From de8464cd2f8217e1cd1f50c195a185929e5071de Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Sat, 24 Feb 2024 20:04:48 -0500 Subject: [PATCH 01/11] Add alpha support for mobjs --- src/hardware/hw_main.c | 15 ++++++++++++++- src/lua_mobjlib.c | 13 +++++++++++++ src/p_mobj.c | 4 ++++ src/p_mobj.h | 1 + src/p_saveg.c | 9 ++++++++- src/p_user.c | 1 + src/r_things.c | 18 ++++++++++++++++++ src/r_things.h | 1 + 8 files changed, 60 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 5a0d997fa..40f17301b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2825,7 +2825,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) } HWR_Lighting(&sSurf, 0, colormap); - sSurf.PolyColor.s.alpha = alpha; + sSurf.PolyColor.s.alpha = FixedMul(thing->alpha, alpha); if (HWR_UseShader()) { @@ -2999,11 +2999,16 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // baseWallVerts is used to know the final shape to easily get the vertex // co-ordinates memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts)); + + UINT32 newalpha = spr->mobj->alpha; // if sprite has linkdraw, then dont write to z-buffer (by not using PF_Occlude) // this will result in sprites drawn afterwards to be drawn on top like intended when using linkdraw. if ((spr->mobj->flags2 & MF2_LINKDRAW) && spr->mobj->tracer) + { + newalpha = spr->mobj->tracer->alpha; occlusion = 0; + } else occlusion = PF_Occlude; @@ -3039,6 +3044,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } + + Surf.PolyColor.s.alpha = FixedMul(newalpha, Surf.PolyColor.s.alpha); if (HWR_UseShader()) { @@ -3488,11 +3495,15 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) FBITFIELD blend = 0; FBITFIELD occlusion; boolean use_linkdraw_hack = false; + UINT32 newalpha = spr->mobj->alpha; // if sprite has linkdraw, then dont write to z-buffer (by not using PF_Occlude) // this will result in sprites drawn afterwards to be drawn on top like intended when using linkdraw. if ((spr->mobj->flags2 & MF2_LINKDRAW) && spr->mobj->tracer) + { occlusion = 0; + newalpha = spr->mobj->tracer->alpha; + } else occlusion = PF_Occlude; @@ -3528,6 +3539,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|occlusion; if (!occlusion) use_linkdraw_hack = true; } + + Surf.PolyColor.s.alpha = FixedMul(newalpha, Surf.PolyColor.s.alpha); if (spr->renderflags & RF_SHADOWEFFECTS) { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 7fd16b32b..79d839677 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -69,6 +69,7 @@ enum mobj_e { mobj_color, mobj_translation, mobj_blendmode, + mobj_alpha, mobj_bnext, mobj_bprev, mobj_hnext, @@ -150,6 +151,7 @@ static const char *const mobj_opt[] = { "color", "translation", "blendmode", + "alpha", "bnext", "bprev", "hnext", @@ -354,6 +356,9 @@ static int mobj_get(lua_State *L) case mobj_blendmode: lua_pushinteger(L, mo->blendmode); break; + case mobj_alpha: + lua_pushinteger(L, mo->alpha); + break; case mobj_bnext: if (mo->blocknode && mo->blocknode->bnext) { LUA_PushUserdata(L, mo->blocknode->bnext->mobj, META_MOBJ); @@ -733,6 +738,14 @@ static int mobj_set(lua_State *L) mo->blendmode = blendmode; break; } + case mobj_alpha: + INT32 alpha = (INT32)luaL_checkinteger(L, 3); + if (alpha < 0) + alpha = 0; + else if (alpha > FRACUNIT) + alpha = FRACUNIT; + mo->alpha = alpha; + break; case mobj_bnext: return NOSETPOS; case mobj_bprev: diff --git a/src/p_mobj.c b/src/p_mobj.c index 8bc6abc54..72a4c1ddb 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10503,6 +10503,9 @@ void P_MobjThinker(mobj_t *mobj) mobj->frame &= ~FF_TRANSMASK; mobj->frame |= value << FF_TRANSSHIFT; + + // TODO: Consider replacing the above with the commented-out line of code below + //mobj->alpha = FixedDiv(mobj->fuse, mobj->info->damage); } break; default: @@ -10838,6 +10841,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type, ...) // Sprite rendering mobj->blendmode = AST_TRANSLUCENT; + mobj->alpha = FRACUNIT; mobj->spritexscale = mobj->spriteyscale = mobj->scale; mobj->spritexoffset = mobj->spriteyoffset = 0; mobj->floorspriteslope = NULL; diff --git a/src/p_mobj.h b/src/p_mobj.h index f833415ed..401071295 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -313,6 +313,7 @@ typedef struct mobj_s UINT32 renderflags; // render flags INT32 blendmode; // blend mode + UINT32 alpha; // alpha fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; diff --git a/src/p_saveg.c b/src/p_saveg.c index 6c6548c56..c8b812a3e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1742,7 +1742,8 @@ typedef enum MD2_DISPOFFSET = 1<<23, MD2_DRAWONLYFORPLAYER = 1<<24, MD2_DONTDRAWFORVIEWMOBJ = 1<<25, - MD2_TRANSLATION = 1<<26 + MD2_TRANSLATION = 1<<26, + MD2_ALPHA = 1<<27 } mobj_diff2_t; typedef enum @@ -1985,6 +1986,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_DONTDRAWFORVIEWMOBJ; if (mobj->dispoffset != mobj->info->dispoffset) diff2 |= MD2_DISPOFFSET; + if (mobj->alpha < FRACUNIT) + diff2 |= MD2_ALPHA; if (diff2 != 0) diff |= MD_MORE; @@ -2168,6 +2171,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, mobj->dispoffset); if (diff2 & MD2_TRANSLATION) WRITEUINT16(save_p, mobj->translation); + if (diff2 & MD2_ALPHA) + WRITEUINT32(save_p, mobj->alpha); WRITEUINT32(save_p, mobj->mobjnum); } @@ -3234,6 +3239,8 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->dispoffset = mobj->info->dispoffset; if (diff2 & MD2_TRANSLATION) mobj->translation = READUINT16(save_p); + if (diff2 & MD2_ALPHA) + mobj->alpha = READUINT32(save_p); if (diff & MD_REDFLAG) { diff --git a/src/p_user.c b/src/p_user.c index 9d0eed288..2f73db272 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2065,6 +2065,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->renderflags = mobj->renderflags; ghost->blendmode = mobj->blendmode; + ghost->alpha = mobj->alpha; ghost->spritexscale = mobj->spritexscale; ghost->spriteyscale = mobj->spriteyscale; diff --git a/src/r_things.c b/src/r_things.c index 57078b4a6..a27a03e77 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -763,6 +763,14 @@ UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 trans return NULL; } +transnum_t R_GetTransmapFromAlpha(UINT32 alpha, transnum_t transmap) +{ + INT32 value = 10 - transmap; + value = 10 - (FixedCeil(alpha * value)>>FRACBITS); + + return value; +} + // // R_DrawVisSprite // mfloorclip and mceilingclip should also be set. @@ -1268,6 +1276,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, floordiff = abs((isflipped ? interp.height : 0) + interp.z - groundz); trans = floordiff / (100*FRACUNIT) + 3; + trans = R_GetTransmapFromAlpha(thing->alpha, trans); if (trans >= 9) return; scalemul = FixedMul(FRACUNIT - floordiff/640, scale); @@ -1952,6 +1961,11 @@ static void R_ProjectSprite(mobj_t *thing) } else trans = 0; + + if ((oldthing->flags2 & MF2_LINKDRAW) && oldthing->tracer) + trans = R_GetTransmapFromAlpha(oldthing->tracer->alpha, trans); + else + trans = R_GetTransmapFromAlpha(oldthing->alpha, trans); // Check if this sprite needs to be rendered like a shadow shadowdraw = (!!(thing->renderflags & RF_SHADOWDRAW) && !(papersprite || splat)); @@ -3414,6 +3428,10 @@ boolean R_ThingVisible (mobj_t *thing) (thing->sprite == SPR_NULL) || // Don't draw null-sprites (thing->flags2 & MF2_DONTDRAW) || // Don't draw MF2_LINKDRAW objects (thing->drawonlyforplayer && thing->drawonlyforplayer != viewplayer) || // Don't draw other players' personal objects + //(thing->alpha == 0) || // Don't draw objects with an alpha of 0 + ((rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || + (rendermode == render_opengl && thing->alpha == 0)) || // TODO: Maybe rethink this + //(rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || (!P_MobjWasRemoved(r_viewmobj) && ( (r_viewmobj == thing) || // Don't draw first-person players or awayviewmobj objects (r_viewmobj->player && r_viewmobj->player->followmobj == thing) || // Don't draw first-person players' followmobj diff --git a/src/r_things.h b/src/r_things.h index 043b454b0..086dd8b55 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -90,6 +90,7 @@ boolean R_ThingIsFullDark (mobj_t *thing); boolean R_ThingIsFlashing (mobj_t *thing); UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 translation); +transnum_t R_GetTransmapFromAlpha(UINT32 alpha, transnum_t transmap); void R_ThingOffsetOverlay (mobj_t *thing, fixed_t *outx, fixed_t *outy); From d168bbaff38dbf325e2a7311fda1ff6466473cdc Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 24 Feb 2024 16:28:02 -0500 Subject: [PATCH 02/11] compiling SRB2 with OSXCROSS --- .gitlab-ci.yml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 016ac951b..9d870dcd7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -764,3 +764,81 @@ Alpine 3 GCC Dedicated: - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + +osxcross x86_64: + stage: build + + when: manual + + allow_failure: true + + artifacts: + name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang" + + variables: + OSXCROSS_HOST: x86_64-apple-darwin21.4 + LD: x86_64-apple-darwin21.4-ld + + script: + - - | + # apt_development + echo -e "\e[0Ksection_start:`date +%s`:macports_development[collapsed=true]\r\e[0KInstalling development packages" + - osxcross-macports install curl libopenmpt libsdl2_mixer + - | + # apt_development + echo -e "\e[0Ksection_end:`date +%s`:macports_development\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KBuilding Makefiles" + - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -D CPM_USE_LOCAL_PACKAGES:BOOL=ON -D OPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -D SDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -D SRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -D SRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -D SRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" + - make --directory=build.osxcross--keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + +osxcross arm64: + stage: build + + when: manual + + allow_failure: true + + artifacts: + name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang" + + variables: + OSXCROSS_HOST: arm64-apple-darwin21.4 + LD: arm64-apple-darwin21.4-ld + + script: + - - | + # apt_development + echo -e "\e[0Ksection_start:`date +%s`:macports_development[collapsed=true]\r\e[0KInstalling development packages" + - osxcross-macports install --arm64 curl libopenmpt libsdl2_mixer + - | + # apt_development + echo -e "\e[0Ksection_end:`date +%s`:macports_development\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KBuilding Makefiles" + - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -D CPM_USE_LOCAL_PACKAGES:BOOL=ON -D OPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -D SDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -D SRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -D SRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -D SRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" + + - - | + # make + echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" + - make --directory=build.osxcross--keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 + - | + # make + echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" From 4190106f2e6c0933b850ca01810fa37aa6cccada Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 24 Feb 2024 16:40:41 -0500 Subject: [PATCH 03/11] Gitlab CI: cmake create config.h, keep that as an artifact --- .gitlab-ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9d870dcd7..15892b24d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -533,7 +533,7 @@ Debian stable Clang: artifacts: paths: - "build.clang/bin/" - - "build.clang/src/comptime.h" + - "build.clang/src/config.h" expose_as: "clang" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang" @@ -589,7 +589,7 @@ Debian testing Clang: artifacts: paths: - "build.clang/bin/" - - "build.clang/src/comptime.h" + - "build.clang/src/config.h" expose_as: "testing-clang" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-clang" @@ -773,6 +773,10 @@ osxcross x86_64: allow_failure: true artifacts: + paths: + - "build.osxcross/bin/" + - "build.osxcross/src/config.h" + expose_as: "Mac x86_64" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang" variables: @@ -799,7 +803,7 @@ osxcross x86_64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" - - make --directory=build.osxcross--keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 + - make --directory=build.osxcross --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" @@ -812,6 +816,10 @@ osxcross arm64: allow_failure: true artifacts: + paths: + - "build.osxcross/bin/" + - "build.osxcross/src/config.h" + expose_as: "Mac arm64" name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang" variables: @@ -838,7 +846,7 @@ osxcross arm64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" - - make --directory=build.osxcross--keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 + - make --directory=build.osxcross --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" From 1a8311d8edecb56956f62bc3d732c8cf7d718266 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Sat, 24 Feb 2024 22:34:36 +0000 Subject: [PATCH 04/11] Update .gitlab-ci.yml file Do not fallback to Linux Makefile for Mac builds` Do not build with libgme, it needs to linked with C++ runtime library --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 15892b24d..d558e50ed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -564,7 +564,7 @@ Debian stable Clang: - - | # cmake echo -e "\e[0Ksection_start:`date +%s`:cmake[collapsed=false]\r\e[0KBuilding Makefiles" - - cmake -B build.clang -D CPM_USE_LOCAL_PACKAGES:BOOL=ON -D SRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -D SRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -G "Unix Makefiles" + - cmake -B build.clang -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" - | # cmake echo -e "\e[0Ksection_end:`date +%s`:cmake\r\e[0K" @@ -572,7 +572,7 @@ Debian stable Clang: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" - - make --directory=build.clang --keep-going || make --directory=src --keep-going + - make --directory=build.clang --keep-going || make --directory=build.clang --keep-going - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" @@ -795,7 +795,7 @@ osxcross x86_64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KBuilding Makefiles" - - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -D CPM_USE_LOCAL_PACKAGES:BOOL=ON -D OPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -D SDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -D SRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -D SRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -D SRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" + - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" @@ -803,7 +803,7 @@ osxcross x86_64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" - - make --directory=build.osxcross --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 + - make --directory=build.osxcross --keep-going || make --directory=build.osxcross --keep-going - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" @@ -838,7 +838,7 @@ osxcross arm64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KBuilding Makefiles" - - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -D CPM_USE_LOCAL_PACKAGES:BOOL=ON -D OPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -D SDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -D SRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -D SRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -D SRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" + - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" @@ -846,7 +846,7 @@ osxcross arm64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2" - - make --directory=build.osxcross --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 + - make --directory=build.osxcross --keep-going || make --directory=build.osxcross --keep-going - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" From 2ca791a2ad2d53926c03440afd1abb3a3b895dff Mon Sep 17 00:00:00 2001 From: Logan Aerl Arias Date: Sat, 24 Feb 2024 19:37:38 -0500 Subject: [PATCH 05/11] disable libgme by default --- CMakeLists.txt | 1 + src/CMakeLists.txt | 12 +++++++----- thirdparty/CMakeLists.txt | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8803620e7..358e62cc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ cmake_dependent_option( OFF ) option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON) +option(SRB2_CONFIG_USE_GME "Enable GME playback support" OFF) option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF) option(SRB2_CONFIG_ERRORMODE "Compile C code with warnings treated as errors." OFF) option(SRB2_CONFIG_DEBUGMODE "Compile with PARANOIA, ZDEBUG, RANGECHECK and PACKETDROP defined." OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 160174080..1bdfc94f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -173,11 +173,13 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") target_compile_definitions(SRB2SDL2 PRIVATE -DMACOSX) endif() -target_link_libraries(SRB2SDL2 PRIVATE gme) -target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME) -if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") - # this sucks but gme doesn't use modern cmake to delineate public headers - target_include_directories(SRB2SDL2 PRIVATE "${libgme_SOURCE_DIR}") +if("${SRB2_CONFIG_USE_GME}") + target_link_libraries(SRB2SDL2 PRIVATE gme) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME) + if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + # this sucks but gme doesn't use modern cmake to delineate public headers + target_include_directories(SRB2SDL2 PRIVATE "${libgme_SOURCE_DIR}") + endif() endif() target_link_libraries(SRB2SDL2 PRIVATE openmpt) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index f33b3bf3f..19aa22c9b 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -18,4 +18,6 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") include("cpm-openmpt.cmake") endif() -include("cpm-libgme.cmake") +if("${SRB2_CONFIG_USE_GME}") + include("cpm-libgme.cmake") +endif() From eab8df9f35abe64a8423d63b355eddefda795e6e Mon Sep 17 00:00:00 2001 From: Logan Aerl Arias Date: Sun, 25 Feb 2024 00:52:40 +0000 Subject: [PATCH 06/11] auto build MacOSX binary for x86_64 --- .gitlab-ci.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d558e50ed..b21ce1b00 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -768,10 +768,6 @@ Alpine 3 GCC Dedicated: osxcross x86_64: stage: build - when: manual - - allow_failure: true - artifacts: paths: - "build.osxcross/bin/" @@ -795,7 +791,7 @@ osxcross x86_64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KBuilding Makefiles" - - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" + - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_CONFIG_USE_GME:BOOL=OFF -G "Unix Makefiles" - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" @@ -838,7 +834,7 @@ osxcross arm64: - - | # make echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KBuilding Makefiles" - - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_USE_LIBGME:BOOL=OFF -G "Unix Makefiles" + - cmake -B build.osxcross --toolchain /osxcross/toolchain.cmake -DCPM_USE_LOCAL_PACKAGES:BOOL=ON -DOPENMPT_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/include" -DSDL2_INCLUDE_DIR:PATH="/osxcross/macports/pkgs/opt/local/lib" -DSRB2_CONFIG_ENABLE_TESTS:BOOL=OFF -DSRB2_CONFIG_SYSTEM_LIBRARIES:BOOL=ON -DSRB2_CONFIG_USE_GME:BOOL=OFF -G "Unix Makefiles" - | # make echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K" From 17e7aea311df6fead55921fa0ddacc72ca8eaf8a Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Wed, 28 Feb 2024 14:41:17 -0500 Subject: [PATCH 07/11] Fix clang build error (hopefully) --- src/lua_mobjlib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 79d839677..451ae6081 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -739,6 +739,7 @@ static int mobj_set(lua_State *L) break; } case mobj_alpha: + { INT32 alpha = (INT32)luaL_checkinteger(L, 3); if (alpha < 0) alpha = 0; @@ -746,6 +747,7 @@ static int mobj_set(lua_State *L) alpha = FRACUNIT; mo->alpha = alpha; break; + } case mobj_bnext: return NOSETPOS; case mobj_bprev: From d18a4cca1ebb6ada21cd691e7b9bffae016c8e52 Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Fri, 1 Mar 2024 13:09:25 -0500 Subject: [PATCH 08/11] Clean up comments --- src/p_mobj.c | 4 +--- src/r_things.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index df08cb9be..15da6e616 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10493,6 +10493,7 @@ void P_MobjThinker(mobj_t *mobj) case MT_GRENADEPICKUP: if (mobj->health == 0) // Fading tile { + // TODO: Maybe use mobj->alpha instead of messing with frame flags INT32 value = mobj->info->damage/10; value = mobj->fuse/value; value = 10-value; @@ -10503,9 +10504,6 @@ void P_MobjThinker(mobj_t *mobj) mobj->frame &= ~FF_TRANSMASK; mobj->frame |= value << FF_TRANSSHIFT; - - // TODO: Consider replacing the above with the commented-out line of code below - //mobj->alpha = FixedDiv(mobj->fuse, mobj->info->damage); } break; default: diff --git a/src/r_things.c b/src/r_things.c index a27a03e77..defdc7aaa 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3428,10 +3428,8 @@ boolean R_ThingVisible (mobj_t *thing) (thing->sprite == SPR_NULL) || // Don't draw null-sprites (thing->flags2 & MF2_DONTDRAW) || // Don't draw MF2_LINKDRAW objects (thing->drawonlyforplayer && thing->drawonlyforplayer != viewplayer) || // Don't draw other players' personal objects - //(thing->alpha == 0) || // Don't draw objects with an alpha of 0 ((rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || - (rendermode == render_opengl && thing->alpha == 0)) || // TODO: Maybe rethink this - //(rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || + (rendermode == render_opengl && thing->alpha == 0)) || (!P_MobjWasRemoved(r_viewmobj) && ( (r_viewmobj == thing) || // Don't draw first-person players or awayviewmobj objects (r_viewmobj->player && r_viewmobj->player->followmobj == thing) || // Don't draw first-person players' followmobj From a76544a3765d2bd9e69b420d60ff171bf76ac87b Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Fri, 1 Mar 2024 16:29:39 -0500 Subject: [PATCH 09/11] Make alpha use fixed_t and add alpha field to precipmobj_t --- src/lua_mobjlib.c | 4 ++-- src/p_mobj.h | 3 ++- src/p_saveg.c | 6 +++--- src/r_things.c | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 451ae6081..9a858c4b6 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -357,7 +357,7 @@ static int mobj_get(lua_State *L) lua_pushinteger(L, mo->blendmode); break; case mobj_alpha: - lua_pushinteger(L, mo->alpha); + lua_pushfixed(L, mo->alpha); break; case mobj_bnext: if (mo->blocknode && mo->blocknode->bnext) { @@ -740,7 +740,7 @@ static int mobj_set(lua_State *L) } case mobj_alpha: { - INT32 alpha = (INT32)luaL_checkinteger(L, 3); + fixed_t alpha = luaL_checkfixed(L, 3); if (alpha < 0) alpha = 0; else if (alpha > FRACUNIT) diff --git a/src/p_mobj.h b/src/p_mobj.h index 401071295..545f0847f 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -313,7 +313,7 @@ typedef struct mobj_s UINT32 renderflags; // render flags INT32 blendmode; // blend mode - UINT32 alpha; // alpha + fixed_t alpha; // alpha fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; @@ -457,6 +457,7 @@ typedef struct precipmobj_s UINT32 renderflags; // render flags INT32 blendmode; // blend mode + fixed_t alpha; // alpha fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; diff --git a/src/p_saveg.c b/src/p_saveg.c index 05cda779a..47f0b8297 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1745,7 +1745,7 @@ typedef enum MD2_DRAWONLYFORPLAYER = 1<<24, MD2_DONTDRAWFORVIEWMOBJ = 1<<25, MD2_TRANSLATION = 1<<26, - MD2_ALPHA = 1<<27 + MD2_ALPHA = 1<<27 } mobj_diff2_t; typedef enum @@ -2174,7 +2174,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) if (diff2 & MD2_TRANSLATION) WRITEUINT16(save_p, mobj->translation); if (diff2 & MD2_ALPHA) - WRITEUINT32(save_p, mobj->alpha); + WRITEFIXED(save_p, mobj->alpha); WRITEUINT32(save_p, mobj->mobjnum); } @@ -3242,7 +3242,7 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) if (diff2 & MD2_TRANSLATION) mobj->translation = READUINT16(save_p); if (diff2 & MD2_ALPHA) - mobj->alpha = READUINT32(save_p); + mobj->alpha = READFIXED(save_p); if (diff & MD_REDFLAG) { diff --git a/src/r_things.c b/src/r_things.c index defdc7aaa..843bf36ee 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1276,7 +1276,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, floordiff = abs((isflipped ? interp.height : 0) + interp.z - groundz); trans = floordiff / (100*FRACUNIT) + 3; - trans = R_GetTransmapFromAlpha(thing->alpha, trans); + trans = R_GetTransmapFromAlpha((UINT32)thing->alpha, trans); if (trans >= 9) return; scalemul = FixedMul(FRACUNIT - floordiff/640, scale); @@ -1963,9 +1963,9 @@ static void R_ProjectSprite(mobj_t *thing) trans = 0; if ((oldthing->flags2 & MF2_LINKDRAW) && oldthing->tracer) - trans = R_GetTransmapFromAlpha(oldthing->tracer->alpha, trans); + trans = R_GetTransmapFromAlpha((UINT32)oldthing->tracer->alpha, trans); else - trans = R_GetTransmapFromAlpha(oldthing->alpha, trans); + trans = R_GetTransmapFromAlpha((UINT32)oldthing->alpha, trans); // Check if this sprite needs to be rendered like a shadow shadowdraw = (!!(thing->renderflags & RF_SHADOWDRAW) && !(papersprite || splat)); @@ -3428,7 +3428,7 @@ boolean R_ThingVisible (mobj_t *thing) (thing->sprite == SPR_NULL) || // Don't draw null-sprites (thing->flags2 & MF2_DONTDRAW) || // Don't draw MF2_LINKDRAW objects (thing->drawonlyforplayer && thing->drawonlyforplayer != viewplayer) || // Don't draw other players' personal objects - ((rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || + ((rendermode == render_soft && R_GetTransmapFromAlpha((UINT32)thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || (rendermode == render_opengl && thing->alpha == 0)) || (!P_MobjWasRemoved(r_viewmobj) && ( (r_viewmobj == thing) || // Don't draw first-person players or awayviewmobj objects From 509adc345409f321f54f5302aed007f19ccede86 Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Sat, 2 Mar 2024 09:51:28 -0500 Subject: [PATCH 10/11] Change all remaining instances (hopefully) of UINT32 to fixed_t for alpha --- src/hardware/hw_main.c | 4 ++-- src/r_things.c | 10 +++++----- src/r_things.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 40f17301b..b58d58111 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3000,7 +3000,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) // co-ordinates memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts)); - UINT32 newalpha = spr->mobj->alpha; + fixed_t newalpha = spr->mobj->alpha; // if sprite has linkdraw, then dont write to z-buffer (by not using PF_Occlude) // this will result in sprites drawn afterwards to be drawn on top like intended when using linkdraw. @@ -3495,7 +3495,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) FBITFIELD blend = 0; FBITFIELD occlusion; boolean use_linkdraw_hack = false; - UINT32 newalpha = spr->mobj->alpha; + fixed_t newalpha = spr->mobj->alpha; // if sprite has linkdraw, then dont write to z-buffer (by not using PF_Occlude) // this will result in sprites drawn afterwards to be drawn on top like intended when using linkdraw. diff --git a/src/r_things.c b/src/r_things.c index 843bf36ee..cede03b80 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -763,7 +763,7 @@ UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 trans return NULL; } -transnum_t R_GetTransmapFromAlpha(UINT32 alpha, transnum_t transmap) +transnum_t R_GetTransmapFromAlpha(fixed_t alpha, transnum_t transmap) { INT32 value = 10 - transmap; value = 10 - (FixedCeil(alpha * value)>>FRACBITS); @@ -1276,7 +1276,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, floordiff = abs((isflipped ? interp.height : 0) + interp.z - groundz); trans = floordiff / (100*FRACUNIT) + 3; - trans = R_GetTransmapFromAlpha((UINT32)thing->alpha, trans); + trans = R_GetTransmapFromAlpha(thing->alpha, trans); if (trans >= 9) return; scalemul = FixedMul(FRACUNIT - floordiff/640, scale); @@ -1963,9 +1963,9 @@ static void R_ProjectSprite(mobj_t *thing) trans = 0; if ((oldthing->flags2 & MF2_LINKDRAW) && oldthing->tracer) - trans = R_GetTransmapFromAlpha((UINT32)oldthing->tracer->alpha, trans); + trans = R_GetTransmapFromAlpha(oldthing->tracer->alpha, trans); else - trans = R_GetTransmapFromAlpha((UINT32)oldthing->alpha, trans); + trans = R_GetTransmapFromAlpha(oldthing->alpha, trans); // Check if this sprite needs to be rendered like a shadow shadowdraw = (!!(thing->renderflags & RF_SHADOWDRAW) && !(papersprite || splat)); @@ -3428,7 +3428,7 @@ boolean R_ThingVisible (mobj_t *thing) (thing->sprite == SPR_NULL) || // Don't draw null-sprites (thing->flags2 & MF2_DONTDRAW) || // Don't draw MF2_LINKDRAW objects (thing->drawonlyforplayer && thing->drawonlyforplayer != viewplayer) || // Don't draw other players' personal objects - ((rendermode == render_soft && R_GetTransmapFromAlpha((UINT32)thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || + ((rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || (rendermode == render_opengl && thing->alpha == 0)) || (!P_MobjWasRemoved(r_viewmobj) && ( (r_viewmobj == thing) || // Don't draw first-person players or awayviewmobj objects diff --git a/src/r_things.h b/src/r_things.h index 086dd8b55..268e5562b 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -90,7 +90,7 @@ boolean R_ThingIsFullDark (mobj_t *thing); boolean R_ThingIsFlashing (mobj_t *thing); UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 translation); -transnum_t R_GetTransmapFromAlpha(UINT32 alpha, transnum_t transmap); +transnum_t R_GetTransmapFromAlpha(fixed_t alpha, transnum_t transmap); void R_ThingOffsetOverlay (mobj_t *thing, fixed_t *outx, fixed_t *outy); From a19f843a3ecae75c2963918675c66c7dcae89d73 Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Sun, 19 May 2024 22:21:09 -0400 Subject: [PATCH 11/11] Implement Lactozilla's suggestions and add 3D model support --- src/hardware/hw_md2.c | 7 +++++++ src/p_saveg.c | 2 +- src/r_things.c | 17 +++++++---------- src/r_things.h | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 0bb8de851..d16700909 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1285,6 +1285,11 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // Apparently people don't like jump frames like that, so back it goes //if (tics > durs) //durs = tics; + + // Make linkdraw objects use their tracer's alpha value + fixed_t newalpha = spr->mobj->alpha; + if ((spr->mobj->flags2 & MF2_LINKDRAW) && spr->mobj->tracer) + newalpha = spr->mobj->tracer->alpha; INT32 blendmode; if (spr->mobj->frame & FF_BLENDMASK) @@ -1299,6 +1304,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) Surf.PolyColor.s.alpha = (spr->mobj->flags2 & MF2_SHADOW) ? 0x40 : 0xff; Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } + + Surf.PolyColor.s.alpha = FixedMul(newalpha, Surf.PolyColor.s.alpha); // don't forget to enable the depth test because we can't do this // like before: model polygons are not sorted diff --git a/src/p_saveg.c b/src/p_saveg.c index 1aed73784..219410bb6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1990,7 +1990,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_DONTDRAWFORVIEWMOBJ; if (mobj->dispoffset != mobj->info->dispoffset) diff2 |= MD2_DISPOFFSET; - if (mobj->alpha < FRACUNIT) + if (mobj->alpha != FRACUNIT) diff2 |= MD2_ALPHA; if (diff2 != 0) diff --git a/src/r_things.c b/src/r_things.c index 41e1c144e..afa861832 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -992,12 +992,10 @@ UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 trans return NULL; } -transnum_t R_GetTransmapFromAlpha(fixed_t alpha, transnum_t transmap) +// Based off of R_GetLinedefTransTable +transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap) { - INT32 value = 10 - transmap; - value = 10 - (FixedCeil(alpha * value)>>FRACBITS); - - return value; + return (20*(FRACUNIT - ((alpha * (10 - transmap))/10) - 1) + FRACUNIT) >> (FRACBITS+1); } // @@ -1505,7 +1503,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, floordiff = abs((isflipped ? interp.height : 0) + interp.z - groundz); trans = floordiff / (100*FRACUNIT) + 3; - trans = R_GetTransmapFromAlpha(thing->alpha, trans); + trans = R_GetThingTransTable(thing->alpha, trans); if (trans >= 9) return; scalemul = FixedMul(FRACUNIT - floordiff/640, scale); @@ -2194,9 +2192,9 @@ static void R_ProjectSprite(mobj_t *thing) trans = 0; if ((oldthing->flags2 & MF2_LINKDRAW) && oldthing->tracer) - trans = R_GetTransmapFromAlpha(oldthing->tracer->alpha, trans); + trans = R_GetThingTransTable(oldthing->tracer->alpha, trans); else - trans = R_GetTransmapFromAlpha(oldthing->alpha, trans); + trans = R_GetThingTransTable(oldthing->alpha, trans); // Check if this sprite needs to be rendered like a shadow shadowdraw = (!!(thing->renderflags & RF_SHADOWDRAW) && !(papersprite || splat)); @@ -3658,8 +3656,7 @@ boolean R_ThingVisible (mobj_t *thing) (thing->sprite == SPR_NULL) || // Don't draw null-sprites (thing->flags2 & MF2_DONTDRAW) || // Don't draw MF2_LINKDRAW objects (thing->drawonlyforplayer && thing->drawonlyforplayer != viewplayer) || // Don't draw other players' personal objects - ((rendermode == render_soft && R_GetTransmapFromAlpha(thing->alpha, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT) >= 10) || - (rendermode == render_opengl && thing->alpha == 0)) || + (!R_BlendLevelVisible(thing->blendmode, R_GetThingTransTable(thing->alpha, 0))) || (!P_MobjWasRemoved(r_viewmobj) && ( (r_viewmobj == thing) || // Don't draw first-person players or awayviewmobj objects (r_viewmobj->player && r_viewmobj->player->followmobj == thing) || // Don't draw first-person players' followmobj diff --git a/src/r_things.h b/src/r_things.h index 530898917..55ab71ec3 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -93,7 +93,7 @@ boolean R_ThingIsFullDark (mobj_t *thing); boolean R_ThingIsFlashing (mobj_t *thing); UINT8 *R_GetTranslationForThing(mobj_t *mobj, skincolornum_t color, UINT16 translation); -transnum_t R_GetTransmapFromAlpha(fixed_t alpha, transnum_t transmap); +transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap); void R_ThingOffsetOverlay (mobj_t *thing, fixed_t *outx, fixed_t *outy);