From 4d9c345202ef01eec0f3ca6040d9418f4d36f46a Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 26 Nov 2025 22:44:57 +0300 Subject: [PATCH 01/15] Add support for emotes in console chat mode (and support for emotes in console in general) --- src/console.c | 27 ++++++++++++++++++++++++++- src/hu_stuff.c | 24 ++++++++++++++++-------- src/m_emotes.cpp | 9 ++------- src/m_emotes.h | 4 +++- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/console.c b/src/console.c index 6f9579bef..e9f4c80ff 100644 --- a/src/console.c +++ b/src/console.c @@ -33,6 +33,8 @@ #include "d_main.h" #include "m_menu.h" #include "m_textinput.h" +#include "m_emotes.h" +#include "i_time.h" #include "filesrch.h" #ifdef HWRENDER @@ -1453,7 +1455,18 @@ static void CON_DrawHudlines(void) } if (c >= con_width) break; - if (*p < HU_FONTSTART) + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<= con_width) break; + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<= HU_FONTSTART) + if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) + { + HU_DrawScaledEmote((HU_INPUTX + c)<= HU_FONTSTART) //Hurdler: isn't it better like that? { //charwidth = hu_font[w_chat[i]-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); @@ -2119,6 +2120,13 @@ static void HU_DrawChat_Old(void) ++i; + if (w_chat.cursor == i && hu_tick < 4) + { + INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down. + INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight); + V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value); + } + c += charwidth; if (c >= vid.width) { diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index c4dc05ba1..3e55ef788 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -248,7 +248,7 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen) return match; } -void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags) +void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, tic_t anim, INT32 flags) { if (emote->numframes == 0) return; @@ -258,13 +258,8 @@ void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags) const int CHARHEIGHT = 6; - fixed_t scale = FRACUNIT; - - x *= FRACUNIT; - y *= FRACUNIT; - if (emotepatch->width > EMOTEWIDTH) - scale = (FRACUNIT/emotepatch->width)*EMOTEWIDTH; + scale = FixedMul(scale, (FRACUNIT/emotepatch->width)*EMOTEWIDTH); else if (emotepatch->width < EMOTEWIDTH) x += (EMOTEWIDTH-emotepatch->width)*FRACUNIT/2; diff --git a/src/m_emotes.h b/src/m_emotes.h index 9921e4444..efe3d69a2 100644 --- a/src/m_emotes.h +++ b/src/m_emotes.h @@ -17,6 +17,7 @@ extern "C" { #endif #include "doomdef.h" +#include "m_fixed.h" #include "command.h" extern consvar_t cv_emotes; @@ -50,7 +51,8 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen); // Draw the emote, anim should be some kind of timer ticking every game tic // for animated emotes -void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags); +#define M_DrawEmote(x, y, emote, anim, flags) M_DrawScaledEmote((x)< Date: Wed, 26 Nov 2025 22:56:04 +0300 Subject: [PATCH 02/15] Discordify emotes a bit more :chonkbunckle: - When autocompleting emote with enter, don't send it immediately - Don't autocomplete after typing 1 character after : (allows text emotes like ":c") --- src/hu_stuff.c | 8 ++++---- src/m_textinput.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4e55a0630..4fce662ab 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1380,9 +1380,9 @@ boolean HU_Responder(event_t *ev) && ev->data1 != gamecontrol[0][gc_talkkey][1])) return false; - M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete); - - if (c == KEY_ENTER) + if (M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete)) + ; // Do nothing + else if (c == KEY_ENTER) { chat_on = false; chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :) @@ -1911,7 +1911,7 @@ static void HU_DrawChat(void) } } - if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 0)) + if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 1)) { emote_t *suggest; int skip = 0; diff --git a/src/m_textinput.c b/src/m_textinput.c index 2e88948a6..7d050dfc7 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -435,10 +435,10 @@ static int M_TextInputEmoteStart(textinput_t *input) return emotestart; } -static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete) +static boolean M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete) { if (input->cursor == 0) - return; + return false; // If we're in "autocomplete" state, delete ':' for latest autocompleted emote if (autocomplete->complete[0]) @@ -457,8 +457,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a int emotestart = autocomplete->emotestart; // No emote - no autocomplete - if (emotestart == -1 || (size_t)emotestart == input->cursor) - return; + if (emotestart == -1 || input->cursor - emotestart < 2) + return false; strlcpy(autocomplete->complete, &input->buffer[emotestart], input->cursor-emotestart+1); } @@ -476,7 +476,7 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a { // Clear autocompletion state autocomplete->complete[0] = 0; - return; + return false; } } @@ -488,6 +488,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a M_TextInputAddString(input, completed->name); M_TextInputAddChar(input, ':'); + + return true; } boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplete_t *autocomplete) @@ -503,7 +505,8 @@ boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplet if (key == '\t' || (autocomplete->complete[0] == 0 && key == KEY_ENTER)) { - M_TextInputCompleteEmote(input, autocomplete); + if (M_TextInputCompleteEmote(input, autocomplete) && key == KEY_ENTER) // Don't send message if we've autocompleted an emote + ret = true; } else { From 7b4592377eb5c1640d3ae4fddad1efca78c3b378 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 27 Nov 2025 18:40:52 +0300 Subject: [PATCH 03/15] Make emote search case insensetive (emotes themself still are case sensetive) --- src/m_emotes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index 3e55ef788..f6ad2db3a 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -200,7 +200,7 @@ emote_t *M_FindEmote(const char *name, int len, int skip) for (auto &pair: emotes) { - if (pair.first.rfind(query) == std::string::npos) + if (strcasestr(pair.first.c_str(), query) == NULL) continue; if (skip > 0) From b09660204ad61f99c4b0038083b5636364e5639c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 16:17:05 +0100 Subject: [PATCH 04/15] r_bsp: move polyobj renderside check into R_AddPolyObjects uneeded within R_AddLine as outside R_AddPolyObjects this will never be called if currecnt seg is a polyseg --- src/r_bsp.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index e680783dd..0932f9d14 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -322,9 +322,6 @@ static void R_AddLine(seg_t *line) g_portal = NULL; - if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) - return; - // big room fix angle1 = R_PointToAngle64(line->v1->x, line->v1->y); angle2 = R_PointToAngle64(line->v2->x, line->v2->y); @@ -722,6 +719,8 @@ static void R_AddPolyObjects(subsector_t *sub) po = (polyobj_t *)(po->link.next); } + g_portal = NULL; + // for render stats ps_numpolyobjects.value.i += numpolys; @@ -732,8 +731,16 @@ static void R_AddPolyObjects(subsector_t *sub) for (i = 0; i < numpolys; ++i) { qs22j(po_ptrs[i]->segs, po_ptrs[i]->segCount, sizeof(seg_t *), R_PolysegCompare); + for (j = 0; j < po_ptrs[i]->segCount; ++j) - R_AddLine(po_ptrs[i]->segs[j]); + { + seg_t *seg = po_ptrs[i]->segs[j]; + + if (!(seg->polyseg->flags & POF_RENDERSIDES)) + continue; + + R_AddLine(seg); + } } } From 1e394b05300ede6655643174884c4b0ba78d84d9 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 16:20:03 +0100 Subject: [PATCH 05/15] pass frontsector ceiling z to R_Prep3DFloors in both cases "R_Subsector" already got the frontsectors ceiling z, so no need to get it again within R_Prep3DFloors should save some P_GetSectorCeilingZAt per frame --- src/hardware/hw_main.cpp | 2 +- src/r_bsp.cpp | 12 ++++++------ src/r_bsp.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 754878441..f38a084b5 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2964,7 +2964,7 @@ static void HWR_Subsector(size_t num) if (anyMoved == true) { gl_frontsector->numlights = sub->sector->numlights = 0; - R_Prep3DFloors(gl_frontsector); + R_Prep3DFloors(gl_frontsector, locCeilingHeight); sub->sector->lightlist = gl_frontsector->lightlist; sub->sector->numlights = gl_frontsector->numlights; sub->sector->moved = gl_frontsector->moved = false; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 0932f9d14..9adcbccf7 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -812,7 +812,7 @@ static void R_Subsector(size_t num) if (anyMoved == true) { frontsector->numlights = sub->sector->numlights = 0; - R_Prep3DFloors(frontsector); + R_Prep3DFloors(frontsector, ceilingcenterz); sub->sector->lightlist = frontsector->lightlist; sub->sector->numlights = frontsector->numlights; sub->sector->moved = frontsector->moved = false; @@ -1062,7 +1062,7 @@ static void R_Subsector(size_t num) // // This function creates the lightlists that the given sector uses to light // floors/ceilings/walls according to the 3D floors. -void R_Prep3DFloors(sector_t *sector) +void R_Prep3DFloors(sector_t *sector, fixed_t secceilz) { ffloor_t *rover; ffloor_t *best; @@ -1088,13 +1088,13 @@ void R_Prep3DFloors(sector_t *sector) if (count != sector->numlights) { Z_Free(sector->lightlist); - sector->lightlist = static_cast(Z_Calloc(sizeof (*sector->lightlist) * count, PU_LEVEL, NULL)); + sector->lightlist = static_cast(Z_Malloc(sizeof(*sector->lightlist) * count, PU_LEVEL, NULL)); sector->numlights = count; } - else - memset(sector->lightlist, 0, sizeof (lightlist_t) * count); - heighttest = P_GetSectorCeilingZAt(sector, sector->soundorg.x, sector->soundorg.y); + memset(sector->lightlist, 0, sizeof(lightlist_t) * count); + + heighttest = secceilz; // sector ceiling z sector->lightlist[0].height = heighttest + 1; sector->lightlist[0].slope = sector->c_slope; diff --git a/src/r_bsp.h b/src/r_bsp.h index 1d00704f7..5f208f015 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -65,7 +65,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean R_IsEmptyLine(seg_t *line, const sector_t *front, const sector_t *back); INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside); -void R_Prep3DFloors(sector_t *sector); +void R_Prep3DFloors(sector_t *sector, fixed_t secceilz); #ifdef __cplusplus } // extern "C" From 7cf3bceaff748f9ce19853281b6348b87ea594fa Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 16:21:24 +0100 Subject: [PATCH 06/15] HWR_Subsector: avoid calling HWR_AddSprites on already processed sectors --- src/hardware/hw_main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index f38a084b5..2752bf36d 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3170,12 +3170,15 @@ doaddline: // hurdler: false: we only add the sprites, the walls are drawn first if (line) { - // draw sprites first, coz they are clipped to the solidsegs of - // subsectors more 'in front' - if (cv_drawdist.value || current_bsp_culling_distance) - HWR_AddSprites(gl_frontsector); - else - HWR_AddSprites(gl_frontsector); + if (sub->sector->validcount != validcount) + { + // draw sprites first, coz they are clipped to the solidsegs of + // subsectors more 'in front' + if (cv_drawdist.value || current_bsp_culling_distance) + HWR_AddSprites(gl_frontsector); + else + HWR_AddSprites(gl_frontsector); + } //Hurdler: at this point validcount must be the same, but is not because // gl_frontsector doesn't point anymore to sub->sector due to From 3878c2f72af9b9f9228b384cd1343c882d277e8d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 16:26:50 +0100 Subject: [PATCH 07/15] DoAddLine: add fast check for lines with same front and back sectors without middle tex taken from dsda-doom --- src/hardware/hw_main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 2752bf36d..340aa8413 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2347,12 +2347,22 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) static sector_t tempsec; auto do_addline = [&](bool dontdraw) { + // Single sided line? if (!line->backsector) { gld_clipper_SafeAddClipRange(angle2, angle1); } else { + if (line->frontsector == line->backsector) + { + if (R_GetTextureNum(line->sidedef->midtexture) == 0) + { + //e6y: nothing to do here! + return; + } + } + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); if (CheckClip(gl_frontsector, gl_backsector)) From 1849d5aadeec7d78a07797c6cc0cb502e9a4fd42 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 16:43:41 +0100 Subject: [PATCH 08/15] R_ProjectSprite: make sprite clipping work with sloped fake floors/ceilings from eternity engine --- src/hardware/hw_main.cpp | 17 +++++++++++------ src/r_things.cpp | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 340aa8413..8cf74f58d 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4924,13 +4924,18 @@ static void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - if (gl_viewz < FixedToFloat(sectors[phs].floorheight) ? - FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].floorheight) : - gzt < FixedToFloat(sectors[heightsec].floorheight)) + fixed_t secheight; + + secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); + if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? + interp.z >= secheight : + gzt < secheight) return; - if (gl_viewz > FixedToFloat(sectors[phs].ceilingheight) ? - gzt < FixedToFloat(sectors[heightsec].ceilingheight) && gl_viewz >= FixedToFloat(sectors[heightsec].ceilingheight) : - FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].ceilingheight)) + + secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); + if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? + gzt < secheight && viewz >= secheight : + interp.z >= secheight) return; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 1fe07b9db..497f5a1ec 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1697,13 +1697,18 @@ static void R_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - if (viewz < sectors[phs].floorheight ? - interp.z >= sectors[heightsec].floorheight : - gzt < sectors[heightsec].floorheight) + fixed_t secheight; + + secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); + if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? + interp.z >= secheight : + gzt < secheight) return; - if (viewz > sectors[phs].ceilingheight ? - gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - interp.z >= sectors[heightsec].ceilingheight) + + secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); + if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? + gzt < secheight && viewz >= secheight : + interp.z >= secheight) return; } From 2222272d6f943ef0fc3f3af5e1d29cdab2650632 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 16:15:13 +0100 Subject: [PATCH 09/15] remove more unused/uneeded things - delet hw_dll - remove sector_t ceilspeed and floorspeed - remove a bunch of stuff from viewvars_s --- src/d_netcmd.c | 1 + src/hardware/hw_data.h | 4 +- src/hardware/hw_defs.h | 8 +-- src/hardware/hw_dll.h | 67 ----------------------- src/hardware/hw_main.cpp | 18 +++---- src/hardware/hw_portal.h | 2 +- src/hardware/r_opengl/r_opengl.c | 8 --- src/hardware/r_opengl/r_opengl.h | 12 ----- src/p_ceilng.c | 21 -------- src/p_floor.c | 92 +------------------------------- src/p_inter.c | 2 + src/p_spec.c | 3 -- src/r_bsp.cpp | 1 + src/r_defs.h | 9 +--- src/r_fps.h | 4 -- src/r_main.cpp | 29 ++-------- 16 files changed, 28 insertions(+), 253 deletions(-) delete mode 100644 src/hardware/hw_dll.h diff --git a/src/d_netcmd.c b/src/d_netcmd.c index eca887ef8..91f1d8245 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -3898,6 +3898,7 @@ static void Got_Teamchange(const UINT8 **cp, INT32 playernum) if (G_BattleGametype()) // SRB2kart { players[playernum].marescore = 0; + if (K_IsPlayerWanted(&players[playernum])) K_CalculateBattleWanted(); } diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 45d072c28..bb174b205 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -65,7 +65,7 @@ typedef struct GLMipmap_s GLMipmap_t; struct GLMapTexture_s { GLMipmap_t mipmap; - float scaleX; //used for scaling textures on walls + float scaleX; // used for scaling textures on walls float scaleY; }; typedef struct GLMapTexture_s GLMapTexture_t; @@ -74,7 +74,7 @@ typedef struct GLMapTexture_s GLMapTexture_t; struct GLPatch_s { GLMipmap_t *mipmap; - float max_s,max_t; + float max_s, max_t; }; typedef struct GLPatch_s GLPatch_t; diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index ce903c82d..6a8649099 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -79,7 +79,7 @@ typedef struct FColorARGB FColorARGB; // Simple 2D coordinate typedef struct { - FLOAT x,y; + FLOAT x, y; } F2DCoord, v2d_t; // ====================== @@ -142,8 +142,8 @@ enum // Transformed vector, as passed to HWR API typedef struct { - FLOAT x,y,z; - FLOAT s,t; + FLOAT x, y, z; + FLOAT s, t; } FOutVector; typedef struct vbo_vertex_s @@ -173,7 +173,7 @@ typedef struct int rows, columns; int loopcount; - int detail, vertex_count; + int vertex_count; int texture, width, height; boolean rebuild; // VBO needs to be rebuilt diff --git a/src/hardware/hw_dll.h b/src/hardware/hw_dll.h deleted file mode 100644 index 8ee6da2fc..000000000 --- a/src/hardware/hw_dll.h +++ /dev/null @@ -1,67 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2005 by SRB2 Jr. Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Win32 DLL and Shared Objects API definitions - -#ifndef __HWR_DLL_H__ -#define __HWR_DLL_H__ - -// Function declaration for exports from the DLL : -// EXPORT HWRAPI() (); -// If _CREATE_DLL_ is defined the above declaration translates to : -// __declspec(dllexport) WINAPI (); -// If _CREATE_DLL_ is NOT DEFINED the above declaration translates to : -// __declspec(dllexport) type> (WINAPI *) (); - -#ifdef _CREATE_DLL_ - #ifdef __cplusplus - #define EXPORT extern "C" - #else - #define EXPORT - #endif - #ifdef _WIN32 - #define HWRAPI(fn) WINAPI fn - #else - #define HWRAPI(fn) fn - #endif -#else // _CREATE_DLL_ - #define EXPORT typedef - #ifdef _WIN32 - #define HWRAPI(fn) (WINAPI *fn) - #else - #define HWRAPI(fn) (*fn) - #endif -#endif - -// ========================================================================== -// MATHS -// ========================================================================== - -// Constants -#define DEGREE (0.017453292519943295769236907684883l) // 2*PI/360 - -void GL_DBG_Printf(const char *format, ...) /*FUNCPRINTF*/; -#define DBG_Printf GL_DBG_Printf - -#if defined (__CYGWIN__) -void _init() __attribute__((constructor)); -void _fini() __attribute__((destructor)); -#else -void _init(); -void _fini(); -#endif - -#endif diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8cf74f58d..52250bbe8 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2529,7 +2529,7 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) // one if statement will split the space in two for one coordinate // for example: // x < BOXLEFT || BOXLEFT || !(x < BOXLEFT) <-- (same as x >= BOXLEFT) - fixed_t mindist;// = min(min(mindist1, mindist2), min(mindist3, mindist4)); + fixed_t mindist = 0;// = min(min(mindist1, mindist2), min(mindist3, mindist4)); // new thing // calculate distance to axis aligned bounding box. @@ -3022,7 +3022,7 @@ static void HWR_Subsector(size_t num) // Hack to make things continue to work around slopes. locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum,NULL, 255, ceilingcolormap); + PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); } } } @@ -3054,8 +3054,8 @@ static void HWR_Subsector(size_t num) centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && - ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { @@ -3099,9 +3099,9 @@ static void HWR_Subsector(size_t num) centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (centerHeight >= locFloorHeight && - centerHeight <= locCeilingHeight && - ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + centerHeight <= locCeilingHeight && + ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { @@ -5201,7 +5201,6 @@ void HWR_ClearSkyDome(void) sky->rows = sky->columns = 0; sky->loopcount = 0; - sky->detail = 0; sky->texture = -1; sky->width = sky->height = 0; @@ -5220,8 +5219,7 @@ void HWR_BuildSkyDome(void) gl_skyvertex_t *vertex_p; const texture_t *texture = textures[texturetranslation[skytexture]]; - sky->detail = 16; - col_count *= sky->detail; + col_count *= 16; if ((sky->columns != col_count) || (sky->rows != row_count)) HWR_ClearSkyDome(); diff --git a/src/hardware/hw_portal.h b/src/hardware/hw_portal.h index 494110d79..23876281c 100644 --- a/src/hardware/hw_portal.h +++ b/src/hardware/hw_portal.h @@ -65,7 +65,7 @@ extern SINT8 gl_portal_state; // new thing extern gl_portallist_t *currentportallist; -static inline void HWR_SetPortalState (SINT8 state) +static inline void HWR_SetPortalState(SINT8 state) { gl_portal_state = state; } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 185bc7e8a..5fd9c8537 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1734,14 +1734,6 @@ void GL_SetBlend(FBITFIELD PolyFlags) if (Xor & PF_Modulated) { -#if defined (__unix__) || defined (UNIXCOMMON) - if (oglflags & GLF_NOTEXENV) - { - if (!(PolyFlags & PF_Modulated)) - pglColor4ubv(white); - } - else -#endif if (PolyFlags & PF_Modulated) { // mix texture colour with Surface->PolyColor pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 256731083..b62c0698c 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -38,8 +38,6 @@ extern "C" { #endif #endif -#define _CREATE_DLL_ // necessary for Unix AND Windows - #include "../../doomdef.h" #include "../hw_gl.h" #include "../../z_zone.h" @@ -126,18 +124,8 @@ extern GLint maximumAnisotropy; extern boolean supportNPO2tex; extern boolean supportMipMap; -/** \brief OpenGL flags for video driver -*/ -extern INT32 oglflags; - extern GLfloat projMatrix[16]; -typedef enum -{ - GLF_NOZBUFREAD = 0x01, - GLF_NOTEXENV = 0x02, -} oglflags_t; - #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_ceilng.c b/src/p_ceilng.c index a00d78008..1ec076325 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -33,7 +33,6 @@ void T_MoveCeiling(ceiling_t *ceiling) { result_e res; - boolean dontupdate = false; if (ceiling->delaytimer) { @@ -69,9 +68,7 @@ void T_MoveCeiling(ceiling_t *ceiling) case instantMoveCeilingByFrontSector: ceiling->sector->ceilingpic = ceiling->texture; ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case moveCeilingByFrontSector: if (ceiling->texture < -1) // chained linedef executing @@ -83,9 +80,7 @@ void T_MoveCeiling(ceiling_t *ceiling) // case raiseCeilingByLine: case moveCeilingByFrontTexture: ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case fastCrushAndRaise: @@ -189,9 +184,7 @@ void T_MoveCeiling(ceiling_t *ceiling) case instantMoveCeilingByFrontSector: ceiling->sector->ceilingpic = ceiling->texture; ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case moveCeilingByFrontSector: @@ -209,9 +202,7 @@ void T_MoveCeiling(ceiling_t *ceiling) // case lowerCeilingByLine: case moveCeilingByFrontTexture: ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case bounceCeiling: { @@ -290,10 +281,6 @@ void T_MoveCeiling(ceiling_t *ceiling) } break; } - if (!dontupdate) - ceiling->sector->ceilspeed = ceiling->speed*ceiling->direction; - else - ceiling->sector->ceilspeed = 0; } /** Moves a ceiling crusher. @@ -335,12 +322,9 @@ void T_CrushCeiling(ceiling_t *ceiling) switch(ceiling->type) { case crushCeilOnce: - ceiling->sector->ceilspeed = 0; ceiling->sector->ceilingdata = NULL; break; case crushBothOnce: - ceiling->sector->floorspeed = 0; - ceiling->sector->ceilspeed = 0; ceiling->sector->ceilingdata = NULL; break; default: @@ -377,11 +361,6 @@ void T_CrushCeiling(ceiling_t *ceiling) } break; } - - if (ceiling->type == crushBothOnce) - ceiling->sector->floorspeed = ceiling->speed*(-ceiling->direction); - - ceiling->sector->ceilspeed = ceiling->speed*ceiling->direction; } /** Starts a ceiling mover. diff --git a/src/p_floor.c b/src/p_floor.c index f4cc3e992..856d14f09 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -279,7 +279,6 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus void T_MoveFloor(floormove_t *movefloor) { result_e res = 0; - boolean dontupdate = false; if (movefloor->delaytimer) { @@ -325,7 +324,6 @@ void T_MoveFloor(floormove_t *movefloor) else movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight; movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 @@ -341,7 +339,6 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx } movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 @@ -374,7 +371,6 @@ void T_MoveFloor(floormove_t *movefloor) else movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight; movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 @@ -390,14 +386,12 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx } movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it P_RemoveThinker(&movefloor->thinker); - movefloor->sector->floorspeed = 0; movefloor->sector->moved = true; return; default: @@ -406,14 +400,8 @@ void T_MoveFloor(floormove_t *movefloor) } movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it - movefloor->sector->floorspeed = 0; P_RemoveThinker(&movefloor->thinker); - dontupdate = true; } - if (!dontupdate) - movefloor->sector->floorspeed = movefloor->speed*movefloor->direction; - else - movefloor->sector->floorspeed = 0; movefloor->sector->moved = true; } @@ -623,22 +611,13 @@ void T_MoveElevator(elevator_t *elevator) { elevator->sector->floordata = NULL; //jff 2/22/98 elevator->sector->ceilingdata = NULL; //jff 2/22/98 - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; P_RemoveThinker(&elevator->thinker); // remove elevator from actives dontupdate = true; } } - if (!dontupdate) + if (dontupdate) { - elevator->sector->floorspeed = elevator->speed*elevator->direction; - elevator->sector->ceilspeed = 42; - } - else - { - elevator->sector->floorspeed = 0; - elevator->sector->ceilspeed = 0; elevator->sector->floordata = NULL; elevator->sector->ceilingdata = NULL; } @@ -695,8 +674,6 @@ void T_ContinuousFalling(levelspecthink_t *faller) } } - faller->sector->floorspeed = faller->speed*faller->direction; - faller->sector->ceilspeed = 42; faller->sector->moved = true; #undef speed #undef direction @@ -767,9 +744,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) { bouncer->sector->crumblestate = 1; bouncer->sector->ceilingdata = NULL; - bouncer->sector->ceilspeed = 0; bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives return; } @@ -795,8 +770,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; - bouncer->sector->ceilspeed = 0; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives return; @@ -810,8 +783,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; - bouncer->sector->ceilspeed = 0; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives return; @@ -827,9 +798,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->floorheight - 70*FRACUNIT, 0, 0, -1); // move floor - bouncer->sector->floorspeed = -bouncer->speed/2; - bouncer->sector->ceilspeed = 42; - if (bouncer->sector->ceilingheight < bouncer->ceilingwasheight && bouncer->low == 0) // Down { if (abs(bouncer->speed) < 6*FRACUNIT) @@ -878,9 +846,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; - bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; - bouncer->sector->ceilspeed = 0; + bouncer->sector->floordata = NULL;; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives } @@ -920,8 +886,6 @@ void T_StartCrumble(elevator_t *elevator) || (elevator->floordestheight == 0 && elevator->direction == 1)) && elevator->type == elevateContinuous) // No return crumbler { - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; return; } @@ -934,9 +898,6 @@ void T_StartCrumble(elevator_t *elevator) elevator->distance = -15*TICRATE; // Timer until platform returns to original position. else { - // Timer isn't up yet, so just keep waiting. - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; return; } } @@ -965,8 +926,6 @@ void T_StartCrumble(elevator_t *elevator) else elevator->direction = 1; - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; return; } @@ -1050,9 +1009,6 @@ void T_StartCrumble(elevator_t *elevator) 0, // move ceiling elevator->direction ); - - elevator->sector->ceilspeed = 42; - elevator->sector->floorspeed = elevator->speed*elevator->direction; } } } @@ -1063,8 +1019,6 @@ void T_StartCrumble(elevator_t *elevator) elevator->sector->floorheight = elevator->floorwasheight; elevator->sector->floordata = NULL; elevator->sector->ceilingdata = NULL; - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; elevator->sector->moved = true; P_RemoveThinker(&elevator->thinker); } @@ -1121,8 +1075,6 @@ void T_MarioBlock(levelspecthink_t *block) P_RemoveThinker(&block->thinker); block->sector->floordata = NULL; block->sector->ceilingdata = NULL; - block->sector->floorspeed = 0; - block->sector->ceilspeed = 0; } for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;) @@ -1365,8 +1317,6 @@ wegotit: { bridge->sector->floorheight = LOWCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = LOWCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; goto dorest; } @@ -1422,9 +1372,6 @@ wegotit: DIRECTION // direction ); - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; - dorest: // Adjust joined sector heights { @@ -1463,8 +1410,6 @@ wegotit: { bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; continue; } @@ -1519,9 +1464,6 @@ wegotit: 0, // floor or ceiling (0 for floor) DIRECTION // direction ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; } } } @@ -1558,8 +1500,6 @@ wegotit: { bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; continue; } @@ -1614,9 +1554,6 @@ wegotit: 0, // floor or ceiling (0 for floor) DIRECTION // direction ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; } } } @@ -1642,8 +1579,6 @@ wegotit: { bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; continue; } @@ -1698,9 +1633,6 @@ wegotit: 0, // floor or ceiling (0 for floor) DIRECTION // direction ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; } } // Update precip @@ -1875,9 +1807,6 @@ void T_ThwompSector(levelspecthink_t *thwomp) if (res == pastdest) thwomp->direction = 0; // stop moving - - thwomp->sector->ceilspeed = 42; - thwomp->sector->floorspeed = thwomp->speed*thwomp->direction; } else if (thwomp->direction < 0) // Crashing down! { @@ -1932,16 +1861,10 @@ void T_ThwompSector(levelspecthink_t *thwomp) thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay } - - thwomp->sector->ceilspeed = 42; - thwomp->sector->floorspeed = thwomp->speed*thwomp->direction; } else // Not going anywhere, so look for players. { thwomp->direction = -1; - - thwomp->sector->ceilspeed = 0; - thwomp->sector->floorspeed = 0; } actionsector->moved = true; @@ -2355,8 +2278,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[7] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[7]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } @@ -2370,8 +2291,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[5] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[5]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } @@ -2390,8 +2309,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[5] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[5]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } raise->vars[8] = 1; @@ -2404,8 +2321,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[7] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[7]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } raise->vars[8] = -1; @@ -2460,9 +2375,6 @@ void T_RaiseSector(levelspecthink_t *raise) raise->vars[8] // direction ); - raise->sector->ceilspeed = 42; - raise->sector->floorspeed = raise->vars[3]*raise->vars[8]; - for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) sectors[i].moved = true; } diff --git a/src/p_inter.c b/src/p_inter.c index 3518684e3..c95735506 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2164,7 +2164,9 @@ static void P_KillPlayer(player_t *player, mobj_t *source) P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; + if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); } diff --git a/src/p_spec.c b/src/p_spec.c index c8e36176a..7cf2694d0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1978,13 +1978,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { P_RemoveThinker(&((elevator_t *)sectors[secnum].floordata)->thinker); sectors[secnum].floordata = sectors[secnum].ceilingdata = NULL; - sectors[secnum].floorspeed = sectors[secnum].ceilspeed = 0; } else // floormove { P_RemoveThinker(&((floormove_t *)sectors[secnum].floordata)->thinker); sectors[secnum].floordata = NULL; - sectors[secnum].floorspeed = 0; } } @@ -1992,7 +1990,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { P_RemoveThinker(&((ceiling_t *)sectors[secnum].ceilingdata)->thinker); sectors[secnum].ceilingdata = NULL; - sectors[secnum].ceilspeed = 0; } } break; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 9adcbccf7..ac9ab081b 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1124,6 +1124,7 @@ void R_Prep3DFloors(sector_t *sector, fixed_t secceilz) bestslope = *rover->t_slope; continue; } + if (rover->flags & FF_DOUBLESHADOW) { heighttest = P_GetFFloorBottomZAt(rover, sector->soundorg.x, sector->soundorg.y); diff --git a/src/r_defs.h b/src/r_defs.h index 876c63485..e6c5866c6 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -397,9 +397,6 @@ typedef struct sector_s // Sprite culling feature struct line_s *cullheight; - // Current speed of ceiling/floor. For Knuckles to hold onto stuff. - fixed_t floorspeed, ceilspeed; - // Eternity engine slope boolean hasslope; // The sector, or one of its visible FOFs, contains a slope } sector_t; @@ -549,12 +546,10 @@ typedef struct seg_s sector_t *backsector; fixed_t length; // precalculated seg length - #ifdef HWRENDER - floatvertex_t fv1; - floatvertex_t fv2; + floatvertex_t fv1; // v1 in floats - precalculated + floatvertex_t fv2; // v2 in floats - precalculated #endif - polyobj_t *polyseg; // Fake contrast calculated on level load diff --git a/src/r_fps.h b/src/r_fps.h index 7ad5e9f16..c1447897e 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -75,15 +75,11 @@ typedef struct { fixed_t y; fixed_t z; boolean sky; - sector_t *sector; player_t *player; angle_t angle; angle_t aim; angle_t roll; - fixed_t cos; - fixed_t sin; - mobj_t *mobj; } viewvars_t; extern viewvars_t *newview; diff --git a/src/r_main.cpp b/src/r_main.cpp index 452ed79c7..af5e821b2 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1094,7 +1094,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) mobj_t *viewmobj = NULL; -static void R_SetupCommonFrame(player_t * player, sector_t * sector) +static void R_SetupCommonFrame(player_t * player) { newview->player = player; @@ -1104,11 +1104,6 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector) newview->roll = R_ViewRollAngle(player); - if (sector != NULL) - newview->sector = sector; - else - newview->sector = R_PointInSubsectorFast(newview->x, newview->y)->sector; - R_InterpolateView(R_GetTimeFrac(RTF_CAMERA), false); } @@ -1207,7 +1202,6 @@ void R_SkyboxFrame(UINT8 pnum) { player_t *player = &players[displayplayers[pnum]]; camera_t *thiscam = &camera[pnum]; - sector_t *viewsec = NULL; mapheader_t *mh = mapheaderinfo[gamemap-1]; R_SetViewContext(static_cast(VIEWCONTEXT_SKY1 + pnum)); @@ -1233,9 +1227,6 @@ void R_SkyboxFrame(UINT8 pnum) newview->x = viewmobj->x; newview->y = viewmobj->y; newview->z = (viewmobj->spawnpoint) ? (((fixed_t)viewmobj->spawnpoint->angle) << FRACBITS) : 0; - - if (viewmobj->subsector) - viewsec = viewmobj->subsector->sector; } if (mh) @@ -1243,7 +1234,7 @@ void R_SkyboxFrame(UINT8 pnum) R_SetupSkyScale(player, thiscam, mh); } - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } void R_SetupFrame(UINT8 pnum, boolean skybox) @@ -1251,7 +1242,6 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) player_t *player = &players[displayplayers[pnum]]; camera_t *thiscam = &camera[pnum]; boolean chasecam = (cv_chasecam[pnum].value); - sector_t *viewsec = NULL; R_SetViewContext(static_cast(VIEWCONTEXT_PLAYER1 + pnum)); @@ -1295,10 +1285,7 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; - if (viewmobj->subsector) - viewsec = viewmobj->subsector->sector; - - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } else if (thiscam && chasecam) // use outside cam view { @@ -1309,10 +1296,7 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); - if (thiscam->subsector) - viewsec = thiscam->subsector->sector; - - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } else if (player->mo) // use the player's eyes view { @@ -1323,10 +1307,7 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) newview->y = viewmobj->y; newview->z = player->viewz; - if (viewmobj->subsector) - viewsec = viewmobj->subsector->sector; - - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } } From dc40befa884546afce0f4f92f6aabc95d46427bb Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 27 Nov 2025 18:48:32 +0300 Subject: [PATCH 10/15] Use I_GetTime for animated emotes, so anim argument in M_DrawEmote is not needed --- src/console.c | 4 ++-- src/hu_stuff.c | 13 +++++-------- src/m_emotes.cpp | 5 +++-- src/m_emotes.h | 7 +++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/console.c b/src/console.c index e9f4c80ff..d3c2623f4 100644 --- a/src/console.c +++ b/src/console.c @@ -1461,7 +1461,7 @@ static void CON_DrawHudlines(void) if ((emote = M_VerifyEmote((const char *)p, &emotelen))) { - M_DrawScaledEmote(x<= chat_topy) && (y+dy < (chat_bottomy))) { - HU_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + M_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT); dx += EMOTEWIDTH - charwidth; } j += emotelen; @@ -1874,7 +1871,7 @@ static void HU_DrawChat(void) if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) { - HU_DrawEmote(chatx + c + 2, y-1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); + M_DrawEmote(chatx + c + 2, y-1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); c += EMOTEWIDTH - charwidth; i += emotelen-1; drawwidth = EMOTEWIDTH; @@ -1963,7 +1960,7 @@ static void HU_DrawChat(void) hlflag = V_YELLOWMAP; V_DrawSmallString(chatx + boxw + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); - HU_DrawEmote(chatx + boxw + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + M_DrawEmote(chatx + boxw + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); ++skip; } @@ -2105,7 +2102,7 @@ static void HU_DrawChat_Old(void) if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) { - HU_DrawScaledEmote((HU_INPUTX + c)<= HU_FONTSTART) //Hurdler: isn't it better like that? diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index f6ad2db3a..e45dcff58 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -15,6 +15,7 @@ #include #include "m_emotes.h" +#include "i_time.h" // I_GetTime extern "C" { #include "w_wad.h" @@ -248,12 +249,12 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen) return match; } -void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, tic_t anim, INT32 flags) +void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, INT32 flags) { if (emote->numframes == 0) return; - const char *lumpname = emote->frames[(anim/emote->timeperframe) % emote->numframes]; + const char *lumpname = emote->frames[(I_GetTime()/emote->timeperframe) % emote->numframes]; patch_t *emotepatch = (patch_t*)W_CachePatchName(lumpname, PU_CACHE); const int CHARHEIGHT = 6; diff --git a/src/m_emotes.h b/src/m_emotes.h index efe3d69a2..594e219f8 100644 --- a/src/m_emotes.h +++ b/src/m_emotes.h @@ -49,10 +49,9 @@ emote_t *M_FindEmote(const char *name, int len, int skips); // needs to be skipped to get past emote name emote_t *M_VerifyEmote(const char *name, int *emotelen); -// Draw the emote, anim should be some kind of timer ticking every game tic -// for animated emotes -#define M_DrawEmote(x, y, emote, anim, flags) M_DrawScaledEmote((x)< Date: Thu, 27 Nov 2025 17:43:05 +0100 Subject: [PATCH 11/15] tiny optimizations k_kart --- src/k_kart.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 141af3481..201438234 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -809,8 +809,10 @@ boolean K_IsPlayerLosing(player_t *player) boolean K_IsPlayerWanted(player_t *player) { UINT8 i; - if (!(G_BattleGametype())) + + if (!G_BattleGametype()) return false; + for (i = 0; i < 4; i++) { if (battlewanted[i] == -1) @@ -818,6 +820,7 @@ boolean K_IsPlayerWanted(player_t *player) if (player == &players[battlewanted[i]]) return true; } + return false; } @@ -1242,7 +1245,9 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) { if (!playeringame[i] || players[i].spectator) continue; + pingame++; + if (players[i].exiting) dontforcespb = true; if (players[i].kartstuff[k_bumper] > bestbumper) @@ -1256,13 +1261,11 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) // This makes the roulette produce the random noises. if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player)) { -#define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)) for (i = 0; i <= splitscreen; i++) { if (player == &players[displayplayers[i]] && players[displayplayers[i]].kartstuff[k_itemroulette]) - PLAYROULETTESND; + S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)); } -#undef PLAYROULETTESND } roulettestop = TICRATE + (3*(pingame - player->kartstuff[k_position])); @@ -1361,8 +1364,9 @@ static fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against) else { weight = (mobj->player->kartweight)<player->speed > K_GetKartSpeed(mobj->player, false)) - weight += (mobj->player->speed - K_GetKartSpeed(mobj->player, false))/8; + const fixed_t kartspeed = K_GetKartSpeed(mobj->player, false); + if (mobj->player->speed > kartspeed) + weight += (mobj->player->speed - kartspeed)/8; } break; case MT_FALLINGROCK: @@ -1484,9 +1488,9 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) } // if the speed difference is less than this let's assume they're going proportionately faster from each other - if (P_AproxDistance(momdifx, momdify) < (25*mapobjectscale)) + const fixed_t momdiflength = P_AproxDistance(momdifx, momdify); + if (momdiflength < (25*mapobjectscale)) { - fixed_t momdiflength = P_AproxDistance(momdifx, momdify); fixed_t normalisedx = FixedDiv(momdifx, momdiflength); fixed_t normalisedy = FixedDiv(momdify, momdiflength); momdifx = FixedMul((25*mapobjectscale), normalisedx); @@ -1650,7 +1654,7 @@ static void K_UpdateOffroad(player_t *player) // If you are in offroad, a timer starts. if (offroadstrength) { - if (/*K_CheckOffroadCollide(player->mo) &&*/ player->kartstuff[k_offroad] == 0) // With the way offroad is detected now that first check is no longer necessary. -Lat' + if (/*K_CheckOffroadCollide(player->mo) &&*/ player->kartstuff[k_offroad] == 0) // With the way offroad is detected now that first check is no longer necessary. -Lat' player->kartstuff[k_offroad] = (TICRATE/2); if (player->kartstuff[k_offroad] > 0) @@ -2394,7 +2398,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto || player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_hyudorotimer] > 0 || (G_BattleGametype() && ((player->kartstuff[k_bumper] <= 0 && player->kartstuff[k_comebacktimer]) || player->kartstuff[k_comebackmode] == 1))) { - if (!force) // if shoulddamage force, we go THROUGH that. + if (!force) // if shoulddamage force, we go THROUGH that. { K_DoInstashield(player); return; @@ -2439,6 +2443,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); @@ -2573,6 +2578,7 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); @@ -2692,6 +2698,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); @@ -2852,9 +2859,9 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 for (i = 0; i < number; i++) { fa = (i*degrees); - v[0] = FixedMul(FINECOSINE(fa),radius); + v[0] = FixedMul(FINECOSINE(fa), radius); v[1] = 0; - v[2] = FixedMul(FINESINE(fa),radius); + v[2] = FixedMul(FINESINE(fa), radius); v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); @@ -6285,7 +6292,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_KartUpdatePosition(player); - if (LIKELY(!player->exiting)) + if (!player->exiting) { if (player->kartstuff[k_oldposition] < player->kartstuff[k_position]) // But first, if you lost a place, { From c81cd48552d9e63cda680ceea9ddf47a20b507e2 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 17:39:39 +0100 Subject: [PATCH 12/15] R_ProjectSprite: move fakeflat clipping before light maths so if applicable we have slightly less work --- src/r_things.cpp | 50 ++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 497f5a1ec..e250e877b 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1612,6 +1612,33 @@ static void R_ProjectSprite(mobj_t *thing) return; } + // killough 3/27/98: exclude things totally separated + // from the viewer, by either water or fake ceilings + // killough 4/11/98: improve sprite clipping for underwater/fake ceilings + + heightsec = thing->subsector->sector->heightsec; + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) + phs = viewplayer->mo->subsector->sector->heightsec; + else + phs = -1; + + if (heightsec != -1 && phs != -1) // only clip things which are in special sectors + { + fixed_t secheight; + + secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); + if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? + interp.z >= secheight : + gzt < secheight) + return; + + secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); + if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? + gzt < secheight && viewz >= secheight : + interp.z >= secheight) + return; + } + if (thing->frame & FF_ABSOLUTELIGHTLEVEL) { const UINT8 n = R_ThingLightLevel(thing); @@ -1689,29 +1716,6 @@ static void R_ProjectSprite(mobj_t *thing) lights_array = scalelight[lightnum]; } - heightsec = thing->subsector->sector->heightsec; - if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) - phs = viewplayer->mo->subsector->sector->heightsec; - else - phs = -1; - - if (heightsec != -1 && phs != -1) // only clip things which are in special sectors - { - fixed_t secheight; - - secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); - if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? - interp.z >= secheight : - gzt < secheight) - return; - - secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); - if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? - gzt < secheight && viewz >= secheight : - interp.z >= secheight) - return; - } - // store information in a vissprite vis = R_NewVisSprite(); vis->heightsec = heightsec; //SoM: 3/17/2000 From 1c82c338a58c1d06fc93bf381bd38f546a154bd7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 18:57:12 +0100 Subject: [PATCH 13/15] sprite gzt is float in opengl render........ --- src/hardware/hw_main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 52250bbe8..05c69b2d4 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4925,16 +4925,17 @@ static void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { fixed_t secheight; + const fixed_t fgzt = FloatToFixed(gzt); secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? interp.z >= secheight : - gzt < secheight) + fgzt < secheight) return; secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? - gzt < secheight && viewz >= secheight : + fgzt < secheight && viewz >= secheight : interp.z >= secheight) return; } From c26d2faee98d6d0d0d11a4ae23682ccbc9d26616 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 22:03:05 +0100 Subject: [PATCH 14/15] OpenGL: fixup spherefrustum culling and use it for sprites clips sprites that are out of our view, especially with precip this may lead to significant speedup in certain cases huge thanks to indev for helping with this <3 huge thanks to dsda-doom for the maths needed! --- src/hardware/hw_clip.c | 29 +++---- src/hardware/hw_clip.h | 2 +- src/hardware/hw_main.cpp | 129 ++++++++++++++++++++++++------- src/hardware/r_opengl/r_opengl.c | 2 +- src/hardware/r_opengl/r_opengl.h | 1 + 5 files changed, 115 insertions(+), 48 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 3365136b3..caa19f565 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -348,34 +348,29 @@ angle_t gld_FrustumAngle(angle_t tiltangle) // gld_FrustumSetup // -static GLdouble viewMatrix[16]; -static GLdouble projMatrix[16]; float frustum[6][4]; #define CALCMATRIX(a, b, c, d, e, f, g, h)\ -(float)(viewMatrix[a] * projMatrix[b] + \ -viewMatrix[c] * projMatrix[d] + \ -viewMatrix[e] * projMatrix[f] + \ -viewMatrix[g] * projMatrix[h]) + (modelMatrix[a] * projMatrix[b] + \ + modelMatrix[c] * projMatrix[d] + \ + modelMatrix[e] * projMatrix[f] + \ + modelMatrix[g] * projMatrix[h]) #define NORMALIZE_PLANE(i)\ -t = (float)sqrt(\ -frustum[i][0] * frustum[i][0] + \ -frustum[i][1] * frustum[i][1] + \ -frustum[i][2] * frustum[i][2]); \ -frustum[i][0] /= t; \ -frustum[i][1] /= t; \ -frustum[i][2] /= t; \ -frustum[i][3] /= t + t = sqrtf(\ + frustum[i][0] * frustum[i][0] + \ + frustum[i][1] * frustum[i][1] + \ + frustum[i][2] * frustum[i][2]); \ + frustum[i][0] /= t; \ + frustum[i][1] /= t; \ + frustum[i][2] /= t; \ + frustum[i][3] /= t void gld_FrustumSetup(void) { float t; float clip[16]; - pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); - pglGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix); - clip[0] = CALCMATRIX(0, 0, 1, 4, 2, 8, 3, 12); clip[1] = CALCMATRIX(0, 1, 1, 5, 2, 9, 3, 13); clip[2] = CALCMATRIX(0, 2, 1, 6, 2, 10, 3, 14); diff --git a/src/hardware/hw_clip.h b/src/hardware/hw_clip.h index 4299fbaea..232d09c06 100644 --- a/src/hardware/hw_clip.h +++ b/src/hardware/hw_clip.h @@ -16,7 +16,7 @@ extern "C" { #include "../tables.h" #include "../doomtype.h" -//#define HAVE_SPHEREFRUSTRUM // enable if you want gld_SphereInFrustum and related code +#define HAVE_SPHEREFRUSTRUM // enable if you want gld_SphereInFrustum and related code boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle); void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 05c69b2d4..5294301b7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -83,6 +83,13 @@ float gl_viewsin = 0.0f, gl_viewcos = 0.0f; static float gl_viewludsin, gl_viewludcos; static angle_t gl_aimingangle; +static float yaw = 0.0f; +static float inv_yaw = 0.0f; +static float cos_inv_yaw = 0.0f; +static float sin_inv_yaw = 0.0f; + +static constexpr float deg2radians = (M_PIf / 180.0f); + seg_t *gl_curline = NULL; side_t *gl_sidedef = NULL; line_t *gl_linedef = NULL; @@ -4645,6 +4652,7 @@ static void HWR_ProjectSprite(mobj_t *thing) float tr_x, tr_y; float tz; float x1, x2; + float y1, y2; float z1, z2; float rightsin, rightcos; float this_scale; @@ -4867,17 +4875,6 @@ static void HWR_ProjectSprite(mobj_t *thing) spr_offset += interp.spritexoffset; spr_topoffset += interp.spriteyoffset; - if (papersprite) - { - rightsin = FixedToFloat(FINESINE(interp.angle >> ANGLETOFINESHIFT)); - rightcos = FixedToFloat(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); - } - else - { - rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - } - spritexscale *= this_scale; spriteyscale *= this_scale; @@ -4894,19 +4891,17 @@ static void HWR_ProjectSprite(mobj_t *thing) x2 = (FixedToFloat(spr_width - spr_offset) * spritexscale); } - z1 = tr_y + x1 * rightsin; - z2 = tr_y - x2 * rightsin; - x1 = tr_x + x1 * rightcos; - x2 = tr_x - x2 * rightcos; + y1 = (FixedToFloat(spr_topoffset) * spriteyscale); + y2 = (FixedToFloat(spr_height - spr_topoffset) * spriteyscale); if (vflip) { - gz = FixedToFloat(interp.z + thing->height) - (FixedToFloat(spr_topoffset) * spriteyscale); + gz = FixedToFloat(interp.z + thing->height) - y1; gzt = gz + (FixedToFloat(spr_height) * spriteyscale); } else { - gzt = FixedToFloat(interp.z) + (FixedToFloat(spr_topoffset) * spriteyscale); + gzt = FixedToFloat(interp.z) + y1; gz = gzt - (FixedToFloat(spr_height) * spriteyscale); } @@ -4916,6 +4911,32 @@ static void HWR_ProjectSprite(mobj_t *thing) return; } + // rest in piece sweet prince + /*if (cv_glshearing.value && !papersprite) + { + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + const fixed_t fixedtz = FloatToFixed(tz); + if (interp.z > viewz + FixedMul(centeryfrac, fixedtz) || // view center accounted for aspect (i hope) + FloatToFixed(gzt) < viewz + FixedMul((centeryfrac - (viewheight << FRACBITS)), fixedtz)) // view center accounted for aspect but the bottom (OwO) + { + return; + } + }*/ + + if (!gld_SphereInFrustum( + (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width), FixedToFloat(spr_height)) / 2.0f * 1.5f)) + { + return; + } + heightsec = thing->subsector->sector->heightsec; if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; @@ -4940,6 +4961,24 @@ static void HWR_ProjectSprite(mobj_t *thing) return; } + if (papersprite) + { + rightsin = FixedToFloat(FINESINE(interp.angle >> ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); + } + else + { + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + } + + z1 = tr_y + x1 * rightsin; + z2 = tr_y - x2 * rightsin; + x1 = tr_x + x1 * rightcos; + x2 = tr_x - x2 * rightcos; + //y1 = tr_y + y1 * rightcos; + //y2 = tr_y - y2 * rightcos; + // store information in a vissprite vis = HWR_NewVisSprite(); vis->x1 = x1; @@ -5015,12 +5054,16 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) float tr_x, tr_y; float tz; float x1, x2; + float y1, y2; float z1, z2; + float gz, gzt; float rightsin, rightcos; float this_scale; spritedef_t *sprdef; spriteframe_t *sprframe; size_t lumpoff; + fixed_t spr_width, spr_height; + fixed_t spr_offset, spr_topoffset; unsigned rot = 0; UINT8 flip; @@ -5081,22 +5124,46 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) lumpoff = sprframe->lumpid[0]; flip = sprframe->flip; // Will only be 0x00 or 0xFF - rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + spr_width = spritecachedinfo[lumpoff].width; + spr_height = spritecachedinfo[lumpoff].height; + spr_offset = spritecachedinfo[lumpoff].offset; + spr_topoffset = spritecachedinfo[lumpoff].topoffset; if (flip) { - x1 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); - x2 = FixedToFloat(spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spr_width - spr_offset); + x2 = FixedToFloat(spr_offset); } else { - x1 = FixedToFloat(spritecachedinfo[lumpoff].offset); - x2 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spr_offset); + x2 = FixedToFloat(spr_offset); } + y1 = (FixedToFloat(spr_topoffset)); + y2 = (FixedToFloat(spr_height - spr_topoffset)); + x1 *= this_scale; x2 *= this_scale; + y1 *= this_scale; + y2 *= this_scale; + + if (!gld_SphereInFrustum( + (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width), FixedToFloat(spr_height)) / 2.0f * 1.5f)) + { + return; + } + + // set top/bottom coords + gzt = FixedToFloat(interp.z) + y1; + gz = gzt - (FixedToFloat(spr_height) * this_scale); + + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); z1 = tr_y + x1 * rightsin; z2 = tr_y - x2 * rightsin; @@ -5125,8 +5192,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->gzt = FixedToFloat(interp.z) + (FixedToFloat(spritecachedinfo[lumpoff].topoffset) * this_scale); - vis->gz = vis->gzt - (FixedToFloat(spritecachedinfo[lumpoff].height) * this_scale); + vis->gzt = gzt; + vis->gz = gz; vis->precip = thing; } @@ -5140,11 +5207,10 @@ static gl_sky_t gl_sky; static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, signed char yflip, float delta, boolean foglayer) { - static constexpr float radians = (M_PIf / 180.0f); static constexpr float scale = 10000.0f; - static constexpr float maxSideAngle = 60.0f * radians; + static constexpr float maxSideAngle = 60.0f * deg2radians; - float topAngle = ((float)c / (float)sky->columns * 360.0f) * radians; + float topAngle = ((float)c / (float)sky->columns * 360.0f) * deg2radians; float sideAngle = (maxSideAngle * (float)(sky->rows - r) / (float)sky->rows); float height = sinf(sideAngle); float realRadius = (scale * cosf(sideAngle)); @@ -5383,6 +5449,12 @@ void HWR_SetTransform(float fpov) HWR_SetTransformAiming(&atransform); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE); + yaw = 270.0f - atransform.angley; + inv_yaw = 180.0f - yaw; + const float inv_yaw_radians = inv_yaw * deg2radians; + cos_inv_yaw = cosf(inv_yaw_radians); + sin_inv_yaw = sinf(inv_yaw_radians); + // only needed for sprite billboarding if (cv_glspritebillboarding.value && !cv_glshearing.value) { @@ -5489,7 +5561,6 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_ HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); HWR_SetTransform(fpov); - HWR_ClearSprites(); HWR_ClearClipper(); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 5fd9c8537..c69d8c1b1 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -127,7 +127,7 @@ GLuint gl_num_extensions; int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -static GLfloat modelMatrix[16]; +GLfloat modelMatrix[16]; GLfloat projMatrix[16] = {0}; static GLint viewport[4]; diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index b62c0698c..13ba9f6f5 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -124,6 +124,7 @@ extern GLint maximumAnisotropy; extern boolean supportNPO2tex; extern boolean supportMipMap; +extern GLfloat modelMatrix[16]; extern GLfloat projMatrix[16]; #ifdef __cplusplus From d2d3afc7f4b47d9c77ef877d32686ae1ddacbdb8 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 27 Nov 2025 22:07:55 +0100 Subject: [PATCH 15/15] software: clip sprites that are out of view similar to what the frustum cull does in opengl, clips sprites that are out of view in vertical direction --- src/r_things.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/r_things.cpp b/src/r_things.cpp index e250e877b..489ce8911 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1612,6 +1612,20 @@ static void R_ProjectSprite(mobj_t *thing) return; } + if (!papersprite) + { + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + if (interp.z > viewz + FixedMul(FixedDiv(centeryfrac, projectiony), tz) || + gzt < viewz + FixedMul(FixedDiv(centeryfrac - (viewheight << FRACBITS), projectiony), tz)) + { + return; + } + } + // killough 3/27/98: exclude things totally separated // from the viewer, by either water or fake ceilings // killough 4/11/98: improve sprite clipping for underwater/fake ceilings @@ -1961,6 +1975,17 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + if (interp.z > viewz + FixedMul(FixedDiv(centeryfrac, projectiony), tz) || + gzt < viewz + FixedMul(FixedDiv(centeryfrac - (viewheight << FRACBITS), projectiony), tz)) + { + return; + } + // aspect ratio stuff : yscale = FixedDiv(projectiony, tz);