Various bug fixes

This commit is contained in:
Jack Andersen 2017-11-29 15:22:46 -10:00
parent 7951cb1ee0
commit 7cd3e8f502
9 changed files with 125 additions and 81 deletions

View File

@ -95,8 +95,8 @@ void CFirstPersonCamera::CalculateGunFollowOrientationAndTransform(zeus::CTransf
if (rVecNoZ.canBeNormalized())
rVecNoZ.normalize();
gunXf = zeus::CQuaternion::lookAt(rVecNoZ, gunFrontVec, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
gunXf.getRotation();
gunXf = zeus::CQuaternion::lookAt(gunFrontVec, rVecNoZ, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
x190_gunFollowXf.getRotation();
zeus::CVector3f newgunFront = gunXf.frontVector();
@ -104,9 +104,8 @@ void CFirstPersonCamera::CalculateGunFollowOrientationAndTransform(zeus::CTransf
newgunFront.normalize();
float angle = newgunFront.dot(rVec);
if (std::fabs(angle) > 0.f)
angle = (angle > -0.f ? -1.f : 1.f);
gunQ = zeus::CQuaternion::lookAt(rVec, newgunFront, zeus::clamp(0.f, std::acos(angle) / dt, 1.f));
angle = std::min(angle, 1.f);
gunQ = zeus::CQuaternion::lookAt(newgunFront, rVec, zeus::clamp(0.f, std::acos(angle) / dt, 1.f) * dt);
}
void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
@ -130,8 +129,12 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
vec.z = std::sin(angle);
vec.y = std::cos(-player->x3e4_freeLookYawAngle) * std::cos(angle);
vec.x = std::sin(-player->x3e4_freeLookYawAngle) * std::cos(angle);
if (g_tweakPlayer->GetFreeLookTurnsPlayer() && !zeus::close_enough(vec, zeus::CVector3f::skZero))
if (g_tweakPlayer->GetFreeLookTurnsPlayer())
{
vec.x = 0.f;
if (!zeus::close_enough(vec, zeus::CVector3f::skZero))
vec.normalize();
}
rVec = zeus::CQuaternion::lookAt({0.f, 1.f, 0.f}, rVec, zeus::CRelAngle::FromDegrees(360.f)).transform(vec);
}
@ -144,11 +147,13 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
player->GetCameraBob()->SetCameraBobTransform(zeus::CTransform::Identity());
}
if (player->GetOrbitState() == CPlayer::EPlayerOrbitState::ForcedOrbitObject ||
player->GetOrbitState() == CPlayer::EPlayerOrbitState::OrbitObject)
switch (player->GetOrbitState())
{
case CPlayer::EPlayerOrbitState::ForcedOrbitObject:
case CPlayer::EPlayerOrbitState::OrbitObject:
{
const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(player->x310_orbitTargetId));
if (act && act->GetMaterialList().Intersection(CMaterialList(EMaterialTypes::Lava)) != 0)
if (act && act->GetMaterialList().HasMaterial(EMaterialTypes::Orbit))
{
zeus::CVector3f v = player->x314_orbitPoint.y - eyePos;
if (v.canBeNormalized())
@ -156,9 +161,24 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
rVec = v;
}
else
{
rVec = player->x314_orbitPoint - eyePos;
}
else if (player->GetOrbitState() == CPlayer::EPlayerOrbitState::NoOrbit &&
player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed &&
break;
}
case CPlayer::EPlayerOrbitState::OrbitPoint:
case CPlayer::EPlayerOrbitState::OrbitCarcass:
{
if (!player->x3dd_lookButtonHeld)
{
rVec = player->x314_orbitPoint - eyePos;
}
break;
}
case CPlayer::EPlayerOrbitState::NoOrbit:
{
if (player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed &&
!player->x3dc_inFreeLook && x1c4_pitchId == kInvalidUniqueId)
{
if (player->x294_jumpCameraTimer > 0.f)
@ -178,13 +198,18 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
float angle = zeus::clamp(0.f, (player->x29c_fallCameraTimer - g_tweakPlayer->GetFallCameraPitchDownStart()) /
g_tweakPlayer->GetFallCameraPitchDownFull(), 1.f) *
g_tweakPlayer->GetFallCameraPitchDownAngle();
rVec.x = 0.f;
rVec.y = std::cos(angle);
rVec.z = -std::sin(angle);
//rVec.x = 0.f;
//rVec.y = std::cos(angle);
//rVec.z = -std::sin(angle);
rVec = playerXf.rotate(rVec);
//rVec = playerXf.rotate(rVec);
}
}
break;
}
default:
break;
}
if (rVec.canBeNormalized())
rVec.normalize();
@ -192,12 +217,33 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
zeus::CTransform gunXf = x190_gunFollowXf;
zeus::CQuaternion qGun = zeus::CQuaternion::skNoRotation;
if (player->x3dc_inFreeLook)
if (!player->x3dc_inFreeLook)
{
if (player->GetOrbitState() == CPlayer::EPlayerOrbitState::ForcedOrbitObject ||
player->GetOrbitState() == CPlayer::EPlayerOrbitState::OrbitObject)
switch (player->GetOrbitState())
{
zeus::CVector3f gunFrontVec = gunXf.frontVector();
default:
{
CalculateGunFollowOrientationAndTransform(gunXf, qGun,
dt * g_tweakPlayer->GetFirstPersonCameraSpeed(), rVec);
break;
}
case CPlayer::EPlayerOrbitState::Grapple:
{
CalculateGunFollowOrientationAndTransform(gunXf, qGun,
dt * g_tweakPlayer->GetGrappleCameraSpeed(), rVec);
break;
}
case CPlayer::EPlayerOrbitState::OrbitPoint:
case CPlayer::EPlayerOrbitState::OrbitCarcass:
{
CalculateGunFollowOrientationAndTransform(gunXf, qGun,
dt * g_tweakPlayer->GetOrbitCameraSpeed() * 0.25f, rVec);
break;
}
case CPlayer::EPlayerOrbitState::ForcedOrbitObject:
case CPlayer::EPlayerOrbitState::OrbitObject:
{
zeus::CVector3f gunFrontVec = x190_gunFollowXf.frontVector();
if (gunFrontVec.canBeNormalized())
gunFrontVec.normalize();
@ -206,10 +252,10 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
float angle = gunFrontVec.dot(rVec);
angle = zeus::clamp(-1.f, angle, 1.f);
float clampedAngle = zeus::clamp(0.f, std::acos(angle) / scaledDt, 1.f);
if (angle > 0.999f && x18c_lockCamera && !player->x374_orbitLockEstablished)
qGun = zeus::CQuaternion::lookAt(rVec, gunFrontVec, zeus::CRelAngle::FromDegrees(360.f));
if (angle > 0.999f || x18c_lockCamera || player->x374_orbitLockEstablished)
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVec, zeus::CRelAngle::FromDegrees(360.f));
else
qGun = zeus::CQuaternion::lookAt(rVec, gunFrontVec, scaledDt * clampedAngle);
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVec, scaledDt * clampedAngle);
const CScriptGrapplePoint* gPoint =
TCastToConstPtr<CScriptGrapplePoint>(mgr.GetObjectById(player->x310_orbitTargetId));
@ -220,53 +266,42 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
gunFrontVec.normalize();
zeus::CVector3f rVecCpy = rVec;
rVecCpy.z = 0.f;
if (rVecCpy.canBeNormalized())
rVecCpy.normalize();
gunXf =
zeus::CQuaternion::lookAt(rVecCpy, gunFrontVec, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
zeus::CQuaternion::lookAt(gunFrontVec, rVecCpy, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
x190_gunFollowXf.getRotation();
gunFrontVec = gunXf.frontVector();
if (gunFrontVec.canBeNormalized())
gunFrontVec.normalize();
float angle = gunFrontVec.dot(rVec);
float sdt = dt * g_tweakPlayer->GetGrappleCameraSpeed();
//float angle = gunFrontVec.dot(rVec);
//float sdt = dt * g_tweakPlayer->GetGrappleCameraSpeed();
angle = zeus::clamp(-1.f, angle, 1.f);
angle = zeus::clamp(0.f, std::acos(angle) / sdt, 1.f) * sdt;
qGun = zeus::CQuaternion::lookAt(rVec, gunFrontVec, angle);
//angle = zeus::clamp(-1.f, angle, 1.f);
//angle = zeus::clamp(0.f, std::acos(angle) / sdt, 1.f);
qGun = zeus::CQuaternion::lookAt(gunFrontVec, rVecCpy, zeus::CRelAngle::FromDegrees(360.f));
}
break;
}
else if (player->GetOrbitState() == CPlayer::EPlayerOrbitState::OrbitPoint ||
player->GetOrbitState() == CPlayer::EPlayerOrbitState::OrbitCarcass)
{
dt *= g_tweakPlayer->GetOrbitCameraSpeed();
CalculateGunFollowOrientationAndTransform(gunXf, qGun, dt, rVec);
}
else if (player->GetOrbitState() == CPlayer::EPlayerOrbitState::Grapple)
{
dt *= g_tweakPlayer->GetGrappleCameraSpeed();
CalculateGunFollowOrientationAndTransform(gunXf, qGun, dt, rVec);
}
else
{
dt *= g_tweakPlayer->GetFirstPersonCameraSpeed();
CalculateGunFollowOrientationAndTransform(gunXf, qGun, dt, rVec);
}
}
else
{
zeus::CVector3f gunFront = x190_gunFollowXf.frontVector();
gunFront.z = 0.f;
if (gunFront.canBeNormalized())
gunFront.normalize();
zeus::CVector3f rVecCpy = rVec;
rVecCpy.z = 0.f;
if (rVecCpy.canBeNormalized())
rVecCpy.normalize();
gunXf = zeus::CQuaternion::lookAt(rVecCpy, gunFront, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
gunXf = zeus::CQuaternion::lookAt(gunFront, rVecCpy, zeus::CRelAngle::FromDegrees(360.f)).toTransform() *
x190_gunFollowXf.getRotation();
gunFront = gunXf.frontVector();
if (gunFront.canBeNormalized())
@ -276,7 +311,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
angle = zeus::clamp(-1.f, angle, 1.f);
float sdt = dt * g_tweakPlayer->GetFreeLookSpeed();
qGun = zeus::CQuaternion::lookAt(
rVec, gunFront, sdt * zeus::clamp(0.f, g_tweakPlayer->GetFreeLookDampenFactor() *
gunFront, rVec, sdt * zeus::clamp(0.f, g_tweakPlayer->GetFreeLookDampenFactor() *
(std::acos(angle) / sdt), 1.f));
}
zeus::CTransform bobXf = player->GetCameraBob()->GetCameraBobTransformation();
@ -285,14 +320,16 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt)
player->GetOrbitState() == CPlayer::EPlayerOrbitState::Grapple ||
player->GetGrappleState() == CPlayer::EGrappleState::None ||
mgr.GetGameState() == CStateManager::EGameState::SoftPaused ||
mgr.GetCameraManager()->IsInCinematicCamera())
mgr.GetCameraManager()->IsInCinematicCamera() ||
x1d4_closeInTimer > 0.f)
{
bobXf = zeus::CTransform::Identity();
player->GetCameraBob()->SetCameraBobTransform(bobXf);
}
x190_gunFollowXf = qGun.toTransform() * gunXf;
SetTransform(x190_gunFollowXf * bobXf.getRotation());
//SetTransform(x190_gunFollowXf * bobXf.getRotation());
SetTransform(playerXf);
x190_gunFollowXf.origin = eyePos;
CActor::SetTranslation(eyePos + player->GetTransform().rotate(bobXf.origin));
x190_gunFollowXf.orthonormalize();

