Merge branch 'master' of https://github.com/coelckers/gzdoom into lightmaps2

This commit is contained in:
nashmuhandes 2022-01-20 14:19:45 +08:00
commit f79bbed130
15 changed files with 207 additions and 207 deletions

View file

@ -937,7 +937,6 @@ set (PCH_SOURCES
rendering/hwrenderer/hw_vertexbuilder.cpp
rendering/hwrenderer/doom_aabbtree.cpp
rendering/hwrenderer/hw_models.cpp
rendering/hwrenderer/hw_postprocessshader.cpp
rendering/hwrenderer/hw_precache.cpp
rendering/hwrenderer/scene/hw_lighting.cpp
rendering/hwrenderer/scene/hw_drawlistadd.cpp
@ -1152,6 +1151,7 @@ set (PCH_SOURCES
common/rendering/hwrenderer/data/hw_aabbtree.cpp
common/rendering/hwrenderer/data/hw_shadowmap.cpp
common/rendering/hwrenderer/data/hw_shaderpatcher.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp
common/rendering/gl_load/gl_interface.cpp

View file

@ -963,6 +963,7 @@ xx(A_FirePlasma)
xx(A_FireBFG)
xx(A_FireOldBFG)
xx(A_FireRailgun)
xx(A_ConsumeAmmo)
// color channels
xx(a)

View file

@ -55,7 +55,6 @@
// ---------------------------------------------------------------------------
CVAR (Bool, i_soundinbackground, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
EXTERN_CVAR(Int, vid_defwidth )
EXTERN_CVAR(Int, vid_defheight)
EXTERN_CVAR(Bool, vid_vsync )
@ -293,7 +292,7 @@ extern bool AppActive;
{
ZD_UNUSED(aNotification);
S_SetSoundPaused(i_soundinbackground);
S_SetSoundPaused(0);
AppActive = false;
}

View file

@ -95,8 +95,6 @@ CUSTOM_CVAR(Bool, gl_es, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCA
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
CVAR(Bool, i_soundinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR (Int, vid_adapter, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(String, vid_sdl_render_driver, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
@ -721,7 +719,7 @@ void ProcessSDLWindowEvent(const SDL_WindowEvent &event)
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
S_SetSoundPaused(i_soundinbackground);
S_SetSoundPaused(0);
AppActive = false;
break;

View file

@ -140,7 +140,6 @@ int BlockMouseMove;
static bool EventHandlerResultForNativeMouse;
CVAR (Bool, i_soundinbackground, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
extern int chatmodeon;
@ -508,7 +507,7 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
SetPriorityClass (GetCurrentProcess (), IDLE_PRIORITY_CLASS);
}
S_SetSoundPaused ((!!i_soundinbackground) || wParam);
S_SetSoundPaused (wParam);
break;
case WM_WTSSESSION_CHANGE:

View file

@ -585,7 +585,7 @@ public:
void SetDepthBias(float a, float b)
{
mBias.mChanged = mBias.mFactor != a || mBias.mUnits != b;
mBias.mChanged |= mBias.mFactor != a || mBias.mUnits != b;
mBias.mFactor = a;
mBias.mUnits = b;
}
@ -597,7 +597,7 @@ public:
void ClearDepthBias()
{
mBias.mChanged = mBias.mFactor != 0 || mBias.mUnits != 0;
mBias.mChanged |= mBias.mFactor != 0 || mBias.mUnits != 0;
mBias.mFactor = 0;
mBias.mUnits = 0;
}

View file

@ -0,0 +1,139 @@
/*
** Postprocessing framework
** Copyright (c) 2016-2020 Magnus Norddahl
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
*/
#include "vm.h"
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
static void ShaderSetEnabled(const FString &shaderName, bool value)
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
shader.Enabled = value;
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_PPShader, SetEnabled, ShaderSetEnabled)
{
PARAM_PROLOGUE;
PARAM_STRING(shaderName);
PARAM_BOOL(value);
ShaderSetEnabled(shaderName, value);
return 0;
}
static void ShaderSetUniform1f(const FString &shaderName, const FString &uniformName, double value)
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = value;
vec4[1] = 0.0;
vec4[2] = 0.0;
vec4[3] = 1.0;
}
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_PPShader, SetUniform1f, ShaderSetUniform1f)
{
PARAM_PROLOGUE;
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_FLOAT(value);
ShaderSetUniform1f(shaderName, uniformName, value);
return 0;
}
DEFINE_ACTION_FUNCTION(_PPShader, SetUniform2f)
{
PARAM_PROLOGUE;
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = x;
vec4[1] = y;
vec4[2] = 0.0;
vec4[3] = 1.0;
}
}
return 0;
}
DEFINE_ACTION_FUNCTION(_PPShader, SetUniform3f)
{
PARAM_PROLOGUE;
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
PARAM_FLOAT(z);
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = x;
vec4[1] = y;
vec4[2] = z;
vec4[3] = 1.0;
}
}
return 0;
}
DEFINE_ACTION_FUNCTION(_PPShader, SetUniform1i)
{
PARAM_PROLOGUE;
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_INT(value);
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = (double)value;
vec4[1] = 0.0;
vec4[2] = 0.0;
vec4[3] = 1.0;
}
}
return 0;
}

