From 8901ac215015f1de771209b2d7836d6846095714 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 9 Dec 2017 19:30:01 -1000 Subject: [PATCH] Various fixes --- DataSpec/DNAMP1/MREA.cpp | 2 +- Runtime/AutoMapper/CMapWorld.cpp | 2 +- Runtime/Collision/CAreaOctTree.cpp | 10 +- Runtime/Collision/CGameCollision.cpp | 14 +- Runtime/Graphics/Shaders/CModelShaders.hpp | 4 +- .../Graphics/Shaders/CModelShadersGLSL.cpp | 36 +++-- .../Graphics/Shaders/CModelShadersHLSL.cpp | 36 +++-- .../Graphics/Shaders/CModelShadersMetal.cpp | 36 +++-- Runtime/GuiSys/CGuiModel.cpp | 16 +-- Runtime/Particle/CElementGen.cpp | 2 +- Runtime/Particle/CParticleSwoosh.cpp | 2 +- Runtime/World/CActor.cpp | 1 - Runtime/World/CPlayer.cpp | 4 +- Runtime/World/CPlayerCameraBob.cpp | 128 +++++++++--------- Runtime/World/CPlayerCameraBob.hpp | 25 ++-- hecl | 2 +- 16 files changed, 179 insertions(+), 141 deletions(-) diff --git a/DataSpec/DNAMP1/MREA.cpp b/DataSpec/DNAMP1/MREA.cpp index cee21176b..23b980fe2 100644 --- a/DataSpec/DNAMP1/MREA.cpp +++ b/DataSpec/DNAMP1/MREA.cpp @@ -811,7 +811,7 @@ bool MREA::CookPath(const hecl::ProjectPath& outPath, PATH::UnknownStruct& s = path.unkStructs.back(); s.unk1 = 1; s.unk2[0] = atVec3f{FLT_MAX, FLT_MAX, FLT_MAX}; - s.unk2[1] = atVec3f{FLT_MIN, FLT_MIN, FLT_MIN}; + s.unk2[1] = atVec3f{-FLT_MAX, -FLT_MAX, -FLT_MAX}; s.unk2[2] = atVec3f{0.f, 0.f, 0.f}; for (int i=0 ; i<8 ; ++i) s.unk3[i] = ~0; diff --git a/Runtime/AutoMapper/CMapWorld.cpp b/Runtime/AutoMapper/CMapWorld.cpp index 2a27b6a43..070de1d4a 100644 --- a/Runtime/AutoMapper/CMapWorld.cpp +++ b/Runtime/AutoMapper/CMapWorld.cpp @@ -741,7 +741,7 @@ void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld std::vector coords; coords.reserve(x0_areas.size() * 8); float zMin = FLT_MAX; - float zMax = FLT_MIN; + float zMax = -FLT_MAX; for (int i=0 ; i hT * *ldir) - hT = *aabbMin - *lorigin * 1.f / *ldir; + hT = (*aabbMin - *lorigin) * 1.f / *ldir; } else { if (*aabbMin - *lorigin > lT * *ldir) - lT = *aabbMin - *lorigin * 1.f / *ldir; + lT = (*aabbMin - *lorigin) * 1.f / *ldir; if (*aabbMax - *lorigin < hT * *ldir) - hT = *aabbMax - *lorigin * 1.f / *ldir; + hT = (*aabbMax - *lorigin) * 1.f / *ldir; } ++aabbMin; diff --git a/Runtime/Collision/CGameCollision.cpp b/Runtime/Collision/CGameCollision.cpp index 2ec04d654..aa7885b1b 100644 --- a/Runtime/Collision/CGameCollision.cpp +++ b/Runtime/Collision/CGameCollision.cpp @@ -381,12 +381,14 @@ CGameCollision::RayWorldIntersection(const CStateManager& mgr, TUniqueId& idOut, CRayCastResult staticRes = RayStaticIntersection(mgr, pos, dir, mag, filter); CRayCastResult dynamicRes = RayDynamicIntersection(mgr, idOut, pos, dir, mag, filter, nearList); - if (!dynamicRes.IsInvalid() && staticRes.IsInvalid()) - return dynamicRes; - else if (staticRes.GetT() >= dynamicRes.GetT()) - return dynamicRes; - else - return staticRes; + if (dynamicRes.IsValid()) + { + if (staticRes.IsInvalid()) + return dynamicRes; + else if (staticRes.GetT() >= dynamicRes.GetT()) + return dynamicRes; + } + return staticRes; } bool CGameCollision::RayStaticIntersectionArea(const CGameArea& area, const zeus::CVector3f& pos, diff --git a/Runtime/Graphics/Shaders/CModelShaders.hpp b/Runtime/Graphics/Shaders/CModelShaders.hpp index 66f683197..fbfd1e1a8 100644 --- a/Runtime/Graphics/Shaders/CModelShaders.hpp +++ b/Runtime/Graphics/Shaders/CModelShaders.hpp @@ -26,7 +26,9 @@ enum EExtendedShader : uint8_t SolidColorBackfaceCullLEqualAlphaOnly, SolidColorBackfaceCullGreaterAlphaOnly, // No Z-write MorphBallShadow, - WorldShadow + WorldShadow, + ForcedAlphaNoCull, + ForcedAdditiveNoCull }; class CModelShaders diff --git a/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp b/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp index a29e2675d..b13555de7 100644 --- a/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersGLSL.cpp @@ -186,61 +186,61 @@ CModelShaders::GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat) ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Thermal Visor shading */ ext.registerExtensionSlot({}, {ThermalPostGLSL, "ThermalPostFunc"}, 3, ThermalBlockNames, 1, ThermalTextures, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Forced alpha shading */ ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Forced additive shading */ ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, - false, true, false, true); + hecl::Backend::CullMode::Backface, true, false, true); /* Solid color */ ext.registerExtensionSlot({}, {SolidPostGLSL, "SolidPostFunc"}, 3, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::LEqual, - false, false, false, false); + hecl::Backend::CullMode::Backface, false, false, false); /* Solid color additive */ ext.registerExtensionSlot({}, {SolidPostGLSL, "SolidPostFunc"}, 3, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual, - false, true, false, true); + hecl::Backend::CullMode::Backface, true, false, true); /* Alpha-only Solid color frontface cull, LEqual */ ext.registerExtensionSlot({}, {SolidPostGLSL, "SolidPostFunc"}, 3, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual, - true, false, true, false); + hecl::Backend::CullMode::Frontface, false, true, false); /* Alpha-only Solid color frontface cull, Always, No Z-write */ ext.registerExtensionSlot({}, {SolidPostGLSL, "SolidPostFunc"}, 3, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::None, - true, true, true, false); + hecl::Backend::CullMode::Frontface, true, true, false); /* Alpha-only Solid color backface cull, LEqual */ ext.registerExtensionSlot({}, {SolidPostGLSL, "SolidPostFunc"}, 3, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual, - false, false, true, false); + hecl::Backend::CullMode::Backface, false, true, false); /* Alpha-only Solid color backface cull, Greater, No Z-write */ ext.registerExtensionSlot({}, {SolidPostGLSL, "SolidPostFunc"}, 3, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Greater, - false, true, true, false); + hecl::Backend::CullMode::Backface, true, true, false); /* MorphBall shadow shading */ ext.registerExtensionSlot({}, {MBShadowPostGLSL, "MBShadowPostFunc"}, @@ -248,13 +248,25 @@ CModelShaders::GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat) hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Equal, - false, false, false, true, true); + hecl::Backend::CullMode::Backface, false, false, true, true); /* World shadow shading (modified lighting) */ ext.registerExtensionSlot({LightingShadowGLSL, "LightingShadowFunc"}, {MainPostGLSL, "MainPostFunc"}, 3, BlockNames, 1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); + + /* Forced alpha shading without culling */ + ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, + 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Original, + hecl::Backend::CullMode::None, false, false, true); + + /* Forced additive shading without culling */ + ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"}, + 3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, + hecl::Backend::CullMode::None, true, false, true); return ext; } diff --git a/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp b/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp index 5526f7d0f..a87ee6a03 100644 --- a/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersHLSL.cpp @@ -169,61 +169,61 @@ CModelShaders::GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat) ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {MainPostHLSL, "MainPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Thermal Visor shading */ ext.registerExtensionSlot({}, {ThermalPostHLSL, "ThermalPostFunc"}, 0, nullptr, 1, ThermalTextures, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Forced alpha shading */ ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {MainPostHLSL, "MainPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Forced additive shading */ ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {MainPostHLSL, "MainPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, - false, true, false, true); + hecl::Backend::CullMode::Backface, true, false, true); /* Solid color */ ext.registerExtensionSlot({}, {SolidPostHLSL, "SolidPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::LEqual, - false, false, false, false); + hecl::Backend::CullMode::Backface, false, false, false); /* Solid color additive */ ext.registerExtensionSlot({}, {SolidPostHLSL, "SolidPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual, - false, true, false, true); + hecl::Backend::CullMode::Backface, true, false, true); /* Alpha-only Solid color frontface cull, LEqual */ ext.registerExtensionSlot({}, {SolidPostHLSL, "SolidPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::LEqual, - true, false, true, false); + hecl::Backend::CullMode::Frontface, false, true, false); /* Alpha-only Solid color frontface cull, Always, No Z-write */ ext.registerExtensionSlot({}, {SolidPostHLSL, "SolidPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::None, - true, true, true, false); + hecl::Backend::CullMode::Frontface, true, true, false); /* Alpha-only Solid color backface cull, LEqual */ ext.registerExtensionSlot({}, {SolidPostHLSL, "SolidPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::LEqual, - false, false, true, false); + hecl::Backend::CullMode::Backface, false, true, false); /* Alpha-only Solid color backface cull, Greater, No Z-write */ ext.registerExtensionSlot({}, {SolidPostHLSL, "SolidPostFunc"}, 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::Greater, - false, true, true, false); + hecl::Backend::CullMode::Backface, true, true, false); /* MorphBall shadow shading */ ext.registerExtensionSlot({}, {MBShadowPostHLSL, "MBShadowPostFunc"}, @@ -231,13 +231,25 @@ CModelShaders::GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat) hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Equal, - false, false, false, true, true); + hecl::Backend::CullMode::Backface, false, false, true, true); /* World shadow shading (modified lighting) */ ext.registerExtensionSlot({LightingShadowHLSL, "LightingShadowFunc"}, {MainPostHLSL, "MainPostFunc"}, 0, nullptr, 1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); + + /* Forced alpha shading without culling */ + ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {MainPostHLSL, "MainPostFunc"}, + 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Original, + hecl::Backend::CullMode::None, false, false, true); + + /* Forced additive shading without culling */ + ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {MainPostHLSL, "MainPostFunc"}, + 0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, + hecl::Backend::CullMode::None, true, false, true); return ext; } diff --git a/Runtime/Graphics/Shaders/CModelShadersMetal.cpp b/Runtime/Graphics/Shaders/CModelShadersMetal.cpp index dbd2baba5..7bb1884f4 100644 --- a/Runtime/Graphics/Shaders/CModelShadersMetal.cpp +++ b/Runtime/Graphics/Shaders/CModelShadersMetal.cpp @@ -176,61 +176,61 @@ CModelShaders::GetShaderExtensionsMetal(boo::IGraphicsDataFactory::Platform plat ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Thermal Visor shading */ ext.registerExtensionSlot({}, {ThermalPostMetal, "EXTThermalPostFunc"}, 1, ThermalBlockNames, 1, ThermalTextures, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Forced alpha shading */ ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); /* Forced additive shading */ ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, - false, true, false, true); + hecl::Backend::CullMode::Backface, true, false, true); /* Solid color */ ext.registerExtensionSlot({}, {SolidPostMetal, "SolidPostFunc"}, 1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::One, hecl::Backend::BlendFactor::Zero, hecl::Backend::ZTest::LEqual, - false, false, false, false); + hecl::Backend::CullMode::Backface, false, false, false); /* Solid color additive */ ext.registerExtensionSlot({}, {SolidPostMetal, "SolidPostFunc"}, 1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual, - false, true, false, true); + hecl::Backend::CullMode::Backface, true, false, true); /* Alpha-only Solid color frontface cull, LEqual */ ext.registerExtensionSlot({}, {SolidPostMetal, "SolidPostFunc"}, 1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual, - true, false, true, false); + hecl::Backend::CullMode::Frontface, false, true, false); /* Alpha-only Solid color frontface cull, Always, No Z-write */ ext.registerExtensionSlot({}, {SolidPostMetal, "SolidPostFunc"}, 1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::None, - true, true, true, false); + hecl::Backend::CullMode::Frontface, true, true, false); /* Alpha-only Solid color backface cull, LEqual */ ext.registerExtensionSlot({}, {SolidPostMetal, "SolidPostFunc"}, 1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::LEqual, - false, false, true, false); + hecl::Backend::CullMode::Backface, false, true, false); /* Alpha-only Solid color backface cull, Greater, No Z-write */ ext.registerExtensionSlot({}, {SolidPostMetal, "SolidPostFunc"}, 1, SolidBlockNames, 0, nullptr, hecl::Backend::BlendFactor::Zero, hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Greater, - false, true, true, false); + hecl::Backend::CullMode::Backface, true, true, false); /* MorphBall shadow shading */ ext.registerExtensionSlot({}, {MBShadowPostMetal, "EXTMBShadowPostFunc"}, @@ -238,13 +238,25 @@ CModelShaders::GetShaderExtensionsMetal(boo::IGraphicsDataFactory::Platform plat hecl::Backend::BlendFactor::SrcAlpha, hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Equal, - false, false, false, true, true); + hecl::Backend::CullMode::Backface, false, false, true, true); /* World shadow shading (modified lighting) */ ext.registerExtensionSlot({LightingShadowMetal, "EXTLightingShadowFunc"}, {MainPostMetal, "MainPostFunc"}, 1, BlockNames, 1, WorldShadowTextures, hecl::Backend::BlendFactor::Original, hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::Original, - false, false, false, true); + hecl::Backend::CullMode::Backface, false, false, true); + + /* Forced alpha shading without culling */ + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::InvSrcAlpha, hecl::Backend::ZTest::Original, + hecl::Backend::CullMode::None, false, false, true); + + /* Forced additive shading without culling */ + ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"}, + 1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::SrcAlpha, + hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original, + hecl::Backend::CullMode::None, true, false, true); return ext; } diff --git a/Runtime/GuiSys/CGuiModel.cpp b/Runtime/GuiSys/CGuiModel.cpp index e2d337e5a..d28375483 100644 --- a/Runtime/GuiSys/CGuiModel.cpp +++ b/Runtime/GuiSys/CGuiModel.cpp @@ -57,8 +57,8 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const zeus::CColor moduCol = xa8_color2; moduCol.a *= parms.x0_alphaMod; xb0_frame->EnableLights(x10c_lightMask, const_cast(model->GetInstance())); - if (xb6_29_cullFaces) - CGraphics::SetCullMode(ERglCullMode::Front); + //if (xb6_29_cullFaces) + // CGraphics::SetCullMode(ERglCullMode::Front); switch (xac_drawFlags) { @@ -79,36 +79,36 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const case EGuiModelDrawFlags::Alpha: { CModelFlags flags(4, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol); - flags.m_extendedShader = EExtendedShader::ForcedAlpha; + flags.m_extendedShader = xb6_29_cullFaces ? EExtendedShader::ForcedAlpha : EExtendedShader::ForcedAlphaNoCull; model->Draw(flags); break; } case EGuiModelDrawFlags::Additive: { CModelFlags flags(3, 0, (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest), moduCol); - flags.m_extendedShader = EExtendedShader::ForcedAdditive; + flags.m_extendedShader = xb6_29_cullFaces ? EExtendedShader::ForcedAdditive : EExtendedShader::ForcedAdditiveNoCull; model->Draw(flags); break; } case EGuiModelDrawFlags::AlphaAdditiveOverdraw: { CModelFlags flags(4, 0, xb6_31_depthTest, moduCol); - flags.m_extendedShader = EExtendedShader::ForcedAlpha; + flags.m_extendedShader = xb6_29_cullFaces ? EExtendedShader::ForcedAlpha : EExtendedShader::ForcedAlphaNoCull; model->Draw(flags); flags.x0_blendMode = 5; flags.x1_matSetIdx = 0; flags.x2_flags = (u32(xb7_24_depthWrite) << 1) | u32(xb6_31_depthTest); flags.x4_color = moduCol; - flags.m_extendedShader = EExtendedShader::ForcedAdditive; + flags.m_extendedShader = xb6_29_cullFaces ? EExtendedShader::ForcedAdditive : EExtendedShader::ForcedAdditiveNoCull; model->Draw(flags); break; } default: break; } - if (xb6_29_cullFaces) - CGraphics::SetCullMode(ERglCullMode::None); + //if (xb6_29_cullFaces) + // CGraphics::SetCullMode(ERglCullMode::None); xb0_frame->DisableLights(); } diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index 5f8b18882..11673c500 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -336,7 +336,7 @@ bool CElementGen::InternalUpdate(double dt) while (t < x78_curSeconds && std::fabs(t - x78_curSeconds) >= 1.0 / 60000.0) { x2d4_aabbMin.splat(FLT_MAX); - x2e0_aabbMax.splat(FLT_MIN); + x2e0_aabbMax.splat(-FLT_MAX); x2ec_maxSize = 0.f; CParticleGlobals::SetEmitterTime(x74_curFrame); UpdateExistingParticles(); diff --git a/Runtime/Particle/CParticleSwoosh.cpp b/Runtime/Particle/CParticleSwoosh.cpp index 7732d8c88..696c2ef5d 100644 --- a/Runtime/Particle/CParticleSwoosh.cpp +++ b/Runtime/Particle/CParticleSwoosh.cpp @@ -125,7 +125,7 @@ void CParticleSwoosh::UpdateTranslationAndOrientation() { x208_maxRadius = 0.f; x1f0_aabbMin = FLT_MAX; - x1fc_aabbMax = FLT_MIN; + x1fc_aabbMax = -FLT_MAX; CParticleGlobals::SetParticleLifetime(x1b4_LENG); CParticleGlobals::SetEmitterTime(x28_curFrame); diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index c9aa46824..269ac2885 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -323,7 +323,6 @@ void CActor::SetRotation(const zeus::CQuaternion &q) void CActor::SetTranslation(const zeus::CVector3f& tr) { - auto old = x34_transform.origin; x34_transform.origin = tr; xe4_27_notInSortedLists = true; xe4_28_ = true; diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index c20f7f741..a6eba8810 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -2235,7 +2235,7 @@ void CPlayer::UpdateStepCameraZBias(float dt) { if (delta < -GetStepDownHeight()) newDelta += -delta - GetStepDownHeight(); - newBias = x9cc_stepCameraZBias + newDelta; + newBias = x9cc_stepCameraZBias - newDelta; } } } @@ -3000,7 +3000,7 @@ void CPlayer::UpdateFootstepSounds(const CFinalInput& input, CStateManager& mgr, if (x790_footstepSfxSel != EFootstepSfx::None && x78c_footstepSfxTimer > sfxDelay) { static float EarHeight = GetEyeHeight() - 0.1f; - if (xe6_24_fluidCounter != 0 && x828_distanceUnderWater > 0.f && x828_distanceUnderWater < EarHeight) + if (xe6_24_fluidCounter != 0 && x828_distanceUnderWater > 0.f && x828_distanceUnderWater < EarHeight) { if (x82c_inLava) { diff --git a/Runtime/World/CPlayerCameraBob.cpp b/Runtime/World/CPlayerCameraBob.cpp index 8bdf54abc..1487dfe9a 100644 --- a/Runtime/World/CPlayerCameraBob.cpp +++ b/Runtime/World/CPlayerCameraBob.cpp @@ -15,16 +15,19 @@ float CPlayerCameraBob::kMaxOrbitBobScale = 0.8f; float CPlayerCameraBob::kSlowSpeedPeriodScale = 0.3f; float CPlayerCameraBob::kTargetMagnitudeTrackingRate = 0.1f; float CPlayerCameraBob::kLandingBobSpringConstant = 150.f; +float CPlayerCameraBob::kLandingBobSpringConstant2 = 40.f; float CPlayerCameraBob::kViewWanderRadius = 2.9f; float CPlayerCameraBob::kViewWanderSpeedMin = 0.1f; float CPlayerCameraBob::kViewWanderSpeedMax = 0.3f; float CPlayerCameraBob::kViewWanderRollVariation = 0.3f; float CPlayerCameraBob::kGunBobMagnitude = 0.3f; float CPlayerCameraBob::kHelmetBobMagnitude = 2.f; -const float CPlayerCameraBob::kLandingBobDamping = 2.f * zeus::sqrtF(150.f); +const float CPlayerCameraBob::kLandingBobDamping = 2.f * std::sqrt(150.f); +const float CPlayerCameraBob::kLandingBobDamping2 = 4.f * std::sqrt(40.f); +const float CPlayerCameraBob::kCameraDamping = 6.f * std::sqrt(80.f); -CPlayerCameraBob::CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float f1) -: x0_type(type), x4_vec(vec), xc_(f1) +CPlayerCameraBob::CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float bobPeriod) +: x0_type(type), x4_vec(vec), xc_bobPeriod(bobPeriod) { } @@ -32,10 +35,9 @@ zeus::CTransform CPlayerCameraBob::GetViewWanderTransform() const { return xd0_v zeus::CVector3f CPlayerCameraBob::GetHelmetBobTranslation() const { - return {kHelmetBobMagnitude * x2c_cameraBobTransform.origin.x, kHelmetBobMagnitude * x2c_cameraBobTransform.origin.y, - kHelmetBobMagnitude * (x2c_cameraBobTransform.origin.z - x78_)}; + kHelmetBobMagnitude * (x2c_cameraBobTransform.origin.z - x78_camTranslation)}; } zeus::CTransform CPlayerCameraBob::GetGunBobTransformation() const @@ -48,20 +50,12 @@ zeus::CTransform CPlayerCameraBob::GetCameraBobTransformation() const { return x void CPlayerCameraBob::SetPlayerVelocity(const zeus::CVector3f& velocity) { x5c_playerVelocity = velocity; - x68_ = zeus::min(x68_, velocity.z); + x68_playerPeakFallVel = zeus::min(x68_playerPeakFallVel, velocity.z); } void CPlayerCameraBob::SetBobMagnitude(float magnitude) { -#if 0 - /* Retro Original (This is why underpaid (re: unpaid) interns make crappy programmers) */ - x10_bobMagnitude = magnitude; - x10_bobMagnitude = std::max(0.f, x10_bobMagnitude); - x10_bobMagnitude = std::max(1.f, x10_bobMagnitude); -#else - /* Should fix lightshow */ - x10_bobMagnitude = zeus::clamp(0.f, magnitude, 1.f); -#endif + x10_targetBobMagnitude = zeus::clamp(0.f, magnitude, 1.f); } void CPlayerCameraBob::SetBobTimeScale(float ts) { x18_bobTimeScale = zeus::clamp(0.f, ts, 1.f); } @@ -80,18 +74,15 @@ void CPlayerCameraBob::SetState(CPlayerCameraBob::ECameraBobState state, CStateM if (x20_oldState == ECameraBobState::InAir) { x28_applyLandingTrans = true; - x68_ = std::min(x68_, -35.f); - x29_ = (x68_ >= -30.f); - if (x29_) - x74_ += x68_; - else - { - x6c_ += x68_; - x68_ = 0.f; - } + x68_playerPeakFallVel = std::max(x68_playerPeakFallVel, -35.f); + x29_hardLand = x68_playerPeakFallVel < -30.f; + if (x29_hardLand) + x74_camVelocity += x68_playerPeakFallVel; + x6c_landingVelocity += x68_playerPeakFallVel; + x68_playerPeakFallVel = 0.f; } - if (x24_curState == ECameraBobState::WalkNoBob && x100_ != 0.f) + if (x24_curState == ECameraBobState::WalkNoBob && x100_wanderMagnitude != 0.f) InitViewWander(mgr); } @@ -118,13 +109,13 @@ void CPlayerCameraBob::UpdateViewWander(float dt, CStateManager& mgr) x7c_wanderPoints[xcc_wanderIndex], x7c_wanderPoints[(xcc_wanderIndex + 1) & 3], x7c_wanderPoints[(xcc_wanderIndex + 2) & 3], x7c_wanderPoints[(xcc_wanderIndex + 3) & 3], dt); - pt.x *= x100_; - pt.z *= x100_; + pt.x *= x100_wanderMagnitude; + pt.z *= x100_wanderMagnitude; zeus::CTransform orient = zeus::CTransform::RotateY(( zeus::getCatmullRomSplinePoint(xb0_wanderPitches[xcc_wanderIndex], xb0_wanderPitches[(xcc_wanderIndex + 1) & 3], xb0_wanderPitches[(xcc_wanderIndex + 2) & 3], xb0_wanderPitches[(xcc_wanderIndex + 3) & 3], dt) * - x100_)); + x100_wanderMagnitude)); xd0_viewWanderXf = zeus::lookAt(pt, zeus::CVector3f::skZero, zeus::CVector3f::skUp) * orient; xc4_wanderTime = (xc8_viewWanderSpeed * xc4_wanderTime) + dt; @@ -141,52 +132,55 @@ void CPlayerCameraBob::UpdateViewWander(float dt, CStateManager& mgr) void CPlayerCameraBob::Update(float dt, CStateManager& mgr) { - x1c_bobTime = (dt * x18_bobTimeScale) + x1c_bobTime; - float landSpring = kLandingBobSpringConstant; - float landDampen = kLandingBobDamping; + x1c_bobTime += dt * x18_bobTimeScale; + if (x28_applyLandingTrans) { - landDampen = 4.f * zeus::sqrtF(40.f); - landSpring = 40.f; - } + float landDampen = kLandingBobDamping; + float landSpring = kLandingBobSpringConstant; + if (x29_hardLand) + { + landDampen = kLandingBobDamping2; + landSpring = kLandingBobSpringConstant2; + } - x6c_ = (dt * -((landSpring * x70_landingTranslation) + -(landDampen * x6c_))) + x6c_; - x70_landingTranslation = x6c_ * dt + x70_landingTranslation; - x74_ = dt * (-(80.f * x78_) + -((6.f * zeus::sqrtF(80.f)) * x74_)) + x74_; - x78_ = x74_ * dt + x78_; + x6c_landingVelocity += dt * (-(landDampen * x6c_landingVelocity) - landSpring * x70_landingTranslation); + x70_landingTranslation += x6c_landingVelocity * dt; + x74_camVelocity += dt * (-(kCameraDamping * x74_camVelocity) - 80.f * x78_camTranslation); + x78_camTranslation += x74_camVelocity * dt; - if (std::fabs(x6c_) < 0.0049f && std::fabs(x70_landingTranslation) < 0.0049f && std::fabs(x78_) < 0.0049f) - { - x28_applyLandingTrans = false; - x70_landingTranslation = 0.f; - x78_ = 0.f; + if (std::fabs(x6c_landingVelocity) < 0.005f && std::fabs(x70_landingTranslation) < 0.005f && + std::fabs(x74_camVelocity) < 0.005f && std::fabs(x78_camTranslation) < 0.005f) + { + x28_applyLandingTrans = false; + x70_landingTranslation = 0.f; + x78_camTranslation = 0.f; + } } if (x24_curState == ECameraBobState::WalkNoBob) - x104_ = 1.f; + x104_targetWanderMagnitude = 1.f; else - x104_ = 0.f; + x104_targetWanderMagnitude = 0.f; - float f1 = mgr.GetCameraManager()->GetCameraBobMagnitude(); - x70_landingTranslation *= f1; - x78_ *= f1; - x104_ *= f1; + float mag = mgr.GetCameraManager()->GetCameraBobMagnitude(); + x70_landingTranslation *= mag; + x78_camTranslation *= mag; + x104_targetWanderMagnitude *= mag; if (mgr.GetPlayer().x38c_doneSidewaysDashing) { x70_landingTranslation *= 0.2f; - x78_ *= 0.2f; - x104_ *= 0.4f; + x78_camTranslation *= 0.2f; + x104_targetWanderMagnitude *= 0.2f; } - x100_ = kTargetMagnitudeTrackingRate * (x104_ - x100_) + x100_; - x100_ = std::max(x100_, 0.f); - float tmp = x14_; - x14_ = kTargetMagnitudeTrackingRate * (x10_bobMagnitude - x14_) + x14_; + x100_wanderMagnitude += kTargetMagnitudeTrackingRate * (x104_targetWanderMagnitude - x100_wanderMagnitude); + x100_wanderMagnitude = std::max(x100_wanderMagnitude, 0.f); + x14_bobMagnitude += kTargetMagnitudeTrackingRate * (x10_targetBobMagnitude - x14_bobMagnitude); UpdateViewWander(dt, mgr); - x78_ = tmp; - x2c_cameraBobTransform = GetViewWanderTransform() * CalculateCameraBobTransformation() * - zeus::lookAt(zeus::CVector3f::skZero, {0.f, 2.f, x78_}, zeus::CVector3f::skUp); + x2c_cameraBobTransform = CalculateCameraBobTransformation() * GetViewWanderTransform() * + zeus::lookAt(zeus::CVector3f::skZero, {0.f, 2.f, x78_camTranslation}, zeus::CVector3f::skUp); } zeus::CVector3f CPlayerCameraBob::CalculateRandomViewWanderPosition(CStateManager& mgr) @@ -205,20 +199,20 @@ void CPlayerCameraBob::CalculateMovingTranslation(float& x, float& y) const { if (x0_type == ECameraBobType::Zero) { - double c = ((M_PIF * 2.f) * std::fmod(x1c_bobTime, 2.0f * xc_) / xc_); - x = (x14_ * x4_vec.x) * float(std::sin(c)); - y = (x14_ * x4_vec.y) * float(std::fabs(std::cos(c * .5)) * std::cos(c * .5)); + double c = ((M_PIF * 2.f) * std::fmod(x1c_bobTime, 2.0f * xc_bobPeriod) / xc_bobPeriod); + x = (x14_bobMagnitude * x4_vec.x) * float(std::sin(c)); + y = (x14_bobMagnitude * x4_vec.y) * float(std::fabs(std::cos(c * .5)) * std::cos(c * .5)); } else if (x0_type == ECameraBobType::One) { - float fX = std::fmod(x1c_bobTime, 2.f * xc_); - if (fX > xc_) - x = (2.f - (fX / xc_)) * (x14_ * x4_vec.x); + float fX = std::fmod(x1c_bobTime, 2.f * xc_bobPeriod); + if (fX > xc_bobPeriod) + x = (2.f - (fX / xc_bobPeriod)) * (x14_bobMagnitude * x4_vec.x); else - x = ((fX / xc_)) * (x14_ * x4_vec.x); + x = ((fX / xc_bobPeriod)) * (x14_bobMagnitude * x4_vec.x); - auto sY = float(std::sin(std::fmod((M_PI * fX) / xc_, M_PI))); - y = (1.f - sY) * (x14_ * x4_vec.y) * 0.5f + (0.5f * -((sY * sY) - 1.f) * (x14_ * x4_vec.y)); + auto sY = float(std::sin(std::fmod((M_PI * fX) / xc_bobPeriod, M_PI))); + y = (1.f - sY) * (x14_bobMagnitude * x4_vec.y) * 0.5f + (0.5f * -((sY * sY) - 1.f) * (x14_bobMagnitude * x4_vec.y)); } } diff --git a/Runtime/World/CPlayerCameraBob.hpp b/Runtime/World/CPlayerCameraBob.hpp index 49f2248b0..1603e824f 100644 --- a/Runtime/World/CPlayerCameraBob.hpp +++ b/Runtime/World/CPlayerCameraBob.hpp @@ -40,6 +40,7 @@ public: static float kSlowSpeedPeriodScale; static float kTargetMagnitudeTrackingRate; static float kLandingBobSpringConstant; + static float kLandingBobSpringConstant2; static float kViewWanderRadius; static float kViewWanderSpeedMin; static float kViewWanderSpeedMax; @@ -47,37 +48,39 @@ public: static float kGunBobMagnitude; static float kHelmetBobMagnitude; static const float kLandingBobDamping; + static const float kLandingBobDamping2; + static const float kCameraDamping; private: ECameraBobType x0_type; zeus::CVector2f x4_vec; - float xc_; - float x10_bobMagnitude = 0.f; - float x14_ = 0.f; + float xc_bobPeriod; + float x10_targetBobMagnitude = 0.f; + float x14_bobMagnitude = 0.f; float x18_bobTimeScale = 0.f; float x1c_bobTime = 0.f; ECameraBobState x20_oldState = ECameraBobState::Unspecified; ECameraBobState x24_curState = ECameraBobState::Unspecified; bool x28_applyLandingTrans = false; - bool x29_ = false; + bool x29_hardLand = false; zeus::CTransform x2c_cameraBobTransform; zeus::CVector3f x5c_playerVelocity; - float x68_ = 0.f; - float x6c_ = 0.f; + float x68_playerPeakFallVel = 0.f; + float x6c_landingVelocity = 0.f; float x70_landingTranslation = 0.f; - float x74_ = 0.f; - float x78_ = 0.f; + float x74_camVelocity = 0.f; + float x78_camTranslation = 0.f; zeus::CVector3f x7c_wanderPoints[4] = {zeus::CVector3f{0.f, 1.f, 0.f}}; float xb0_wanderPitches[4] = {0.f}; float xc4_wanderTime = 0.f; float xc8_viewWanderSpeed = kViewWanderSpeedMin; u32 xcc_wanderIndex = 0; zeus::CTransform xd0_viewWanderXf; - float x100_ = FLT_EPSILON; - float x104_ = 0.f; + float x100_wanderMagnitude = FLT_EPSILON; + float x104_targetWanderMagnitude = 0.f; public: - CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float); + CPlayerCameraBob(ECameraBobType type, const zeus::CVector2f& vec, float bobPeriod); zeus::CTransform GetViewWanderTransform() const; zeus::CVector3f GetHelmetBobTranslation() const; diff --git a/hecl b/hecl index 914545051..3650eccc2 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 914545051e9be680ea6bd85c0143f3fbd5f3ebf9 +Subproject commit 3650eccc26d5d245cb964a3d16e2a9905de82fa7