View File

@ -36,7 +36,7 @@ CActorLights::CActorLights(u32 areaUpdateFramePeriod, const zeus::CVector3f& act
void CActorLights::BuildConstantAmbientLighting()
{
x299_26_ = true;
x299_26_ambientOnly = true;
x298_24_dirty = true;
x29c_shadowLightArrIdx = -1;
x2a0_shadowLightIdx = -1;
@ -44,7 +44,7 @@ void CActorLights::BuildConstantAmbientLighting()
void CActorLights::BuildConstantAmbientLighting(const zeus::CColor& color)
{
x299_26_ = false;
x299_26_ambientOnly = false;
x288_ambientColor = color;
x294_aid = kInvalidAreaId;
x298_24_dirty = true;
@ -454,7 +454,7 @@ bool CActorLights::BuildAreaLightList(const CStateManager& mgr, const CGameArea&
void CActorLights::BuildDynamicLightList(const CStateManager& mgr, const zeus::CAABox& aabb)
{
UpdateBrightLight();
x299_26_ = false;
x299_26_ambientOnly = false;
x144_dynamicLights.clear();
if (!x29a_findNearestDynamicLights)
@ -506,7 +506,10 @@ void CActorLights::BuildDynamicLightList(const CStateManager& mgr, const zeus::C
std::vector<CLight> CActorLights::BuildLightVector() const
{
std::vector<CLight> lights;
lights.push_back(CLight::BuildLocalAmbient(zeus::CVector3f::skZero, x288_ambientColor));
zeus::CColor ambColor = x288_ambientColor;
ambColor.a = 1.f;
lights.push_back(CLight::BuildLocalAmbient(zeus::CVector3f::skZero, ambColor));
if (x0_areaLights.size())
{
@ -543,9 +546,10 @@ void CActorLights::ActivateLights(CBooModel& model) const
if (x298_28_inArea)
{
if (!x298_26_hasAreaLights || !x299_26_)
if (!x298_26_hasAreaLights || x299_26_ambientOnly)
{
g_Renderer->SetAmbientColor(zeus::CColor::skWhite);
//g_Renderer->SetAmbientColor(zeus::CColor::skWhite);
lights.push_back(CLight::BuildLocalAmbient(zeus::CVector3f::skZero, zeus::CColor::skWhite));
model.ActivateLights(lights);
return;
}

View File

@ -35,7 +35,7 @@ class CActorLights
bool x298_31_disableWorldLights : 1;
bool x299_24_inBrightLight : 1;
bool x299_25_useBrightLightLag : 1;
bool x299_26_ : 1;
bool x299_26_ambientOnly : 1;
};
u16 _dummy = 0;
};

View File

@ -188,7 +188,7 @@ static FloatReturnFn skAnalogFuncs[] =
nullptr
};
#define kCommandFilterCount 65
#define kCommandFilterCount 67
static bool skCommandFilterFlag[kCommandFilterCount] = {true};
void ControlMapper::SetCommandFiltered(ECommands cmd, bool filtered)

View File

@ -77,7 +77,7 @@ void CLogBookScreen::UpdateRightTitles()
{
std::vector<std::pair<CAssetId, bool>>& category =
x19c_scanCompletes[x70_tablegroup_leftlog->GetUserSelection()];
for (int i=0 ; xd8_textpane_titles.size() ; ++i)
for (int i=0 ; i<xd8_textpane_titles.size() ; ++i)
{
std::u16string string;
size_t scanIndex = x18_firstViewRightSel + i;

View File

@ -14,7 +14,7 @@ COptionsScreen::COptionsScreen(const CStateManager& mgr, CGuiFrame& frame,
const CStringTable& pauseStrg)
: CPauseScreenBase(mgr, frame, pauseStrg)
{
x1a0_gameCube = std::unique_ptr<CGameCubeDoll>();
x1a0_gameCube = std::make_unique<CGameCubeDoll>();
x2a0_24_inOptionBody = false;
}

View File

@ -28,6 +28,7 @@ CPauseScreen::CPauseScreen(ESubScreen subscreen,
x5c_frmePauseScreenBuf.reset(new u8[x58_frmePauseScreenBufSz]);
x60_loadTok = g_ResFactory->LoadResourceAsync(frmeTag, x5c_frmePauseScreenBuf.get());
CSfxManager::SfxStart(1435, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x7c_screens.resize(2);
}
std::unique_ptr<CPauseScreenBase> CPauseScreen::BuildPauseSubScreen(ESubScreen subscreen,
@ -113,11 +114,12 @@ void CPauseScreen::StartTransition(float time, const CStateManager& mgr, ESubScr
return;
xc_nextSubscreen = subscreen;
x4_ = b;
std::unique_ptr<CPauseScreenBase>& newScreenSlot = x7c_screens[x78_activeIdx];
std::unique_ptr<CGuiFrame>& newScreenInst = x64_frameInsts[x78_activeIdx];
x10_alphaInterp = time;
std::unique_ptr<CPauseScreenBase>& newScreenSlot = x7c_screens[1 - x78_activeIdx];
std::unique_ptr<CGuiFrame>& newScreenInst = x64_frameInsts[1 - x78_activeIdx];
newScreenSlot = BuildPauseSubScreen(xc_nextSubscreen, mgr, *newScreenInst);
if (x7c_screens[1 - x78_activeIdx])
x7c_screens[1 - x78_activeIdx]->TransitioningAway();
if (x7c_screens[x78_activeIdx])
x7c_screens[x78_activeIdx]->TransitioningAway();
x91_initialTransition = false;
}

View File

@ -100,7 +100,8 @@ void CPhysicsActor::AddMotionState(const CMotionState& mst)
{
zeus::CNUQuaternion q{x34_transform.buildMatrix3f()};
q += mst.xc_orientation;
SetTransform(zeus::CTransform(zeus::CQuaternion::fromNUQuaternion(q), x34_transform.origin));
zeus::CQuaternion quat = zeus::CQuaternion::fromNUQuaternion(q);
SetTransform(zeus::CTransform(quat, x34_transform.origin));
SetTranslation(x34_transform.origin + mst.x0_translation);
@ -241,7 +242,7 @@ void CPhysicsActor::ComputeDerivedQuantities()
{
x138_velocity = xec_massRecip * xfc_constantForce;
x114_ = x34_transform.buildMatrix3f();
x144_angularVelocity = xf0_inertiaTensor * x108_angularMomentum;
x144_angularVelocity = xf4_inertiaTensorRecip * x108_angularMomentum;
}
bool CPhysicsActor::WillMove(const CStateManager&)
@ -311,7 +312,7 @@ CMotionState CPhysicsActor::PredictLinearMotion(float dt) const
CMotionState CPhysicsActor::PredictAngularMotion(float dt) const
{
const zeus::CVector3f v1 = xf4_inertiaTensorRecip * (x180_angularImpulse + x198_moveAngularImpulse);
zeus::CNUQuaternion q = 0.5f * zeus::CNUQuaternion(0.f, x144_angularVelocity + v1);
zeus::CNUQuaternion q = 0.5f * zeus::CNUQuaternion(0.f, x144_angularVelocity.getVector() + v1);
CMotionState ret = {zeus::CVector3f::skZero, q * zeus::CNUQuaternion(x34_transform.buildMatrix3f()) * dt,
zeus::CVector3f::skZero, (x174_torque * dt) + x180_angularImpulse};
return ret;

@ -1 +1 @@
Subproject commit 410ab94d7f5d5d6c5081af90ae9c217b10978db1
Subproject commit d78b1bf64087bf82133b1de71bfca9f9128fbf78