View file

@ -184,7 +184,7 @@ struct MBFParamState
int GetSoundArg(int i, int def = 0)
{
int num = argsused & (1 << i) ? (int)args[i] : def;
if (num > 0 && num < int(SoundMap.Size())) return SoundMap[num];
if (num > 0 && num <= int(SoundMap.Size())) return SoundMap[num-1];
return 0;
}
@ -237,6 +237,7 @@ static AmmoPerAttack AmmoPerAttacks[] = {
{ NAME_A_FireBFG, -1}, // uses deh.BFGCells
{ NAME_A_FireOldBFG, 1},
{ NAME_A_FireRailgun, 1},
{ NAME_A_ConsumeAmmo, 1}, // MBF21
{ NAME_None, 0}
};
@ -886,12 +887,12 @@ static void CreateWeaponBulletAttackFunc(FunctionCallEmitter &emitters, int valu
static void CreateWeaponMeleeAttackFunc(FunctionCallEmitter &emitters, int value1, int value2, MBFParamState* state)
{
state->ValidateArgCount(5, "A_WeaponBulletAttack");
state->ValidateArgCount(5, "A_WeaponMeleeAttack");
emitters.AddParameterIntConst(state->GetIntArg(0, 2));
emitters.AddParameterIntConst(state->GetIntArg(1, 10));
emitters.AddParameterFloatConst(state->GetFloatArg(2, 1));
emitters.AddParameterIntConst(state->GetIntArg(3));
emitters.AddParameterIntConst(state->GetIntArg(4));
emitters.AddParameterIntConst(state->GetSoundArg(3));
emitters.AddParameterFloatConst(state->GetFloatArg(4));
}
static void CreateWeaponSoundFunc(FunctionCallEmitter &emitters, int value1, int value2, MBFParamState* state)

View file

@ -1,169 +0,0 @@
/*
** Postprocessing framework
** Copyright (c) 2016-2020 Magnus Norddahl
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
*/
#include "vm.h"
#include "d_player.h"
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
#include "g_levellocals.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
static bool IsConsolePlayer(player_t *player)
{
AActor *activator = player ? player->mo : nullptr;
if (activator == nullptr || activator->player == nullptr)
return false;
return activator->player == activator->Level->GetConsolePlayer();
}
static void ShaderSetEnabled(player_t *player, const FString &shaderName, bool value)
{
if (IsConsolePlayer(player))
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
shader.Enabled = value;
}
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_Shader, SetEnabled, ShaderSetEnabled)
{
PARAM_PROLOGUE;
PARAM_POINTER(player, player_t);
PARAM_STRING(shaderName);
PARAM_BOOL(value);
ShaderSetEnabled(player, shaderName, value);
return 0;
}
static void ShaderSetUniform1f(player_t *player, const FString &shaderName, const FString &uniformName, double value)
{
if (IsConsolePlayer(player))
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = value;
vec4[1] = 0.0;
vec4[2] = 0.0;
vec4[3] = 1.0;
}
}
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_Shader, SetUniform1f, ShaderSetUniform1f)
{
PARAM_PROLOGUE;
PARAM_POINTER(player, player_t);
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_FLOAT(value);
ShaderSetUniform1f(player, shaderName, uniformName, value);
return 0;
}
DEFINE_ACTION_FUNCTION(_Shader, SetUniform2f)
{
PARAM_PROLOGUE;
PARAM_POINTER(player, player_t);
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
if (IsConsolePlayer(player))
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = x;
vec4[1] = y;
vec4[2] = 0.0;
vec4[3] = 1.0;
}
}
}
return 0;
}
DEFINE_ACTION_FUNCTION(_Shader, SetUniform3f)
{
PARAM_PROLOGUE;
PARAM_POINTER(player, player_t);
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
PARAM_FLOAT(z);
if (IsConsolePlayer(player))
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = x;
vec4[1] = y;
vec4[2] = z;
vec4[3] = 1.0;
}
}
}
return 0;
}
DEFINE_ACTION_FUNCTION(_Shader, SetUniform1i)
{
PARAM_PROLOGUE;
PARAM_POINTER(player, player_t);
PARAM_STRING(shaderName);
PARAM_STRING(uniformName);
PARAM_INT(value);
if (IsConsolePlayer(player))
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)
{
PostProcessShader &shader = PostProcessShaders[i];
if (shader.Name == shaderName)
{
double *vec4 = shader.Uniforms[uniformName].Values;
vec4[0] = (double)value;
vec4[1] = 0.0;
vec4[2] = 0.0;
vec4[3] = 1.0;
}
}
}
return 0;
}

