Various fixes

This commit is contained in:
Jack Andersen 2017-12-09 19:30:01 -10:00
parent 5e03278eff
commit 8901ac2150
16 changed files with 179 additions and 141 deletions

View File

@ -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;

View File

@ -741,7 +741,7 @@ void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo& mwInfo, const IWorld
std::vector<zeus::CVector2f> coords;
coords.reserve(x0_areas.size() * 8);
float zMin = FLT_MAX;
float zMax = FLT_MIN;
float zMax = -FLT_MAX;
for (int i=0 ; i<x0_areas.size() ; ++i)
{
if (IsMapAreaValid(wld, i, true))

View File

@ -17,6 +17,8 @@ static bool BoxLineTest(const zeus::CAABox& aabb, const zeus::CLine& line, float
const float* aabbMax = &aabb.max.x;
const float* lorigin = &line.origin.x;
const float* ldir = &line.dir.x;
lT = -FLT_MAX;
hT = FLT_MAX;
for (int i=0 ; i<3 ; ++i)
{
@ -27,16 +29,16 @@ static bool BoxLineTest(const zeus::CAABox& aabb, const zeus::CLine& line, float
if (*ldir < 0.f)
{
if (*aabbMax - *lorigin < lT * *ldir)
lT = *aabbMax - *lorigin * 1.f / *ldir;
lT = (*aabbMax - *lorigin) * 1.f / *ldir;
if (*aabbMin - *lorigin > 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;

View File

@ -381,11 +381,13 @@ 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())
if (dynamicRes.IsValid())
{
if (staticRes.IsInvalid())
return dynamicRes;
else if (staticRes.GetT() >= dynamicRes.GetT())
return dynamicRes;
else
}
return staticRes;
}

View File

@ -26,7 +26,9 @@ enum EExtendedShader : uint8_t
SolidColorBackfaceCullLEqualAlphaOnly,
SolidColorBackfaceCullGreaterAlphaOnly, // No Z-write
MorphBallShadow,
WorldShadow
WorldShadow,
ForcedAlphaNoCull,
ForcedAdditiveNoCull
};
class CModelShaders

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<CBooModel&>(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();
}

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -2235,7 +2235,7 @@ void CPlayer::UpdateStepCameraZBias(float dt)
{
if (delta < -GetStepDownHeight())
newDelta += -delta - GetStepDownHeight();
newBias = x9cc_stepCameraZBias + newDelta;
newBias = x9cc_stepCameraZBias - newDelta;
}
}
}

View File

@ -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)
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_ = 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));
}
}

View File

@ -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;

2
hecl

@ -1 +1 @@
Subproject commit 914545051e9be680ea6bd85c0143f3fbd5f3ebf9
Subproject commit 3650eccc26d5d245cb964a3d16e2a9905de82fa7