From b338458a1dbffd95565c5b3bf609674e513d81c8 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 24 May 2024 09:48:42 +0100 Subject: [PATCH 01/25] possible fix for torsion lineno --- Engine/source/console/torquescript/CMDscan.cpp | 1 + Engine/source/console/torquescript/CMDscan.l | 1 + 2 files changed, 2 insertions(+) diff --git a/Engine/source/console/torquescript/CMDscan.cpp b/Engine/source/console/torquescript/CMDscan.cpp index ccf1aacb5..5ca6ca7d9 100644 --- a/Engine/source/console/torquescript/CMDscan.cpp +++ b/Engine/source/console/torquescript/CMDscan.cpp @@ -2741,6 +2741,7 @@ void CMDSetScanBuffer(const char *sb, const char *fn) scanBuffer = sb; fileName = fn; scanIndex = 0; + yylineno = 1; } int CMDgetc() diff --git a/Engine/source/console/torquescript/CMDscan.l b/Engine/source/console/torquescript/CMDscan.l index 57e8f0b3f..d6a03186a 100644 --- a/Engine/source/console/torquescript/CMDscan.l +++ b/Engine/source/console/torquescript/CMDscan.l @@ -291,6 +291,7 @@ void CMDSetScanBuffer(const char *sb, const char *fn) scanBuffer = sb; fileName = fn; scanIndex = 0; + yylineno = 1; } int CMDgetc() From 482eb28dedf44296c3a47f2312278cb5939bc1f1 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 24 May 2024 14:00:21 +0100 Subject: [PATCH 02/25] Update sfxSndStream.cpp add different file type modes and reset stream after reading (torque still reads the full thing) --- Engine/source/sfx/media/sfxSndStream.cpp | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index 3c1d21b17..aad9fa897 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -105,14 +105,45 @@ void SFXSndStream::reset() U32 SFXSndStream::read(U8* buffer, U32 length) { + if (!sndFile) + { + Con::errorf("SFXSndStream - read: Called on uninitialized stream."); + return 0; + } + + U32 framesToRead = length / mFormat.getBytesPerSample(); U32 framesRead = 0; - framesRead = sf_readf_short(sndFile, (short*)buffer, sfinfo.frames); + switch (sfinfo.format & SF_FORMAT_SUBMASK) + { + case SF_FORMAT_PCM_S8: + case SF_FORMAT_PCM_U8: + framesRead = sf_readf_int(sndFile, reinterpret_cast(buffer), framesToRead); + break; + case SF_FORMAT_PCM_16: + case SF_FORMAT_VORBIS: + framesRead = sf_readf_short(sndFile, reinterpret_cast(buffer), framesToRead); + break; + case SF_FORMAT_PCM_24: + framesRead = sf_readf_int(sndFile, reinterpret_cast(buffer), framesToRead); // 24-bit usually stored in 32-bit containers + break; + case SF_FORMAT_PCM_32: + case SF_FORMAT_FLOAT: + framesRead = sf_readf_float(sndFile, reinterpret_cast(buffer), framesToRead); + break; + default: + Con::errorf("SFXSndStream - read: Unsupported format."); + return 0; + } + if (framesRead != sfinfo.frames) { Con::errorf("SFXSndStream - read: %s", sf_strerror(sndFile)); } + // reset stream + setPosition(0); + return framesRead * mFormat.getBytesPerSample(); } From bf34d3daa8a2dc87fe732713fe6c61fad178eff6 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 24 May 2024 14:12:01 +0100 Subject: [PATCH 03/25] Update sfxSndStream.cpp fix distortion issue on some sounds, if vorbis requires a scale set for float conversion --- Engine/source/sfx/media/sfxSndStream.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index aad9fa897..2ccad264f 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -57,8 +57,11 @@ bool SFXSndStream::_readHeader() bitsPerSample = 8; break; case SF_FORMAT_PCM_16: + bitsPerSample = 16; + break; case SF_FORMAT_VORBIS: bitsPerSample = 16; + sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); break; case SF_FORMAT_PCM_24: bitsPerSample = 24; From ebdc40838523de2bedeab644d613420f3ac44a29 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 24 May 2024 15:11:18 +0100 Subject: [PATCH 04/25] Update sfxSndStream.cpp streaming file fixes, also only wrap back around when we have read the whole file. --- Engine/source/sfx/media/sfxSndStream.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index 2ccad264f..a2a508804 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -139,13 +139,22 @@ U32 SFXSndStream::read(U8* buffer, U32 length) return 0; } - if (framesRead != sfinfo.frames) + if (framesRead != framesToRead) { Con::errorf("SFXSndStream - read: %s", sf_strerror(sndFile)); } - // reset stream - setPosition(0); + // make sure we are more than 0 position. + if (getPosition() > 0) + { + // (convert to frames) == number of frames available? + if ((getPosition() / mFormat.getBytesPerSample()) == sfinfo.frames) + { + // reset stream + setPosition(0); + } + } + return framesRead * mFormat.getBytesPerSample(); } From c28cedc2d898f2c2fa00d02bc715f535878879ea Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 24 May 2024 16:19:10 +0100 Subject: [PATCH 05/25] 32 bit float test 32 bit floating point sounds --- Engine/source/sfx/media/sfxSndStream.cpp | 7 ++----- Engine/source/sfx/openal/sfxALBuffer.h | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index a2a508804..829d73f37 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -59,15 +59,12 @@ bool SFXSndStream::_readHeader() case SF_FORMAT_PCM_16: bitsPerSample = 16; break; - case SF_FORMAT_VORBIS: - bitsPerSample = 16; - sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); - break; case SF_FORMAT_PCM_24: bitsPerSample = 24; break; case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: + case SF_FORMAT_VORBIS: bitsPerSample = 32; break; default: @@ -124,7 +121,6 @@ U32 SFXSndStream::read(U8* buffer, U32 length) framesRead = sf_readf_int(sndFile, reinterpret_cast(buffer), framesToRead); break; case SF_FORMAT_PCM_16: - case SF_FORMAT_VORBIS: framesRead = sf_readf_short(sndFile, reinterpret_cast(buffer), framesToRead); break; case SF_FORMAT_PCM_24: @@ -132,6 +128,7 @@ U32 SFXSndStream::read(U8* buffer, U32 length) break; case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: + case SF_FORMAT_VORBIS: framesRead = sf_readf_float(sndFile, reinterpret_cast(buffer), framesToRead); break; default: diff --git a/Engine/source/sfx/openal/sfxALBuffer.h b/Engine/source/sfx/openal/sfxALBuffer.h index 26864a3d0..7589485bd 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.h +++ b/Engine/source/sfx/openal/sfxALBuffer.h @@ -84,14 +84,24 @@ class SFXALBuffer : public SFXBuffer return AL_FORMAT_STEREO8; else if( bps == 32 ) return AL_FORMAT_STEREO16; + else if (bps == 64) + { + if (alIsExtensionPresent("AL_EXT_FLOAT32")) + return AL_FORMAT_STEREO_FLOAT32; + } } else if( format.getChannels() == 1 ) { const U32 bps = format.getBitsPerSample(); - if( bps == 8 ) + if (bps == 8) return AL_FORMAT_MONO8; - else if( bps == 16 ) + else if (bps == 16) return AL_FORMAT_MONO16; + else if (bps == 32) + { + if(alIsExtensionPresent("AL_EXT_FLOAT32")) + return AL_FORMAT_MONO_FLOAT32; + } } return 0; } @@ -116,4 +126,4 @@ class SFXALBuffer : public SFXBuffer virtual ~SFXALBuffer(); }; -#endif // _SFXALBUFFER_H_ \ No newline at end of file +#endif // _SFXALBUFFER_H_ From de454dc793d0bb760586296cbd9e127cc6375e04 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 24 May 2024 16:25:26 +0100 Subject: [PATCH 06/25] Update sfxSndStream.cpp revert vorbis back to 16bit add normalisation option. --- Engine/source/sfx/media/sfxSndStream.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index 829d73f37..1eeffab31 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -59,12 +59,16 @@ bool SFXSndStream::_readHeader() case SF_FORMAT_PCM_16: bitsPerSample = 16; break; + case SF_FORMAT_VORBIS: + bitsPerSample = 16; + sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); + sf_command(sndFile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE); + break; case SF_FORMAT_PCM_24: bitsPerSample = 24; break; case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: - case SF_FORMAT_VORBIS: bitsPerSample = 32; break; default: @@ -121,6 +125,7 @@ U32 SFXSndStream::read(U8* buffer, U32 length) framesRead = sf_readf_int(sndFile, reinterpret_cast(buffer), framesToRead); break; case SF_FORMAT_PCM_16: + case SF_FORMAT_VORBIS: framesRead = sf_readf_short(sndFile, reinterpret_cast(buffer), framesToRead); break; case SF_FORMAT_PCM_24: @@ -128,7 +133,6 @@ U32 SFXSndStream::read(U8* buffer, U32 length) break; case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: - case SF_FORMAT_VORBIS: framesRead = sf_readf_float(sndFile, reinterpret_cast(buffer), framesToRead); break; default: From aa9cb63789037916719c9ba6ad0efa9d4d042089 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 24 May 2024 17:18:35 +0100 Subject: [PATCH 07/25] Update sfxSndStream.cpp --- Engine/source/sfx/media/sfxSndStream.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index 1eeffab31..26d774c44 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -62,7 +62,6 @@ bool SFXSndStream::_readHeader() case SF_FORMAT_VORBIS: bitsPerSample = 16; sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); - sf_command(sndFile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE); break; case SF_FORMAT_PCM_24: bitsPerSample = 24; @@ -148,8 +147,8 @@ U32 SFXSndStream::read(U8* buffer, U32 length) // make sure we are more than 0 position. if (getPosition() > 0) { - // (convert to frames) == number of frames available? - if ((getPosition() / mFormat.getBytesPerSample()) == sfinfo.frames) + // (convert to frames) - number of frames available < MAX_BUFFER? + if (((getPosition() / mFormat.getBytesPerSample()) - sfinfo.frames) < MAX_BUFFER) { // reset stream setPosition(0); From 0ae0d633e99751f7a0db070fa4dc2899be475399 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sat, 25 May 2024 08:16:43 +0100 Subject: [PATCH 08/25] Update sfxSndStream.cpp --- Engine/source/sfx/media/sfxSndStream.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index 26d774c44..955f118d8 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -64,8 +64,6 @@ bool SFXSndStream::_readHeader() sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); break; case SF_FORMAT_PCM_24: - bitsPerSample = 24; - break; case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: bitsPerSample = 32; @@ -124,12 +122,12 @@ U32 SFXSndStream::read(U8* buffer, U32 length) framesRead = sf_readf_int(sndFile, reinterpret_cast(buffer), framesToRead); break; case SF_FORMAT_PCM_16: + framesRead = sf_readf_short(sndFile, reinterpret_cast(buffer), framesToRead); + break; case SF_FORMAT_VORBIS: framesRead = sf_readf_short(sndFile, reinterpret_cast(buffer), framesToRead); break; case SF_FORMAT_PCM_24: - framesRead = sf_readf_int(sndFile, reinterpret_cast(buffer), framesToRead); // 24-bit usually stored in 32-bit containers - break; case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: framesRead = sf_readf_float(sndFile, reinterpret_cast(buffer), framesToRead); From e3d977b8e710852eea8368593756629ba71364c3 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sat, 25 May 2024 09:10:47 +0100 Subject: [PATCH 09/25] Update sfxALBuffer.h mac dont like --- Engine/source/sfx/openal/sfxALBuffer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Engine/source/sfx/openal/sfxALBuffer.h b/Engine/source/sfx/openal/sfxALBuffer.h index 7589485bd..d3260d704 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.h +++ b/Engine/source/sfx/openal/sfxALBuffer.h @@ -84,11 +84,12 @@ class SFXALBuffer : public SFXBuffer return AL_FORMAT_STEREO8; else if( bps == 32 ) return AL_FORMAT_STEREO16; + /* MAC doesnt like 32bit openal (doesnt use the ext) else if (bps == 64) { if (alIsExtensionPresent("AL_EXT_FLOAT32")) return AL_FORMAT_STEREO_FLOAT32; - } + }*/ } else if( format.getChannels() == 1 ) { @@ -97,11 +98,12 @@ class SFXALBuffer : public SFXBuffer return AL_FORMAT_MONO8; else if (bps == 16) return AL_FORMAT_MONO16; + /* else if (bps == 32) { if(alIsExtensionPresent("AL_EXT_FLOAT32")) return AL_FORMAT_MONO_FLOAT32; - } + }*/ } return 0; } From 0d1dc234fac406cce67e872dfa8391db2c64fc4e Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sat, 25 May 2024 10:04:51 +0100 Subject: [PATCH 10/25] Update sfxSndStream.cpp we always want shorts --- Engine/source/sfx/media/sfxSndStream.cpp | 26 ++++++++---------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index 955f118d8..96ad07711 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -60,13 +60,11 @@ bool SFXSndStream::_readHeader() bitsPerSample = 16; break; case SF_FORMAT_VORBIS: - bitsPerSample = 16; - sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); - break; case SF_FORMAT_PCM_24: case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: - bitsPerSample = 32; + bitsPerSample = 16; + sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE); break; default: // missed, set it to 16 anyway. @@ -119,18 +117,14 @@ U32 SFXSndStream::read(U8* buffer, U32 length) { case SF_FORMAT_PCM_S8: case SF_FORMAT_PCM_U8: - framesRead = sf_readf_int(sndFile, reinterpret_cast(buffer), framesToRead); + framesRead = sf_readf_int(sndFile, (int*)buffer, framesToRead); break; case SF_FORMAT_PCM_16: - framesRead = sf_readf_short(sndFile, reinterpret_cast(buffer), framesToRead); - break; case SF_FORMAT_VORBIS: - framesRead = sf_readf_short(sndFile, reinterpret_cast(buffer), framesToRead); - break; case SF_FORMAT_PCM_24: case SF_FORMAT_PCM_32: case SF_FORMAT_FLOAT: - framesRead = sf_readf_float(sndFile, reinterpret_cast(buffer), framesToRead); + framesRead = sf_readf_short(sndFile, (short*)buffer, framesToRead); break; default: Con::errorf("SFXSndStream - read: Unsupported format."); @@ -142,15 +136,11 @@ U32 SFXSndStream::read(U8* buffer, U32 length) Con::errorf("SFXSndStream - read: %s", sf_strerror(sndFile)); } - // make sure we are more than 0 position. - if (getPosition() > 0) + // (convert to frames) - number of frames available < MAX_BUFFER? reset + if (((getPosition() / mFormat.getBytesPerSample()) - sfinfo.frames) < MAX_BUFFER) { - // (convert to frames) - number of frames available < MAX_BUFFER? - if (((getPosition() / mFormat.getBytesPerSample()) - sfinfo.frames) < MAX_BUFFER) - { - // reset stream - setPosition(0); - } + // reset stream + setPosition(0); } From 79dfd14bea11a22888b03fa30b7978e219846dc3 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sat, 25 May 2024 10:20:14 +0100 Subject: [PATCH 11/25] Update sfxALBuffer.h revert to head --- Engine/source/sfx/openal/sfxALBuffer.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/Engine/source/sfx/openal/sfxALBuffer.h b/Engine/source/sfx/openal/sfxALBuffer.h index d3260d704..26864a3d0 100644 --- a/Engine/source/sfx/openal/sfxALBuffer.h +++ b/Engine/source/sfx/openal/sfxALBuffer.h @@ -84,26 +84,14 @@ class SFXALBuffer : public SFXBuffer return AL_FORMAT_STEREO8; else if( bps == 32 ) return AL_FORMAT_STEREO16; - /* MAC doesnt like 32bit openal (doesnt use the ext) - else if (bps == 64) - { - if (alIsExtensionPresent("AL_EXT_FLOAT32")) - return AL_FORMAT_STEREO_FLOAT32; - }*/ } else if( format.getChannels() == 1 ) { const U32 bps = format.getBitsPerSample(); - if (bps == 8) + if( bps == 8 ) return AL_FORMAT_MONO8; - else if (bps == 16) + else if( bps == 16 ) return AL_FORMAT_MONO16; - /* - else if (bps == 32) - { - if(alIsExtensionPresent("AL_EXT_FLOAT32")) - return AL_FORMAT_MONO_FLOAT32; - }*/ } return 0; } @@ -128,4 +116,4 @@ class SFXALBuffer : public SFXBuffer virtual ~SFXALBuffer(); }; -#endif // _SFXALBUFFER_H_ +#endif // _SFXALBUFFER_H_ \ No newline at end of file From 56e4484ff612a70456e2ebd1e6ffff4c1508c47e Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 30 May 2024 17:29:42 -0500 Subject: [PATCH 12/25] remove glowbin as it's own render pass --- .../glsl/deferredShadingFeaturesGLSL.cpp | 6 +- .../hlsl/deferredShadingFeaturesHLSL.cpp | 6 +- .../source/materials/materialFeatureTypes.cpp | 3 +- Engine/source/materials/processedMaterial.cpp | 14 +- Engine/source/materials/processedMaterial.h | 7 +- .../materials/processedShaderMaterial.cpp | 4 +- Engine/source/materials/sceneData.h | 4 - .../renderInstance/renderDeferredMgr.cpp | 3 +- .../source/renderInstance/renderGlowMgr.cpp | 282 ------------------ Engine/source/renderInstance/renderGlowMgr.h | 90 ------ .../renderInstance/renderPassManager.cpp | 1 - .../shaderGen/GLSL/shaderFeatureGLSL.cpp | 23 +- .../source/shaderGen/GLSL/shaderFeatureGLSL.h | 4 +- .../shaderGen/HLSL/shaderFeatureHLSL.cpp | 23 +- .../source/shaderGen/HLSL/shaderFeatureHLSL.h | 4 +- .../DepthOfField/DepthOfFieldPostFX.tscript | 2 +- .../postFX/scripts/Glow/GlowPostFX.tscript | 71 ----- .../Turbulence/TurbulencePostFX.tscript | 2 +- .../rendering/scripts/renderManager.tscript | 5 +- 19 files changed, 44 insertions(+), 510 deletions(-) delete mode 100644 Engine/source/renderInstance/renderGlowMgr.cpp delete mode 100644 Engine/source/renderInstance/renderGlowMgr.h diff --git a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp index 3d881b398..66e451ab7 100644 --- a/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp +++ b/Engine/source/lighting/advanced/glsl/deferredShadingFeaturesGLSL.cpp @@ -261,16 +261,16 @@ void GlowMapGLSL::processPix(Vector& componentList, const Mate targ->setType("vec4"); targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3)); targ->setStructName("OUT"); - output = new GenOp("@ = vec4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ = vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),0);", targ, texOp, glowMul); } else { - output = new GenOp("@ += vec4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ += vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),0);", targ, texOp, glowMul); } } else { - output = new GenOp("@ += vec4(@.rgb*@,@.a);", targ, texOp, glowMul, targ); + output = new GenOp("@ += vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),@.a);", targ, texOp, glowMul, targ); } } diff --git a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp index 42518830a..8b7d3c0bb 100644 --- a/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp +++ b/Engine/source/lighting/advanced/hlsl/deferredShadingFeaturesHLSL.cpp @@ -264,16 +264,16 @@ void GlowMapHLSL::processPix(Vector &componentList, const Mate targ->setType("fragout"); targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3)); targ->setStructName("OUT"); - output = new GenOp("@ = float4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ = float4(pow(max(@.rgb*@,0.0),3.54406804435),0);", targ, texOp, glowMul); } else { - output = new GenOp("@ += float4(@.rgb*@,0);", targ, texOp, glowMul); + output = new GenOp("@ += float4(pow(max(@.rgb*@,0.0),3.54406804435),0);", targ, texOp, glowMul); } } else { - output = new GenOp("@ += float4(@.rgb*@,@.a);", targ, texOp, glowMul, targ); + output = new GenOp("@ += float4(pow(max(@.rgb*@,0.0),3.54406804435),@.a);", targ, texOp, glowMul, targ); } } diff --git a/Engine/source/materials/materialFeatureTypes.cpp b/Engine/source/materials/materialFeatureTypes.cpp index 44220a9b1..2a5736ae3 100644 --- a/Engine/source/materials/materialFeatureTypes.cpp +++ b/Engine/source/materials/materialFeatureTypes.cpp @@ -56,6 +56,7 @@ ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true ); ImplementFeatureType(MFT_ReflectionProbes, MFG_Lighting, 1.0f, true); ImplementFeatureType( MFT_RTLighting, MFG_Lighting, 2.0f, true ); ImplementFeatureType( MFT_GlowMap, MFG_Lighting, 3.0f, true ); +ImplementFeatureType( MFT_GlowMask, MFG_Lighting, 3.1f, true ); ImplementFeatureType( MFT_LightMap, MFG_Lighting, 4.0f, true ); ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 5.0f, true ); ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 6.0f, false ); @@ -65,8 +66,6 @@ ImplementFeatureType( MFT_SubSurface, MFG_Lighting, 8.0f, true ); ImplementFeatureType( MFT_VertLit, MFG_Lighting, 9.0f, true ); ImplementFeatureType( MFT_MinnaertShading, MFG_Lighting, 10.0f, true ); - -ImplementFeatureType( MFT_GlowMask, MFG_PostLighting, 1.0f, true ); ImplementFeatureType( MFT_Visibility, MFG_PostLighting, 2.0f, true ); ImplementFeatureType( MFT_Fog, MFG_PostProcess, 3.0f, true ); diff --git a/Engine/source/materials/processedMaterial.cpp b/Engine/source/materials/processedMaterial.cpp index 79b08249a..f4b0d2417 100644 --- a/Engine/source/materials/processedMaterial.cpp +++ b/Engine/source/materials/processedMaterial.cpp @@ -197,7 +197,7 @@ void ProcessedMaterial::addStateBlockDesc(const GFXStateBlockDesc& sb) mUserDefined = sb; } -void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect) +void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateReflect) { // Translucency stateTranslucent.blendDefined = true; @@ -211,10 +211,6 @@ void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslu stateTranslucent.alphaTestFunc = GFXCmpGreaterEqual; stateTranslucent.samplersDefined = true; - // Glow - stateGlow.zDefined = true; - stateGlow.zWriteEnable = false; - // Reflect stateReflect.cullDefined = true; stateReflect.cullMode = mMaterial->mDoubleSided ? GFXCullNone : GFXCullCW; @@ -316,11 +312,10 @@ void ProcessedMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockD void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd ) { GFXStateBlockDesc stateTranslucent; - GFXStateBlockDesc stateGlow; GFXStateBlockDesc stateReflect; GFXStateBlockDesc statePass; - _initStateBlockTemplates( stateTranslucent, stateGlow, stateReflect ); + _initStateBlockTemplates( stateTranslucent, stateReflect ); _initPassStateBlock( rpd, statePass ); // Ok, we've got our templates set up, let's combine them together based on state and @@ -333,8 +328,6 @@ void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd ) stateFinal.addDesc(stateReflect); if (i & RenderPassData::STATE_TRANSLUCENT) stateFinal.addDesc(stateTranslucent); - if (i & RenderPassData::STATE_GLOW) - stateFinal.addDesc(stateGlow); stateFinal.addDesc(statePass); @@ -359,9 +352,6 @@ U32 ProcessedMaterial::_getRenderStateIndex( const SceneRenderState *sceneState, // For example sgData.visibility would be bad to use // in here without changing how RenderMeshMgr works. - if ( sgData.binType == SceneData::GlowBin ) - currState |= RenderPassData::STATE_GLOW; - if ( sceneState && sceneState->isReflectPass() ) currState |= RenderPassData::STATE_REFLECT; diff --git a/Engine/source/materials/processedMaterial.h b/Engine/source/materials/processedMaterial.h index d316fc450..4efc338bc 100644 --- a/Engine/source/materials/processedMaterial.h +++ b/Engine/source/materials/processedMaterial.h @@ -98,9 +98,8 @@ public: { STATE_REFLECT = 1, STATE_TRANSLUCENT = 2, - STATE_GLOW = 4, - STATE_WIREFRAME = 8, - STATE_MAX = 16 + STATE_WIREFRAME = 4, + STATE_MAX = 8 }; /// @@ -301,7 +300,7 @@ protected: /// @{ /// Creates the default state block templates, used by initStateBlocks. - virtual void _initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect); + virtual void _initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateReflect); /// Does the base render state block setting, normally per pass. virtual void _initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc& result); diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index 77566ef29..521ec04c6 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -348,7 +348,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, // if ( features.hasFeature( MFT_UseInstancing ) && mMaxStages == 1 && - !mMaterial->mGlow[0] && shaderVersion >= 3.0f ) fd.features.addFeature( MFT_UseInstancing ); @@ -520,6 +519,9 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, if ( mMaterial->mVertColor[ stageNum ] && mVertexFormat->hasColor() ) fd.features.addFeature( MFT_DiffuseVertColor ); + + if (mMaterial->mGlow[stageNum]) + fd.features.addFeature(MFT_GlowMask); // Allow features to add themselves. for ( U32 i = 0; i < FEATUREMGR->getFeatureCount(); i++ ) diff --git a/Engine/source/materials/sceneData.h b/Engine/source/materials/sceneData.h index 67a521923..bd99e3e00 100644 --- a/Engine/source/materials/sceneData.h +++ b/Engine/source/materials/sceneData.h @@ -45,10 +45,6 @@ struct SceneData /// the special bins we care about. RegularBin = 0, - /// The glow render bin. - /// @see RenderGlowMgr - GlowBin, - /// The deferred render bin. /// @RenderDeferredMgr DeferredBin, diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index 664302528..65276a111 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -683,7 +683,8 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum, type == MFT_UseInstancing || type == MFT_DiffuseVertColor || type == MFT_DetailMap || - type == MFT_DiffuseMapAtlas) + type == MFT_DiffuseMapAtlas|| + type == MFT_GlowMask) newFeatures.addFeature( type ); // Add any transform features. diff --git a/Engine/source/renderInstance/renderGlowMgr.cpp b/Engine/source/renderInstance/renderGlowMgr.cpp deleted file mode 100644 index 17ae78c60..000000000 --- a/Engine/source/renderInstance/renderGlowMgr.cpp +++ /dev/null @@ -1,282 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -#include "platform/platform.h" -#include "renderInstance/renderGlowMgr.h" -#include "renderInstance/renderParticleMgr.h" - -#include "scene/sceneManager.h" -#include "scene/sceneRenderState.h" -#include "materials/sceneData.h" -#include "materials/matInstance.h" -#include "materials/materialFeatureTypes.h" -#include "materials/processedMaterial.h" -#include "postFx/postEffect.h" -#include "gfx/gfxTransformSaver.h" -#include "gfx/gfxDebugEvent.h" -#include "math/util/matrixSet.h" - -IMPLEMENT_CONOBJECT( RenderGlowMgr ); - - -ConsoleDocClass( RenderGlowMgr, - "@brief A render bin for the glow pass.\n\n" - "When the glow buffer PostEffect is enabled this bin gathers mesh render " - "instances with glow materials and renders them to the #glowbuffer offscreen " - "render target.\n\n" - "This render target is then used by the 'GlowPostFx' PostEffect to blur and " - "render the glowing portions of the screen.\n\n" - "@ingroup RenderBin\n" ); - -const MatInstanceHookType RenderGlowMgr::GlowMaterialHook::Type( "Glow" ); - - -RenderGlowMgr::GlowMaterialHook::GlowMaterialHook( BaseMatInstance *matInst ) - : mGlowMatInst( NULL ) -{ - mGlowMatInst = (MatInstance*)matInst->getMaterial()->createMatInstance(); - mGlowMatInst->getFeaturesDelegate().bind( &GlowMaterialHook::_overrideFeatures ); - mGlowMatInst->setUserObject(matInst->getUserObject()); - mGlowMatInst->init( matInst->getRequestedFeatures(), - matInst->getVertexFormat() ); -} - -RenderGlowMgr::GlowMaterialHook::~GlowMaterialHook() -{ - SAFE_DELETE( mGlowMatInst ); -} - -void RenderGlowMgr::GlowMaterialHook::_overrideFeatures( ProcessedMaterial *mat, - U32 stageNum, - MaterialFeatureData &fd, - const FeatureSet &features ) -{ - // If this isn't a glow pass... then add the glow mask feature. - if ( mat->getMaterial() && - !mat->getMaterial()->mGlow[stageNum] ) - fd.features.addFeature( MFT_GlowMask ); - - // Don't allow fog or HDR encoding on - // the glow materials. - fd.features.removeFeature( MFT_Fog ); - fd.features.addFeature( MFT_Imposter ); -} - -RenderGlowMgr::RenderGlowMgr() - : RenderTexTargetBinManager( RenderPassManager::RIT_Mesh, - 1.0f, - 1.0f, - GFXFormatR8G8B8A8, - Point2I( 512, 512 ) ) -{ - notifyType( RenderPassManager::RIT_Decal ); - notifyType( RenderPassManager::RIT_DecalRoad ); - notifyType( RenderPassManager::RIT_Translucent ); - notifyType( RenderPassManager::RIT_Particle ); - - mParticleRenderMgr = NULL; - - mNamedTarget.registerWithName( "glowbuffer" ); - mTargetSizeType = WindowSize; -} - -RenderGlowMgr::~RenderGlowMgr() -{ -} - -PostEffect* RenderGlowMgr::getGlowEffect() -{ - if ( !mGlowEffect ) - mGlowEffect = dynamic_cast( Sim::findObject( "GlowPostFx" ) ); - - return mGlowEffect; -} - -bool RenderGlowMgr::isGlowEnabled() -{ - return getGlowEffect() && getGlowEffect()->isEnabled(); -} - -void RenderGlowMgr::addElement( RenderInst *inst ) -{ - // Skip out if we don't have the glow post - // effect enabled at this time. - if ( !isGlowEnabled() ) - return; - - // TODO: We need to get the scene state here in a more reliable - // manner so we can skip glow in a non-diffuse render pass. - //if ( !mParentManager->getSceneManager()->getSceneState()->isDiffusePass() ) - //return RenderBinManager::arSkipped; - ParticleRenderInst *particleInst = NULL; - if(inst->type == RenderPassManager::RIT_Particle) - particleInst = static_cast(inst); - if(particleInst && particleInst->glow) - { - internalAddElement(inst); - return; - } - - // Skip it if we don't have a glowing material. - BaseMatInstance *matInst = getMaterial( inst ); - if ( !matInst || !matInst->hasGlow() ) - return; - - internalAddElement(inst); -} - -void RenderGlowMgr::render( SceneRenderState *state ) -{ - PROFILE_SCOPE( RenderGlowMgr_Render ); - - if ( !isGlowEnabled() ) - return; - - const U32 binSize = mElementList.size(); - - // If this is a non-diffuse pass or we have no objects to - // render then tell the effect to skip rendering. - if ( !state->isDiffusePass() || binSize == 0 ) - { - getGlowEffect()->setSkip( true ); - return; - } - - GFXDEBUGEVENT_SCOPE( RenderGlowMgr_Render, ColorI::GREEN ); - - GFXTransformSaver saver; - - // Respect the current viewport - mNamedTarget.setViewport(GFX->getViewport()); - - // Tell the superclass we're about to render, preserve contents - const bool isRenderingToTarget = _onPreRender( state, true ); - - // Clear all the buffers to black. - GFX->clear( GFXClearTarget, ColorI::BLACK, 1.0f, 0); - - // Restore transforms - MatrixSet &matrixSet = getRenderPass()->getMatrixSet(); - matrixSet.restoreSceneViewProjection(); - - // init loop data - SceneData sgData; - sgData.init( state, SceneData::GlowBin ); - - for( U32 j=0; jtype == RenderPassManager::RIT_Particle) - { - // Find the particle render manager (if we don't have it) - if(mParticleRenderMgr == NULL) - { - RenderPassManager *rpm = state->getRenderPass(); - for( U32 i = 0; i < rpm->getManagerCount(); i++ ) - { - RenderBinManager *bin = rpm->getManager(i); - if( bin->getRenderInstType() == RenderParticleMgr::RIT_Particles ) - { - mParticleRenderMgr = reinterpret_cast(bin); - break; - } - } - } - - ParticleRenderInst *ri = static_cast(_ri); - - GFX->setStateBlock(mParticleRenderMgr->_getHighResStateBlock(ri)); - mParticleRenderMgr->_getShaderConsts().mShaderConsts->setSafe(mParticleRenderMgr->_getShaderConsts().mModelViewProjSC, *ri->modelViewProj); - - mParticleRenderMgr->renderParticle(ri, state); - j++; - continue; - } - - MeshRenderInst *ri = static_cast(_ri); - - setupSGData( ri, sgData ); - - BaseMatInstance *mat = ri->matInst; - GlowMaterialHook *hook = mat->getHook(); - if ( !hook ) - { - hook = new GlowMaterialHook( ri->matInst ); - ri->matInst->addHook( hook ); - } - BaseMatInstance *glowMat = hook->getMatInstance(); - - U32 matListEnd = j; - - while( glowMat && glowMat->setupPass( state, sgData ) ) - { - U32 a; - for( a=j; atype == RenderPassManager::RIT_Particle) - break; - - MeshRenderInst *passRI = static_cast(mElementList[a].inst); - - if ( newPassNeeded( ri, passRI ) ) - break; - - matrixSet.setWorld(*passRI->objectToWorld); - matrixSet.setView(*passRI->worldToCamera); - matrixSet.setProjection(*passRI->projection); - glowMat->setTransforms(matrixSet, state); - - // Setup HW skinning transforms if applicable - if (glowMat->usesHardwareSkinning()) - { - glowMat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount); - } - - //push along any overriden fields that are instance-specific as well - if (passRI->mCustomShaderData.size() > 0) - { - mat->setCustomShaderData(passRI->mCustomShaderData); - } - - glowMat->setSceneInfo(state, sgData); - glowMat->setBuffers(passRI->vertBuff, passRI->primBuff); - - if ( passRI->prim ) - GFX->drawPrimitive( *passRI->prim ); - else - GFX->drawPrimitive( passRI->primBuffIndex ); - } - matListEnd = a; - setupSGData( ri, sgData ); - } - - // force increment if none happened, otherwise go to end of batch - j = ( j == matListEnd ) ? j+1 : matListEnd; - } - - // Finish up. - if ( isRenderingToTarget ) - _onPostRender(); - - // Make sure the effect is gonna render. - getGlowEffect()->setSkip( false ); -} diff --git a/Engine/source/renderInstance/renderGlowMgr.h b/Engine/source/renderInstance/renderGlowMgr.h deleted file mode 100644 index 27ff7a03f..000000000 --- a/Engine/source/renderInstance/renderGlowMgr.h +++ /dev/null @@ -1,90 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright (c) 2012 GarageGames, LLC -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal in the Software without restriction, including without limitation the -// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -#ifndef _RENDERGLOWMGR_H_ -#define _RENDERGLOWMGR_H_ - -#ifndef _TEXTARGETBIN_MGR_H_ -#include "renderInstance/renderTexTargetBinManager.h" -#endif -#include - - -class PostEffect; - - -/// -class RenderGlowMgr : public RenderTexTargetBinManager -{ - typedef RenderTexTargetBinManager Parent; - -public: - - RenderGlowMgr(); - virtual ~RenderGlowMgr(); - - /// Returns the glow post effect. - PostEffect* getGlowEffect(); - - /// Returns true if the glow post effect is - /// enabled and the glow buffer should be updated. - bool isGlowEnabled(); - - // RenderBinManager - void addElement( RenderInst *inst ) override; - void render( SceneRenderState *state ) override; - - // ConsoleObject - DECLARE_CONOBJECT( RenderGlowMgr ); - -protected: - - class GlowMaterialHook : public MatInstanceHook - { - public: - - GlowMaterialHook( BaseMatInstance *matInst ); - virtual ~GlowMaterialHook(); - - virtual BaseMatInstance *getMatInstance() { return mGlowMatInst; } - - const MatInstanceHookType& getType() const override { return Type; } - - /// Our material hook type. - static const MatInstanceHookType Type; - - protected: - - static void _overrideFeatures( ProcessedMaterial *mat, - U32 stageNum, - MaterialFeatureData &fd, - const FeatureSet &features ); - - BaseMatInstance *mGlowMatInst; - }; - - SimObjectPtr mGlowEffect; - RenderParticleMgr *mParticleRenderMgr; -}; - - -#endif // _RENDERGLOWMGR_H_ diff --git a/Engine/source/renderInstance/renderPassManager.cpp b/Engine/source/renderInstance/renderPassManager.cpp index 5c88041c7..fdcf76936 100644 --- a/Engine/source/renderInstance/renderPassManager.cpp +++ b/Engine/source/renderInstance/renderPassManager.cpp @@ -35,7 +35,6 @@ #include "renderInstance/renderObjectMgr.h" #include "renderInstance/renderMeshMgr.h" #include "renderInstance/renderTranslucentMgr.h" -#include "renderInstance/renderGlowMgr.h" #include "renderInstance/renderTerrainMgr.h" #include "core/util/safeDelete.h" #include "math/util/matrixSet.h" diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 33c3f520d..1fd6276d3 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -2519,23 +2519,22 @@ void AlphaTestGLSL::processPix( Vector &componentList, //**************************************************************************** // GlowMask //**************************************************************************** - void GlowMaskGLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { - output = NULL; - - // Get the output color... and make it black to mask out - // glow passes rendered before us. - // - // The shader compiler will optimize out all the other - // code above that doesn't contribute to the alpha mask. - Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - if ( color ) - output = new GenOp( " @.rgb = vec3(0);\r\n", color ); + //determine output target + ShaderFeature::OutputTarget inTarg, outTarg; + inTarg = outTarg = ShaderFeature::DefaultTarget; + if (fd.features[MFT_isDeferred]) + { + inTarg = ShaderFeature::RenderTarget1; + outTarg = ShaderFeature::RenderTarget3; + } + Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg)); + Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg)); + output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol); } - //**************************************************************************** // RenderTargetZero //**************************************************************************** diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h index 5db741ded..e7bcea21f 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.h @@ -552,11 +552,9 @@ public: class GlowMaskGLSL : public ShaderFeatureGLSL { public: + void processPix( Vector &componentList, const MaterialFeatureData &fd ) override; - - Material::BlendOp getBlendOp() override { return Material::None; } - String getName() override { return "Glow Mask"; diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 0f1bf06fd..8e7542052 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -2592,23 +2592,22 @@ void AlphaTestHLSL::processPix( Vector &componentList, //**************************************************************************** // GlowMask //**************************************************************************** - void GlowMaskHLSL::processPix( Vector &componentList, const MaterialFeatureData &fd ) { - output = NULL; - - // Get the output color... and make it black to mask out - // glow passes rendered before us. - // - // The shader compiler will optimize out all the other - // code above that doesn't contribute to the alpha mask. - Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); - if ( color ) - output = new GenOp( " @.rgb = 0;\r\n", color ); + //determine output target + ShaderFeature::OutputTarget inTarg, outTarg; + inTarg = outTarg = ShaderFeature::DefaultTarget; + if (fd.features[MFT_isDeferred]) + { + inTarg = ShaderFeature::RenderTarget1; + outTarg = ShaderFeature::RenderTarget3; + } + Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg)); + Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg)); + output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol); } - //**************************************************************************** // RenderTargetZero //**************************************************************************** diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h index 49c32e66e..627f1019a 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.h @@ -555,11 +555,9 @@ public: class GlowMaskHLSL : public ShaderFeatureHLSL { public: + void processPix( Vector &componentList, const MaterialFeatureData &fd ) override; - - Material::BlendOp getBlendOp() override { return Material::None; } - String getName() override { return "Glow Mask"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript index 74feb289d..d77dc2511 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/DepthOfField/DepthOfFieldPostFX.tscript @@ -407,7 +407,7 @@ singleton PostEffect( DepthOfFieldPostFX ) enabled = false; renderTime = "PFXAfterBin"; - renderBin = "GlowBin"; + renderBin = "FogBin"; renderPriority = 0.1; shader = PFX_DOFDownSampleShader; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript index 8f2c5a72d..0e3ce4457 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/Glow/GlowPostFX.tscript @@ -20,29 +20,6 @@ // IN THE SOFTWARE. //----------------------------------------------------------------------------- - -singleton ShaderData( PFX_GlowBlurVertShader ) -{ - DXVertexShaderFile = "./glowBlurV.hlsl"; - DXPixelShaderFile = "./glowBlurP.hlsl"; - - OGLVertexShaderFile = "./glowBlurV.glsl"; - OGLPixelShaderFile = "./glowBlurP.glsl"; - - defines = "BLUR_DIR=float2(0.0,1.0)"; - - samplerNames[0] = "$diffuseMap"; - - pixVersion = 2.0; -}; - - -singleton ShaderData( PFX_GlowBlurHorzShader : PFX_GlowBlurVertShader ) -{ - defines = "BLUR_DIR=float2(1.0,0.0)"; -}; - - singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock ) { // Use alpha test to save some fillrate @@ -59,54 +36,6 @@ singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock ) blendDest = GFXBlendOne; }; - -singleton PostEffect( GlowPostFX ) -{ - // Do not allow the glow effect to work in reflection - // passes by default so we don't do the extra drawing. - allowReflectPass = false; - - renderTime = "PFXAfterBin"; - renderBin = "GlowBin"; - renderPriority = 1; - - // First we down sample the glow buffer. - shader = PFX_PassthruShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "#glowbuffer"; - target = "$outTex"; - targetScale = "0.5 0.5"; - - enabled = true; - - // Blur vertically - new PostEffect() - { - shader = PFX_GlowBlurVertShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "$inTex"; - target = "$outTex"; - }; - - // Blur horizontally - new PostEffect() - { - shader = PFX_GlowBlurHorzShader; - stateBlock = PFX_DefaultStateBlock; - texture[0] = "$inTex"; - target = "$outTex"; - }; - - // Upsample and combine with the back buffer. - new PostEffect() - { - shader = PFX_PassthruShader; - stateBlock = PFX_GlowCombineStateBlock; - texture[0] = "$inTex"; - target = "$backBuffer"; - }; -}; - singleton ShaderData( PFX_VolFogGlowBlurVertShader ) { DXVertexShaderFile = "./glowBlurV.hlsl"; diff --git a/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript index 2d30550a5..781333dce 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript +++ b/Templates/BaseGame/game/core/postFX/scripts/Turbulence/TurbulencePostFX.tscript @@ -48,7 +48,7 @@ singleton PostEffect( TurbulencePostFX ) allowReflectPass = true; renderTime = "PFXAfterDiffuse"; - renderBin = "GlowBin"; + renderBin = "FogBin"; renderPriority = 0.5; // Render after the glows themselves shader = PFX_TurbulenceShader; diff --git a/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript b/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript index 34a48f64a..e3461b199 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript +++ b/Templates/BaseGame/game/core/rendering/scripts/renderManager.tscript @@ -79,10 +79,7 @@ function initRenderManager() DiffuseRenderPassManager.addManager( new RenderTranslucentMgr(TranslucentBin){ renderOrder = 1.4; processAddOrder = 1.4; } ); DiffuseRenderPassManager.addManager(new RenderObjectMgr(FogBin){ bintype = "ObjectVolumetricFog"; renderOrder = 1.45; processAddOrder = 1.45; } ); - - // Note that the GlowPostFx is triggered after this bin. - DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } ); - + // We render any editor stuff from this bin. Note that the HDR is // completed before this bin to keep editor elements from tone mapping. DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } ); From 8140ed9b64ae822811cb821c0bd1e48ea5f94389 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 7 Jun 2024 20:13:56 +0100 Subject: [PATCH 13/25] clear clear lines, and dont try to print lines when there is no file. --- Engine/source/console/torquescript/CMDgram.y | 15 +++++++++------ Engine/source/console/torquescript/CMDscan.cpp | 1 + Engine/source/console/torquescript/CMDscan.l | 1 + Engine/source/console/torquescript/cmdgram.cpp | 15 +++++++++------ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Engine/source/console/torquescript/CMDgram.y b/Engine/source/console/torquescript/CMDgram.y index 1e118ae1b..8aea2b470 100644 --- a/Engine/source/console/torquescript/CMDgram.y +++ b/Engine/source/console/torquescript/CMDgram.y @@ -645,15 +645,18 @@ yyreport_syntax_error (const yypcontext_t *ctx) output += String::ToString("%s %s", i == 0 ? ": expected" : "or", yysymbol_name(expected[i])); } - if (lines.size() > 0) + if(CMDGetCurrentFile()) { - output += "\n"; - for (int i = 0; i < lines.size(); i++) + if (lines.size() > 0) { - int line = lines.size() - i; - output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; + output += "\n"; + for (int i = 0; i < lines.size(); i++) + { + int line = lines.size() - i; + output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; + } + output += String::ToString("%5s | %*s", "", loc->first_column, "^"); } - output += String::ToString("%5s | %*s", "", loc->first_column, "^"); } yyerror(output.c_str()); diff --git a/Engine/source/console/torquescript/CMDscan.cpp b/Engine/source/console/torquescript/CMDscan.cpp index 5ca6ca7d9..36baa2099 100644 --- a/Engine/source/console/torquescript/CMDscan.cpp +++ b/Engine/source/console/torquescript/CMDscan.cpp @@ -2742,6 +2742,7 @@ void CMDSetScanBuffer(const char *sb, const char *fn) fileName = fn; scanIndex = 0; yylineno = 1; + lines.clear(); } int CMDgetc() diff --git a/Engine/source/console/torquescript/CMDscan.l b/Engine/source/console/torquescript/CMDscan.l index d6a03186a..751f92936 100644 --- a/Engine/source/console/torquescript/CMDscan.l +++ b/Engine/source/console/torquescript/CMDscan.l @@ -292,6 +292,7 @@ void CMDSetScanBuffer(const char *sb, const char *fn) fileName = fn; scanIndex = 0; yylineno = 1; + lines.clear(); } int CMDgetc() diff --git a/Engine/source/console/torquescript/cmdgram.cpp b/Engine/source/console/torquescript/cmdgram.cpp index 8b7d536c6..52161e92b 100644 --- a/Engine/source/console/torquescript/cmdgram.cpp +++ b/Engine/source/console/torquescript/cmdgram.cpp @@ -3352,15 +3352,18 @@ yyreport_syntax_error (const yypcontext_t *ctx) output += String::ToString("%s %s", i == 0 ? ": expected" : "or", yysymbol_name(expected[i])); } - if (lines.size() > 0) + if(CMDGetCurrentFile()) { - output += "\n"; - for (int i = 0; i < lines.size(); i++) + if (lines.size() > 0) { - int line = lines.size() - i; - output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; + output += "\n"; + for (int i = 0; i < lines.size(); i++) + { + int line = lines.size() - i; + output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; + } + output += String::ToString("%5s | %*s", "", loc->first_column, "^"); } - output += String::ToString("%5s | %*s", "", loc->first_column, "^"); } yyerror(output.c_str()); From 1c43959c07b9bc7d4afee527a6d11441f02a3110 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Fri, 7 Jun 2024 20:44:44 +0100 Subject: [PATCH 14/25] multiline eval support --- Engine/source/console/torquescript/CMDgram.y | 15 +- .../source/console/torquescript/CMDscan.cpp | 185 +++++++++--------- Engine/source/console/torquescript/CMDscan.l | 3 +- .../source/console/torquescript/cmdgram.cpp | 15 +- 4 files changed, 107 insertions(+), 111 deletions(-) diff --git a/Engine/source/console/torquescript/CMDgram.y b/Engine/source/console/torquescript/CMDgram.y index 8aea2b470..1e118ae1b 100644 --- a/Engine/source/console/torquescript/CMDgram.y +++ b/Engine/source/console/torquescript/CMDgram.y @@ -645,18 +645,15 @@ yyreport_syntax_error (const yypcontext_t *ctx) output += String::ToString("%s %s", i == 0 ? ": expected" : "or", yysymbol_name(expected[i])); } - if(CMDGetCurrentFile()) + if (lines.size() > 0) { - if (lines.size() > 0) + output += "\n"; + for (int i = 0; i < lines.size(); i++) { - output += "\n"; - for (int i = 0; i < lines.size(); i++) - { - int line = lines.size() - i; - output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; - } - output += String::ToString("%5s | %*s", "", loc->first_column, "^"); + int line = lines.size() - i; + output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; } + output += String::ToString("%5s | %*s", "", loc->first_column, "^"); } yyerror(output.c_str()); diff --git a/Engine/source/console/torquescript/CMDscan.cpp b/Engine/source/console/torquescript/CMDscan.cpp index 36baa2099..4497cb961 100644 --- a/Engine/source/console/torquescript/CMDscan.cpp +++ b/Engine/source/console/torquescript/CMDscan.cpp @@ -1301,7 +1301,8 @@ case 5: /* rule 5 can match eol */ YY_RULE_SETUP #line 120 "CMDscan.l" -{ yycolumn = 1; +{ + yycolumn = 1; lines.push_back(String::ToString("%s", yytext+1)); if (lines.size() > Con::getIntVariable("$scriptErrorLineCount", 10)) lines.erase(lines.begin()); @@ -1311,162 +1312,162 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 127 "CMDscan.l" +#line 128 "CMDscan.l" { return(Sc_ScanString(STRATOM)); } YY_BREAK case 7: YY_RULE_SETUP -#line 128 "CMDscan.l" +#line 129 "CMDscan.l" { return(Sc_ScanString(TAGATOM)); } YY_BREAK case 8: YY_RULE_SETUP -#line 129 "CMDscan.l" +#line 130 "CMDscan.l" { CMDlval.i = MakeToken< int >( opEQ, yylineno ); return opEQ; } YY_BREAK case 9: YY_RULE_SETUP -#line 130 "CMDscan.l" +#line 131 "CMDscan.l" { CMDlval.i = MakeToken< int >( opNE, yylineno ); return opNE; } YY_BREAK case 10: YY_RULE_SETUP -#line 131 "CMDscan.l" +#line 132 "CMDscan.l" { CMDlval.i = MakeToken< int >( opGE, yylineno ); return opGE; } YY_BREAK case 11: YY_RULE_SETUP -#line 132 "CMDscan.l" +#line 133 "CMDscan.l" { CMDlval.i = MakeToken< int >( opLE, yylineno ); return opLE; } YY_BREAK case 12: YY_RULE_SETUP -#line 133 "CMDscan.l" +#line 134 "CMDscan.l" { CMDlval.i = MakeToken< int >( opAND, yylineno ); return opAND; } YY_BREAK case 13: YY_RULE_SETUP -#line 134 "CMDscan.l" +#line 135 "CMDscan.l" { CMDlval.i = MakeToken< int >( opOR, yylineno ); return opOR; } YY_BREAK case 14: YY_RULE_SETUP -#line 135 "CMDscan.l" +#line 136 "CMDscan.l" { CMDlval.i = MakeToken< int >( opCOLONCOLON, yylineno ); return opCOLONCOLON; } YY_BREAK case 15: YY_RULE_SETUP -#line 136 "CMDscan.l" +#line 137 "CMDscan.l" { CMDlval.i = MakeToken< int >( opMINUSMINUS, yylineno ); return opMINUSMINUS; } YY_BREAK case 16: YY_RULE_SETUP -#line 137 "CMDscan.l" +#line 138 "CMDscan.l" { CMDlval.i = MakeToken< int >( opPLUSPLUS, yylineno ); return opPLUSPLUS; } YY_BREAK case 17: YY_RULE_SETUP -#line 138 "CMDscan.l" +#line 139 "CMDscan.l" { CMDlval.i = MakeToken< int >( opSTREQ, yylineno ); return opSTREQ; } YY_BREAK case 18: YY_RULE_SETUP -#line 139 "CMDscan.l" +#line 140 "CMDscan.l" { CMDlval.i = MakeToken< int >( opSTRNE, yylineno ); return opSTRNE; } YY_BREAK case 19: YY_RULE_SETUP -#line 140 "CMDscan.l" +#line 141 "CMDscan.l" { CMDlval.i = MakeToken< int >( opSHL, yylineno ); return opSHL; } YY_BREAK case 20: YY_RULE_SETUP -#line 141 "CMDscan.l" +#line 142 "CMDscan.l" { CMDlval.i = MakeToken< int >( opSHR, yylineno ); return opSHR; } YY_BREAK case 21: YY_RULE_SETUP -#line 142 "CMDscan.l" +#line 143 "CMDscan.l" { CMDlval.i = MakeToken< int >( opPLASN, yylineno ); return opPLASN; } YY_BREAK case 22: YY_RULE_SETUP -#line 143 "CMDscan.l" +#line 144 "CMDscan.l" { CMDlval.i = MakeToken< int >( opMIASN, yylineno ); return opMIASN; } YY_BREAK case 23: YY_RULE_SETUP -#line 144 "CMDscan.l" +#line 145 "CMDscan.l" { CMDlval.i = MakeToken< int >( opMLASN, yylineno ); return opMLASN; } YY_BREAK case 24: YY_RULE_SETUP -#line 145 "CMDscan.l" +#line 146 "CMDscan.l" { CMDlval.i = MakeToken< int >( opDVASN, yylineno ); return opDVASN; } YY_BREAK case 25: YY_RULE_SETUP -#line 146 "CMDscan.l" +#line 147 "CMDscan.l" { CMDlval.i = MakeToken< int >( opMODASN, yylineno ); return opMODASN; } YY_BREAK case 26: YY_RULE_SETUP -#line 147 "CMDscan.l" +#line 148 "CMDscan.l" { CMDlval.i = MakeToken< int >( opANDASN, yylineno ); return opANDASN; } YY_BREAK case 27: YY_RULE_SETUP -#line 148 "CMDscan.l" +#line 149 "CMDscan.l" { CMDlval.i = MakeToken< int >( opXORASN, yylineno ); return opXORASN; } YY_BREAK case 28: YY_RULE_SETUP -#line 149 "CMDscan.l" +#line 150 "CMDscan.l" { CMDlval.i = MakeToken< int >( opORASN, yylineno ); return opORASN; } YY_BREAK case 29: YY_RULE_SETUP -#line 150 "CMDscan.l" +#line 151 "CMDscan.l" { CMDlval.i = MakeToken< int >( opSLASN, yylineno ); return opSLASN; } YY_BREAK case 30: YY_RULE_SETUP -#line 151 "CMDscan.l" +#line 152 "CMDscan.l" { CMDlval.i = MakeToken< int >( opSRASN, yylineno ); return opSRASN; } YY_BREAK case 31: YY_RULE_SETUP -#line 152 "CMDscan.l" +#line 153 "CMDscan.l" { CMDlval.i = MakeToken< int >( opINTNAME, yylineno ); return opINTNAME; } YY_BREAK case 32: YY_RULE_SETUP -#line 153 "CMDscan.l" +#line 154 "CMDscan.l" { CMDlval.i = MakeToken< int >( opINTNAMER, yylineno ); return opINTNAMER; } YY_BREAK case 33: YY_RULE_SETUP -#line 154 "CMDscan.l" +#line 155 "CMDscan.l" { CMDlval.i = MakeToken< int >( '\n', yylineno ); return '@'; } YY_BREAK case 34: YY_RULE_SETUP -#line 155 "CMDscan.l" +#line 156 "CMDscan.l" { CMDlval.i = MakeToken< int >( '\t', yylineno ); return '@'; } YY_BREAK case 35: YY_RULE_SETUP -#line 156 "CMDscan.l" +#line 157 "CMDscan.l" { CMDlval.i = MakeToken< int >( ' ', yylineno ); return '@'; } YY_BREAK case 36: YY_RULE_SETUP -#line 157 "CMDscan.l" +#line 158 "CMDscan.l" { CMDlval.i = MakeToken< int >( 0, yylineno ); return '@'; } YY_BREAK case 37: YY_RULE_SETUP -#line 158 "CMDscan.l" +#line 159 "CMDscan.l" { /* this comment stops syntax highlighting from getting messed up when editing the lexer in TextPad */ int c = 0, l; for ( ; ; ) @@ -1488,222 +1489,222 @@ YY_RULE_SETUP } YY_BREAK case 38: -#line 178 "CMDscan.l" -case 39: #line 179 "CMDscan.l" -case 40: +case 39: #line 180 "CMDscan.l" -case 41: +case 40: #line 181 "CMDscan.l" -case 42: +case 41: #line 182 "CMDscan.l" -case 43: +case 42: #line 183 "CMDscan.l" -case 44: +case 43: #line 184 "CMDscan.l" -case 45: +case 44: #line 185 "CMDscan.l" -case 46: +case 45: #line 186 "CMDscan.l" -case 47: +case 46: #line 187 "CMDscan.l" -case 48: +case 47: #line 188 "CMDscan.l" -case 49: +case 48: #line 189 "CMDscan.l" -case 50: +case 49: #line 190 "CMDscan.l" -case 51: +case 50: #line 191 "CMDscan.l" -case 52: +case 51: #line 192 "CMDscan.l" -case 53: +case 52: #line 193 "CMDscan.l" -case 54: +case 53: #line 194 "CMDscan.l" -case 55: +case 54: #line 195 "CMDscan.l" -case 56: +case 55: #line 196 "CMDscan.l" -case 57: +case 56: #line 197 "CMDscan.l" -case 58: +case 57: #line 198 "CMDscan.l" -case 59: +case 58: #line 199 "CMDscan.l" -case 60: +case 59: #line 200 "CMDscan.l" +case 60: +#line 201 "CMDscan.l" case 61: YY_RULE_SETUP -#line 200 "CMDscan.l" +#line 201 "CMDscan.l" { CMDlval.i = MakeToken< int >( CMDtext[ 0 ], yylineno ); return CMDtext[ 0 ]; } YY_BREAK case 62: YY_RULE_SETUP -#line 201 "CMDscan.l" +#line 202 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwIN, yylineno ); return(rwIN); } YY_BREAK case 63: YY_RULE_SETUP -#line 202 "CMDscan.l" +#line 203 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwCASEOR, yylineno ); return(rwCASEOR); } YY_BREAK case 64: YY_RULE_SETUP -#line 203 "CMDscan.l" +#line 204 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwBREAK, yylineno ); return(rwBREAK); } YY_BREAK case 65: YY_RULE_SETUP -#line 204 "CMDscan.l" +#line 205 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwRETURN, yylineno ); return(rwRETURN); } YY_BREAK case 66: YY_RULE_SETUP -#line 205 "CMDscan.l" +#line 206 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwELSE, yylineno ); return(rwELSE); } YY_BREAK case 67: YY_RULE_SETUP -#line 206 "CMDscan.l" +#line 207 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwASSERT, yylineno ); return(rwASSERT); } YY_BREAK case 68: YY_RULE_SETUP -#line 207 "CMDscan.l" +#line 208 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwWHILE, yylineno ); return(rwWHILE); } YY_BREAK case 69: YY_RULE_SETUP -#line 208 "CMDscan.l" +#line 209 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwDO, yylineno ); return(rwDO); } YY_BREAK case 70: YY_RULE_SETUP -#line 209 "CMDscan.l" +#line 210 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwIF, yylineno ); return(rwIF); } YY_BREAK case 71: YY_RULE_SETUP -#line 210 "CMDscan.l" +#line 211 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwFOREACHSTR, yylineno ); return(rwFOREACHSTR); } YY_BREAK case 72: YY_RULE_SETUP -#line 211 "CMDscan.l" +#line 212 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwFOREACH, yylineno ); return(rwFOREACH); } YY_BREAK case 73: YY_RULE_SETUP -#line 212 "CMDscan.l" +#line 213 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwFOR, yylineno ); return(rwFOR); } YY_BREAK case 74: YY_RULE_SETUP -#line 213 "CMDscan.l" +#line 214 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwCONTINUE, yylineno ); return(rwCONTINUE); } YY_BREAK case 75: YY_RULE_SETUP -#line 214 "CMDscan.l" +#line 215 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwDEFINE, yylineno ); return(rwDEFINE); } YY_BREAK case 76: YY_RULE_SETUP -#line 215 "CMDscan.l" +#line 216 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwDECLARE, yylineno ); return(rwDECLARE); } YY_BREAK case 77: YY_RULE_SETUP -#line 216 "CMDscan.l" +#line 217 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwDECLARESINGLETON, yylineno ); return(rwDECLARESINGLETON); } YY_BREAK case 78: YY_RULE_SETUP -#line 217 "CMDscan.l" +#line 218 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwDATABLOCK, yylineno ); return(rwDATABLOCK); } YY_BREAK case 79: YY_RULE_SETUP -#line 218 "CMDscan.l" +#line 219 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwCASE, yylineno ); return(rwCASE); } YY_BREAK case 80: YY_RULE_SETUP -#line 219 "CMDscan.l" +#line 220 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwSWITCHSTR, yylineno ); return(rwSWITCHSTR); } YY_BREAK case 81: YY_RULE_SETUP -#line 220 "CMDscan.l" +#line 221 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwSWITCH, yylineno ); return(rwSWITCH); } YY_BREAK case 82: YY_RULE_SETUP -#line 221 "CMDscan.l" +#line 222 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwDEFAULT, yylineno ); return(rwDEFAULT); } YY_BREAK case 83: YY_RULE_SETUP -#line 222 "CMDscan.l" +#line 223 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwPACKAGE, yylineno ); return(rwPACKAGE); } YY_BREAK case 84: YY_RULE_SETUP -#line 223 "CMDscan.l" +#line 224 "CMDscan.l" { CMDlval.i = MakeToken< int >( rwNAMESPACE, yylineno ); return(rwNAMESPACE); } YY_BREAK case 85: YY_RULE_SETUP -#line 224 "CMDscan.l" +#line 225 "CMDscan.l" { CMDlval.i = MakeToken< int >( 1, yylineno ); return INTCONST; } YY_BREAK case 86: YY_RULE_SETUP -#line 225 "CMDscan.l" +#line 226 "CMDscan.l" { CMDlval.i = MakeToken< int >( 0, yylineno ); return INTCONST; } YY_BREAK case 87: YY_RULE_SETUP -#line 226 "CMDscan.l" +#line 227 "CMDscan.l" { return(Sc_ScanVar()); } YY_BREAK case 88: YY_RULE_SETUP -#line 228 "CMDscan.l" +#line 229 "CMDscan.l" { return Sc_ScanIdent(); } YY_BREAK case 89: YY_RULE_SETUP -#line 229 "CMDscan.l" +#line 230 "CMDscan.l" return(Sc_ScanHex()); YY_BREAK case 90: YY_RULE_SETUP -#line 230 "CMDscan.l" +#line 231 "CMDscan.l" { CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >( dAtoi(CMDtext), yylineno ); return INTCONST; } YY_BREAK case 91: YY_RULE_SETUP -#line 231 "CMDscan.l" +#line 232 "CMDscan.l" return Sc_ScanNum(); YY_BREAK case 92: YY_RULE_SETUP -#line 232 "CMDscan.l" +#line 233 "CMDscan.l" return(ILLEGAL_TOKEN); YY_BREAK case 93: YY_RULE_SETUP -#line 233 "CMDscan.l" +#line 234 "CMDscan.l" return(ILLEGAL_TOKEN); YY_BREAK case 94: YY_RULE_SETUP -#line 234 "CMDscan.l" +#line 235 "CMDscan.l" ECHO; YY_BREAK -#line 1706 "CMDscan.cpp" +#line 1707 "CMDscan.cpp" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2679,7 +2680,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 234 "CMDscan.l" +#line 235 "CMDscan.l" static const char *scanBuffer; diff --git a/Engine/source/console/torquescript/CMDscan.l b/Engine/source/console/torquescript/CMDscan.l index 751f92936..aa3a72733 100644 --- a/Engine/source/console/torquescript/CMDscan.l +++ b/Engine/source/console/torquescript/CMDscan.l @@ -116,7 +116,8 @@ HEXDIGIT [a-fA-F0-9] ("///"([^/\n\r][^\n\r]*)?[\n\r]+)+ { return(Sc_ScanDocBlock()); } "//"[^\n\r]* ; [\r] ; -\n.* { yycolumn = 1; +\n.* { + yycolumn = 1; lines.push_back(String::ToString("%s", yytext+1)); if (lines.size() > Con::getIntVariable("$scriptErrorLineCount", 10)) lines.erase(lines.begin()); diff --git a/Engine/source/console/torquescript/cmdgram.cpp b/Engine/source/console/torquescript/cmdgram.cpp index 52161e92b..8b7d536c6 100644 --- a/Engine/source/console/torquescript/cmdgram.cpp +++ b/Engine/source/console/torquescript/cmdgram.cpp @@ -3352,18 +3352,15 @@ yyreport_syntax_error (const yypcontext_t *ctx) output += String::ToString("%s %s", i == 0 ? ": expected" : "or", yysymbol_name(expected[i])); } - if(CMDGetCurrentFile()) + if (lines.size() > 0) { - if (lines.size() > 0) + output += "\n"; + for (int i = 0; i < lines.size(); i++) { - output += "\n"; - for (int i = 0; i < lines.size(); i++) - { - int line = lines.size() - i; - output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; - } - output += String::ToString("%5s | %*s", "", loc->first_column, "^"); + int line = lines.size() - i; + output += String::ToString("%5d | ", loc->first_line - (line-1)) + lines[i] + "\n"; } + output += String::ToString("%5s | %*s", "", loc->first_column, "^"); } yyerror(output.c_str()); From 5c701fe09e0b1b4375a2f13201398aeb2918ecf3 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 10 Jun 2024 13:15:27 -0500 Subject: [PATCH 15/25] file write clarifications handle clang complaints about hidden virtuals in the context of file writes that have thier own routes and I/O needs. --- Engine/source/core/fileObject.cpp | 20 ++++++++++---------- Engine/source/core/fileObject.h | 4 +++- Engine/source/module/moduleDefinition.h | 2 ++ Engine/source/persistence/taml/taml.h | 1 + Engine/source/util/settings.h | 1 + 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Engine/source/core/fileObject.cpp b/Engine/source/core/fileObject.cpp index 1305074c9..c5efbd654 100644 --- a/Engine/source/core/fileObject.cpp +++ b/Engine/source/core/fileObject.cpp @@ -85,18 +85,18 @@ FileObject::FileObject() mFileBuffer = NULL; mBufferSize = 0; mCurPos = 0; - stream = NULL; + mStream = NULL; } FileObject::~FileObject() { SAFE_DELETE_ARRAY(mFileBuffer); - SAFE_DELETE(stream); + SAFE_DELETE(mStream); } void FileObject::close() { - SAFE_DELETE(stream); + SAFE_DELETE(mStream); SAFE_DELETE_ARRAY(mFileBuffer); mFileBuffer = NULL; mBufferSize = mCurPos = 0; @@ -112,10 +112,10 @@ bool FileObject::openForWrite(const char *fileName, const bool append) if( !buffer[ 0 ] ) return false; - if((stream = FileStream::createAndOpen( fileName, append ? Torque::FS::File::WriteAppend : Torque::FS::File::Write )) == NULL) + if((mStream = FileStream::createAndOpen( fileName, append ? Torque::FS::File::WriteAppend : Torque::FS::File::Write )) == NULL) return false; - stream->setPosition( stream->getStreamSize() ); + mStream->setPosition(mStream->getStreamSize() ); return( true ); } @@ -225,17 +225,17 @@ void FileObject::peekLine( S32 peekLineOffset, U8* line, S32 length ) void FileObject::writeLine(const U8 *line) { - stream->write(dStrlen((const char *) line), line); - stream->write(2, "\r\n"); + mStream->write(dStrlen((const char *) line), line); + mStream->write(2, "\r\n"); } void FileObject::writeObject( SimObject* object, const U8* objectPrepend ) { if( objectPrepend == NULL ) - stream->write(2, "\r\n"); + mStream->write(2, "\r\n"); else - stream->write(dStrlen((const char *) objectPrepend), objectPrepend ); - object->write( *stream, 0 ); + mStream->write(dStrlen((const char *) objectPrepend), objectPrepend ); + object->write( *mStream, 0 ); } DefineEngineMethod( FileObject, openForRead, bool, ( const char* filename ),, diff --git a/Engine/source/core/fileObject.h b/Engine/source/core/fileObject.h index 64559e7db..ae2f20bd2 100644 --- a/Engine/source/core/fileObject.h +++ b/Engine/source/core/fileObject.h @@ -36,7 +36,7 @@ class FileObject : public SimObject U8 *mFileBuffer; U32 mBufferSize; U32 mCurPos; - FileStream *stream; + FileStream *mStream; public: FileObject(); ~FileObject(); @@ -50,6 +50,8 @@ public: bool isEOF(); void writeLine(const U8 *line); void close(); + + bool writeObject(Stream* stream) override { Con::errorf("FileObject:Can Not write a file interface object to a file"); return false; }; //Don't allow writing FileObject *to* files void writeObject( SimObject* object, const U8* objectPrepend = NULL ); DECLARE_CONOBJECT(FileObject); diff --git a/Engine/source/module/moduleDefinition.h b/Engine/source/module/moduleDefinition.h index f26c2ae2c..0fb12f7b0 100644 --- a/Engine/source/module/moduleDefinition.h +++ b/Engine/source/module/moduleDefinition.h @@ -194,6 +194,8 @@ public: inline void setModuleLocked( const bool status ) { mLocked = status; } inline bool getModuleLocked( void ) const { return mLocked; } inline ModuleManager* getModuleManager( void ) const { return mpModuleManager; } + + using Parent::save; bool save( void ); /// Declare Console Object. diff --git a/Engine/source/persistence/taml/taml.h b/Engine/source/persistence/taml/taml.h index 70290684f..dd093e164 100644 --- a/Engine/source/persistence/taml/taml.h +++ b/Engine/source/persistence/taml/taml.h @@ -111,6 +111,7 @@ private: void compileCustomState( TamlWriteNode* pTamlWriteNode ); void compileCustomNodeState( TamlCustomNode* pCustomNode ); + void write(Stream& stream, U32 tabStop, U32 flags = 0) override { Con::errorf("Taml:Can Not write a file interface object to a file"); }; //Don't allow writing Taml objects *to* files bool write( FileStream& stream, SimObject* pSimObject, const TamlFormatMode formatMode ); SimObject* read( FileStream& stream, const TamlFormatMode formatMode ); template inline T* read( FileStream& stream, const TamlFormatMode formatMode ) diff --git a/Engine/source/util/settings.h b/Engine/source/util/settings.h index 3368fe759..41d5a2f84 100644 --- a/Engine/source/util/settings.h +++ b/Engine/source/util/settings.h @@ -52,6 +52,7 @@ public: const UTF8 *value(const UTF8 *settingName, const UTF8 *defaultValue = ""); void remove(const UTF8 *settingName, bool includeDefaults = false); void clearAllFields(); + void write(Stream& stream, U32 tabStop, U32 flags = 0) override { Con::errorf("Settings: Can Not write a file interface object to a file"); }; //Don't allow writing Settings objects *to* files bool write(); bool read(); void readLayer(SimXMLDocument *document, String groupStack = String("")); From a58f98167fc7fbb9b100a9d8395a8e160c0e5c66 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 10 Jun 2024 13:20:09 -0500 Subject: [PATCH 16/25] handle missing virtual destructors clang translation: destructinplace needs to know what to erase. --- Engine/source/T3D/gameBase/moveManager.h | 2 +- Engine/source/gfx/video/theoraTexture.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/T3D/gameBase/moveManager.h b/Engine/source/T3D/gameBase/moveManager.h index 6b26c4196..539046dc4 100644 --- a/Engine/source/T3D/gameBase/moveManager.h +++ b/Engine/source/T3D/gameBase/moveManager.h @@ -57,7 +57,7 @@ struct Move bool trigger[MaxTriggerKeys]; Move(); - + virtual ~Move() {}; virtual void pack(BitStream *stream, const Move * move = NULL); virtual void unpack(BitStream *stream, const Move * move = NULL); virtual void clamp(); diff --git a/Engine/source/gfx/video/theoraTexture.h b/Engine/source/gfx/video/theoraTexture.h index 8c0748068..d262dfae7 100644 --- a/Engine/source/gfx/video/theoraTexture.h +++ b/Engine/source/gfx/video/theoraTexture.h @@ -263,7 +263,7 @@ class TheoraTexture : private IOutputStream< TheoraTextureFrame* >, /// AsyncState( const ThreadSafeRef< OggInputStream >& oggStream, bool looping = false ); - + virtual ~AsyncState() {}; /// Return the Theora decoder substream. OggTheoraDecoder* getTheora() const { return mTheoraDecoder; } From 61978fa4da95adbd1b261ecac24d6935b372dde8 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 11 Jun 2024 15:21:24 -0500 Subject: [PATCH 17/25] pickanimation filter fix, with docs sorts the order of operations flaws clang was complaining about, with explainations on why --- Engine/source/T3D/player.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index f2e54900a..623b5f716 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -4014,9 +4014,9 @@ void Player::updateActionThread() mActionAnimation.callbackTripped = true; } - if ((mActionAnimation.action == PlayerData::NullAnimation) || - ((!mActionAnimation.waitForEnd || mActionAnimation.atEnd) && - (!mActionAnimation.holdAtEnd && (mActionAnimation.delayTicks -= !mMountPending) <= 0))) + if (mActionAnimation.action == PlayerData::NullAnimation || //no animation + ((!mActionAnimation.waitForEnd || (mActionAnimation.atEnd && !mActionAnimation.holdAtEnd) && //either not waiting till the end, or not holding that state + (mActionAnimation.delayTicks -= mMountPending) <= 0))) //not waiting to mount { pickActionAnimation(); } From 7ac714606f93d3759a5a19ea9441d764901616f8 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Tue, 11 Jun 2024 16:08:07 -0500 Subject: [PATCH 18/25] proper formulation --- Engine/source/T3D/player.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 623b5f716..7c0fd1aca 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -4014,9 +4014,9 @@ void Player::updateActionThread() mActionAnimation.callbackTripped = true; } - if (mActionAnimation.action == PlayerData::NullAnimation || //no animation - ((!mActionAnimation.waitForEnd || (mActionAnimation.atEnd && !mActionAnimation.holdAtEnd) && //either not waiting till the end, or not holding that state - (mActionAnimation.delayTicks -= mMountPending) <= 0))) //not waiting to mount + if (mActionAnimation.action == PlayerData::NullAnimation || !mActionAnimation.waitForEnd || //either no animation or not waiting till the end + ((mActionAnimation.atEnd && !mActionAnimation.holdAtEnd) && //or not holding that state and + (mActionAnimation.delayTicks -= mMountPending) <= 0)) //not waiting to mount { pickActionAnimation(); } From e56f4cb6a60bc965db2601310b946c6907418606 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sun, 16 Jun 2024 15:04:20 +0100 Subject: [PATCH 19/25] if statements Changed: if check on vals now return true if the value has a string value %val = "test me" if(%val) will now return true since %val is not null Script side: string checks for "true" and "false" will now be parsed as integer values of 1 and 0. TEST VIGOUROUSLY --- Engine/source/console/console.h | 2 +- Engine/source/console/torquescript/CMDscan.cpp | 12 ++++++++++++ Engine/source/console/torquescript/CMDscan.l | 12 ++++++++++++ Engine/source/console/torquescript/astNodes.cpp | 16 +++++++++++++--- .../source/console/torquescript/compiledEval.cpp | 1 + 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index df921c694..8ac3f2f4c 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -245,7 +245,7 @@ public: if (type == ConsoleValueType::cvSTEntry) return s == StringTable->EmptyString() ? 0 : dAtoi(s); if (type == ConsoleValueType::cvString) - return dStrcmp(s, "") == 0 ? 0 : dAtoi(s); + return dStrcmp(s, "") == 0 ? 0 : dIsdigit(*s) ? dAtoi(s) : s == StringTable->EmptyString() ? 0 : 1; return dAtoi(getConsoleData()); } diff --git a/Engine/source/console/torquescript/CMDscan.cpp b/Engine/source/console/torquescript/CMDscan.cpp index 4497cb961..b533658f0 100644 --- a/Engine/source/console/torquescript/CMDscan.cpp +++ b/Engine/source/console/torquescript/CMDscan.cpp @@ -2827,6 +2827,18 @@ static int Sc_ScanString(int ret) if(!collapseEscape(CMDtext+1)) return -1; + const char* scannedStr = CMDtext + 1; + + if (dStrcmp(scannedStr, "true") == 0) { + CMDlval.i = MakeToken(1, yylineno); + return INTCONST; + } + + if (dStrcmp(scannedStr, "false") == 0) { + CMDlval.i = MakeToken(0, yylineno); + return INTCONST; + } + dsize_t bufferLen = dStrlen( CMDtext ); char* buffer = ( char* ) consoleAlloc( bufferLen ); dStrcpy( buffer, CMDtext + 1, bufferLen ); diff --git a/Engine/source/console/torquescript/CMDscan.l b/Engine/source/console/torquescript/CMDscan.l index aa3a72733..88246a3b5 100644 --- a/Engine/source/console/torquescript/CMDscan.l +++ b/Engine/source/console/torquescript/CMDscan.l @@ -377,6 +377,18 @@ static int Sc_ScanString(int ret) if(!collapseEscape(CMDtext+1)) return -1; + const char* scannedStr = CMDtext + 1; + + if (dStrcmp(scannedStr, "true") == 0) { + CMDlval.i = MakeToken(1, yylineno); + return INTCONST; + } + + if (dStrcmp(scannedStr, "false") == 0) { + CMDlval.i = MakeToken(0, yylineno); + return INTCONST; + } + dsize_t bufferLen = dStrlen( CMDtext ); char* buffer = ( char* ) consoleAlloc( bufferLen ); dStrcpy( buffer, CMDtext + 1, bufferLen ); diff --git a/Engine/source/console/torquescript/astNodes.cpp b/Engine/source/console/torquescript/astNodes.cpp index cc911477d..173f9ab53 100644 --- a/Engine/source/console/torquescript/astNodes.cpp +++ b/Engine/source/console/torquescript/astNodes.cpp @@ -200,7 +200,9 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip) U32 endifIp, elseIp; addBreakLine(codeStream); - if (testExpr->getPreferredType() == TypeReqUInt) + TypeReq testType = testExpr->getPreferredType(); + + if (testType == TypeReqUInt) { integer = true; } @@ -209,8 +211,16 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip) integer = false; } - ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat); - codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT); + if (testType == TypeReqString) + { + ip = testExpr->compile(codeStream, ip, TypeReqString); + codeStream.emit(OP_JMPIFNOT); + } + else + { + ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat); + codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT); + } if (elseBlock) { diff --git a/Engine/source/console/torquescript/compiledEval.cpp b/Engine/source/console/torquescript/compiledEval.cpp index 3d765c470..337c71354 100644 --- a/Engine/source/console/torquescript/compiledEval.cpp +++ b/Engine/source/console/torquescript/compiledEval.cpp @@ -1144,6 +1144,7 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi ip++; break; } + ip = code[ip]; break; case OP_JMPIFF: From d6a79e4f5ba0930cf1c5e49d0aaeec0526c429aa Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sun, 16 Jun 2024 20:01:47 +0100 Subject: [PATCH 20/25] if statement treat "true" as a bool in getInt check (inside if statements for strings) no longer convert all "true" and "false" to ints --- Engine/source/console/console.h | 12 +++++++++++- Engine/source/console/torquescript/CMDscan.cpp | 12 ------------ Engine/source/console/torquescript/CMDscan.l | 12 ------------ 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index 8ac3f2f4c..279f0dffc 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -245,7 +245,17 @@ public: if (type == ConsoleValueType::cvSTEntry) return s == StringTable->EmptyString() ? 0 : dAtoi(s); if (type == ConsoleValueType::cvString) - return dStrcmp(s, "") == 0 ? 0 : dIsdigit(*s) ? dAtoi(s) : s == StringTable->EmptyString() ? 0 : 1; + { + if (dStrcmp(s, "false") == 0) { + return 0; + } + else if (dStrcmp(s, "true") == 0) { + return 1; + } + + return dIsdigit(*s) ? dAtoi(s) : s == StringTable->EmptyString() ? 0 : 1; + } + return dAtoi(getConsoleData()); } diff --git a/Engine/source/console/torquescript/CMDscan.cpp b/Engine/source/console/torquescript/CMDscan.cpp index b533658f0..4497cb961 100644 --- a/Engine/source/console/torquescript/CMDscan.cpp +++ b/Engine/source/console/torquescript/CMDscan.cpp @@ -2827,18 +2827,6 @@ static int Sc_ScanString(int ret) if(!collapseEscape(CMDtext+1)) return -1; - const char* scannedStr = CMDtext + 1; - - if (dStrcmp(scannedStr, "true") == 0) { - CMDlval.i = MakeToken(1, yylineno); - return INTCONST; - } - - if (dStrcmp(scannedStr, "false") == 0) { - CMDlval.i = MakeToken(0, yylineno); - return INTCONST; - } - dsize_t bufferLen = dStrlen( CMDtext ); char* buffer = ( char* ) consoleAlloc( bufferLen ); dStrcpy( buffer, CMDtext + 1, bufferLen ); diff --git a/Engine/source/console/torquescript/CMDscan.l b/Engine/source/console/torquescript/CMDscan.l index 88246a3b5..aa3a72733 100644 --- a/Engine/source/console/torquescript/CMDscan.l +++ b/Engine/source/console/torquescript/CMDscan.l @@ -377,18 +377,6 @@ static int Sc_ScanString(int ret) if(!collapseEscape(CMDtext+1)) return -1; - const char* scannedStr = CMDtext + 1; - - if (dStrcmp(scannedStr, "true") == 0) { - CMDlval.i = MakeToken(1, yylineno); - return INTCONST; - } - - if (dStrcmp(scannedStr, "false") == 0) { - CMDlval.i = MakeToken(0, yylineno); - return INTCONST; - } - dsize_t bufferLen = dStrlen( CMDtext ); char* buffer = ( char* ) consoleAlloc( bufferLen ); dStrcpy( buffer, CMDtext + 1, bufferLen ); From d8411b4a58b94dbbec86323821c30ff7c7479eb9 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sun, 16 Jun 2024 20:02:57 +0100 Subject: [PATCH 21/25] Update console.h case insensitive --- Engine/source/console/console.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index 279f0dffc..07c57d1b5 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -246,10 +246,10 @@ public: return s == StringTable->EmptyString() ? 0 : dAtoi(s); if (type == ConsoleValueType::cvString) { - if (dStrcmp(s, "false") == 0) { + if (dStricmp(s, "false") == 0) { return 0; } - else if (dStrcmp(s, "true") == 0) { + else if (dStricmp(s, "true") == 0) { return 1; } From 0d4c335231ef67ef86ed41178660ca27b8c99040 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sun, 16 Jun 2024 23:05:42 +0100 Subject: [PATCH 22/25] test working test without scanstring changes --- Engine/source/console/console.h | 11 +---------- Engine/source/console/torquescript/astNodes.cpp | 4 ++-- Engine/source/console/torquescript/compiledEval.cpp | 8 ++++++++ Engine/source/console/torquescript/compiler.h | 1 + 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index 07c57d1b5..b3163e5c5 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -245,16 +245,7 @@ public: if (type == ConsoleValueType::cvSTEntry) return s == StringTable->EmptyString() ? 0 : dAtoi(s); if (type == ConsoleValueType::cvString) - { - if (dStricmp(s, "false") == 0) { - return 0; - } - else if (dStricmp(s, "true") == 0) { - return 1; - } - - return dIsdigit(*s) ? dAtoi(s) : s == StringTable->EmptyString() ? 0 : 1; - } + return dStrcmp(s, "") == 0 ? 0 : dAtoi(s); return dAtoi(getConsoleData()); } diff --git a/Engine/source/console/torquescript/astNodes.cpp b/Engine/source/console/torquescript/astNodes.cpp index 173f9ab53..00e2d2d67 100644 --- a/Engine/source/console/torquescript/astNodes.cpp +++ b/Engine/source/console/torquescript/astNodes.cpp @@ -211,10 +211,10 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip) integer = false; } - if (testType == TypeReqString) + if (testType == TypeReqString || testType == TypeReqNone) { ip = testExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_JMPIFNOT); + codeStream.emit(OP_JMPSTRING); } else { diff --git a/Engine/source/console/torquescript/compiledEval.cpp b/Engine/source/console/torquescript/compiledEval.cpp index 337c71354..73a972c96 100644 --- a/Engine/source/console/torquescript/compiledEval.cpp +++ b/Engine/source/console/torquescript/compiledEval.cpp @@ -1163,6 +1163,14 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi } ip = code[ip]; break; + case OP_JMPSTRING: + if (stack[_STK--].getBool()) + { + ip++; + break; + } + ip = code[ip]; + break; case OP_JMPIFNOT_NP: if (stack[_STK].getInt()) { diff --git a/Engine/source/console/torquescript/compiler.h b/Engine/source/console/torquescript/compiler.h index e1cfbbed9..8d271e7fb 100644 --- a/Engine/source/console/torquescript/compiler.h +++ b/Engine/source/console/torquescript/compiler.h @@ -64,6 +64,7 @@ namespace Compiler OP_JMPIFNOT, OP_JMPIFF, OP_JMPIF, + OP_JMPSTRING, OP_JMPIFNOT_NP, OP_JMPIF_NP, // 10 OP_JMP, From 54d0da6690cc1c803fdf00cc328eeb7952f8cef0 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 18 Jun 2024 15:10:24 +0100 Subject: [PATCH 23/25] Update stringFunctions.h changes to dAtob from az --- Engine/source/core/strings/stringFunctions.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Engine/source/core/strings/stringFunctions.h b/Engine/source/core/strings/stringFunctions.h index d0c91b734..d1556f7a6 100644 --- a/Engine/source/core/strings/stringFunctions.h +++ b/Engine/source/core/strings/stringFunctions.h @@ -259,9 +259,23 @@ extern S32 dStrcmp(const UTF16 *str1, const UTF16 *str2); extern S32 dStrnatcmp( const char* str1, const char* str2 ); extern S32 dStrnatcasecmp( const char* str1, const char* str2 ); -inline bool dAtob(const char *str) +inline bool dAtob(const char* str) { - return !dStricmp(str, "true") || dAtof(str); + if (str && str[0] != '\0') + { + if (dStricmp(str, "0") == 0) + return false; + if (dStricmp(str, "0.0") == 0) + return false; + if (dStricmp(str, "0.0f") == 0) + return false; + if (dStricmp(str, "null") == 0) + return false; + if (dStricmp(str, "false") == 0) + return false; + return true; + } + return false; } bool dStrEqual(const char* str1, const char* str2); From fed83cdb8f51048186e679e00648d86d1180024b Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 18 Jun 2024 15:15:25 +0100 Subject: [PATCH 24/25] naming change enum to OP_JMPIFNOTSTRING (same name as others doing similar for different types) place case with other ifnot statements --- .../source/console/torquescript/compiledEval.cpp | 16 ++++++++-------- Engine/source/console/torquescript/compiler.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Engine/source/console/torquescript/compiledEval.cpp b/Engine/source/console/torquescript/compiledEval.cpp index 73a972c96..94ddcab80 100644 --- a/Engine/source/console/torquescript/compiledEval.cpp +++ b/Engine/source/console/torquescript/compiledEval.cpp @@ -1145,6 +1145,14 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi break; } + ip = code[ip]; + break; + case OP_JMPNOTSTRING: + if (stack[_STK--].getBool()) + { + ip++; + break; + } ip = code[ip]; break; case OP_JMPIFF: @@ -1163,14 +1171,6 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi } ip = code[ip]; break; - case OP_JMPSTRING: - if (stack[_STK--].getBool()) - { - ip++; - break; - } - ip = code[ip]; - break; case OP_JMPIFNOT_NP: if (stack[_STK].getInt()) { diff --git a/Engine/source/console/torquescript/compiler.h b/Engine/source/console/torquescript/compiler.h index 8d271e7fb..74737c773 100644 --- a/Engine/source/console/torquescript/compiler.h +++ b/Engine/source/console/torquescript/compiler.h @@ -62,9 +62,9 @@ namespace Compiler OP_JMPIFFNOT, OP_JMPIFNOT, + OP_JMPNOTSTRING, OP_JMPIFF, OP_JMPIF, - OP_JMPSTRING, OP_JMPIFNOT_NP, OP_JMPIF_NP, // 10 OP_JMP, From b0181cc56a9a7158c34a7deb7a6b01d9441410fc Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 18 Jun 2024 15:23:52 +0100 Subject: [PATCH 25/25] Update astNodes.cpp missed naming --- Engine/source/console/torquescript/astNodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/console/torquescript/astNodes.cpp b/Engine/source/console/torquescript/astNodes.cpp index 00e2d2d67..17d96c961 100644 --- a/Engine/source/console/torquescript/astNodes.cpp +++ b/Engine/source/console/torquescript/astNodes.cpp @@ -214,7 +214,7 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip) if (testType == TypeReqString || testType == TypeReqNone) { ip = testExpr->compile(codeStream, ip, TypeReqString); - codeStream.emit(OP_JMPSTRING); + codeStream.emit(OP_JMPNOTSTRING); } else {