View file

@ -71,6 +71,8 @@
FBoolCVar noisedebug("noise", false, 0); // [RH] Print sound debugging info?
CVAR (Bool, i_soundinbackground, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Bool, i_pauseinbackground, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
static FString LastLocalSndInfo;
@ -930,7 +932,16 @@ void S_SerializeSounds(FSerializer &arc)
void S_SetSoundPaused(int state)
{
if (state)
if (!netgame && (i_pauseinbackground)
#ifdef _DEBUG
&& !demoplayback
#endif
)
{
pauseext = !state;
}
if ((state || i_soundinbackground) && !pauseext)
{
if (paused == 0)
{
@ -954,14 +965,6 @@ void S_SetSoundPaused(int state)
}
}
}
if (!netgame
#ifdef _DEBUG
&& !demoplayback
#endif
)
{
pauseext = !state;
}
}

View file

@ -6,6 +6,7 @@ version "4.6"
#include "zscript/engine/dictionary.zs"
#include "zscript/engine/inputevents.zs"
#include "zscript/engine/service.zs"
#include "zscript/engine/ppshader.zs"
#include "zscript/engine/ui/menu/colorpickermenu.zs"
#include "zscript/engine/ui/menu/joystickmenu.zs"

View file

@ -994,7 +994,7 @@ class Weapon : StateProvider
//
//===========================================================================
virtual bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1)
virtual bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1, bool forceammouse = false)
{
if (!(sv_infiniteammo || (Owner.FindInventory ('PowerInfiniteAmmo', true) != null)))
{
@ -1006,7 +1006,7 @@ class Weapon : StateProvider
{
if (Ammo1 != null)
{
if (ammouse >= 0 && bDehAmmo)
if (ammouse >= 0 && (bDehAmmo || forceammouse))
{
Ammo1.Amount -= ammouse;
}

View file

@ -198,7 +198,9 @@ extend class Actor
//
void A_FindTracer(double fov, int dist)
{
if (!tracer) tracer = RoughMonsterSearch(dist, fov: fov);
// note: mbf21 fov is the angle of the entire cone, while
// zdoom fov is defined as 1/2 of the cone, so halve it.
if (!tracer) tracer = RoughMonsterSearch(dist, fov: fov/2);
}
//
@ -316,11 +318,9 @@ extend class Weapon
FTranslatedLineTarget t;
angle += self.angle;
double x = Spawnofs_xy * cos(angle);
double y = Spawnofs_xy * sin(angle);
let pos = self.Vec3Offset(x, y, Spawnofs_z);
Vector2 ofs = AngleToVector(self.Angle - 90, spawnofs_xy);
let mo = SpawnPlayerMissile(type, angle, pos.X, pos.Y, pos.Z, pLineTarget: t);
let mo = SpawnPlayerMissile(type, angle, ofs.x, ofs.y, Spawnofs_z, pLineTarget: t);
if (!mo) return;
Pitch += mo.PitchFromVel();
@ -432,7 +432,7 @@ extend class Weapon
if (!weap) return;
if (consume == 0) consume = -1;
weap.DepleteAmmo(weap.bAltFire, false, consume);
weap.DepleteAmmo(weap.bAltFire, false, consume, true);
}
//
@ -505,9 +505,9 @@ extend class Weapon
// needed to call A_SeekerMissile with proper defaults.
deprecated("2.3", "for Dehacked use only")
void MBF21_SeekTracer(int threshold, int turnmax)
void MBF21_SeekTracer(double threshold, double turnmax)
{
A_SeekerMissile(threshold, turnmax);
A_SeekerMissile(threshold, turnmax, flags: SMF_PRECISE); // args get truncated to ints here, but it's close enough
}
}

View file

@ -701,11 +701,31 @@ class Lighting : SectorEffect native
struct Shader native
{
native clearscope static void SetEnabled(PlayerInfo player, string shaderName, bool enable);
native clearscope static void SetUniform1f(PlayerInfo player, string shaderName, string uniformName, float value);
native clearscope static void SetUniform2f(PlayerInfo player, string shaderName, string uniformName, vector2 value);
native clearscope static void SetUniform3f(PlayerInfo player, string shaderName, string uniformName, vector3 value);
native clearscope static void SetUniform1i(PlayerInfo player, string shaderName, string uniformName, int value);
// This interface was deprecated for the pointless player dependency
private static bool IsConsolePlayer(PlayerInfo player)
{
return player && !player.mo && player == players[consoleplayer];
}
deprecated("4.8", "Use PPShader.SetEnabled() instead") clearscope static void SetEnabled(PlayerInfo player, string shaderName, bool enable)
{
if (IsConsolePlayer(player)) PPShader.SetEnabled(shaderName, enable);
}
deprecated("4.8", "Use PPShader.SetUniform1f() instead") clearscope static void SetUniform1f(PlayerInfo player, string shaderName, string uniformName, float value)
{
if (IsConsolePlayer(player)) PPShader.SetUniform1f(shaderName, uniformName, value);
}
deprecated("4.8", "Use PPShader.SetUniform2f() instead") clearscope static void SetUniform2f(PlayerInfo player, string shaderName, string uniformName, vector2 value)
{
if (IsConsolePlayer(player)) PPShader.SetUniform2f(shaderName, uniformName, value);
}
deprecated("4.8", "Use PPShader.SetUniform3f() instead") clearscope static void SetUniform3f(PlayerInfo player, string shaderName, string uniformName, vector3 value)
{
if (IsConsolePlayer(player)) PPShader.SetUniform3f(shaderName, uniformName, value);
}
deprecated("4.8", "Use PPShader.SetUniform1i() instead") clearscope static void SetUniform1i(PlayerInfo player, string shaderName, string uniformName, int value)
{
if (IsConsolePlayer(player)) PPShader.SetUniform1i(shaderName, uniformName, value);
}
}
struct FRailParams

View file

@ -0,0 +1,8 @@
struct PPShader native
{
native clearscope static void SetEnabled(string shaderName, bool enable);
native clearscope static void SetUniform1f(string shaderName, string uniformName, float value);
native clearscope static void SetUniform2f(string shaderName, string uniformName, vector2 value);
native clearscope static void SetUniform3f(string shaderName, string uniformName, vector3 value);
native clearscope static void SetUniform1i(string shaderName, string uniformName, int value);
}