CRelAngle fix

This commit is contained in:
Jack Andersen 2018-12-16 17:52:51 -10:00
parent 62d68a98da
commit b7f35e0528
14 changed files with 75 additions and 25 deletions

View File

@ -12,6 +12,25 @@
<option name="SPACE_AFTER_REFERENCE_IN_DECLARATION" value="true" />
</Objective-C>
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="hpp" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />

View File

@ -539,21 +539,28 @@ void CAutoMapper::ProcessMapRotateInput(const CFinalInput& input, const CStateMa
SetShouldRotatingSoundBePlaying(true);
zeus::CEulerAngles eulers(xa8_renderStates[0].x8_camOrientation);
zeus::CRelAngle angX(eulers.x());
angX.makeRel();
zeus::CRelAngle angZ(eulers.z());
angZ.makeRel();
float dt = deltaFrames * g_tweakAutoMapper->GetCamRotateDegreesPerFrame();
angZ -= zeus::degToRad(dt * dirs[2]);
angZ.makeRel();
angZ += zeus::degToRad(dt * dirs[3]);
angZ.makeRel();
angX -= zeus::degToRad(dt * dirs[0]);
angX.makeRel();
angX += zeus::degToRad(dt * dirs[1]);
angX.makeRel();
float angXDeg = angX.asDegrees();
if (angXDeg > 180.f)
angXDeg -= 360.f;
angX = zeus::degToRad(
zeus::clamp(g_tweakAutoMapper->GetMinCamRotateX(), angXDeg, g_tweakAutoMapper->GetMaxCamRotateX()));
angX.makeRel();
zeus::CQuaternion quat;
quat.rotateZ(angZ);
@ -767,12 +774,11 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, const CStateMa
zeus::CQuaternion CAutoMapper::GetMiniMapCameraOrientation(const CStateManager& stateMgr) const {
const CGameCamera* cam = stateMgr.GetCameraManager()->GetCurrentCamera(stateMgr);
zeus::CEulerAngles camAngles(zeus::CQuaternion(cam->GetTransform().buildMatrix3f()));
float rotMod = -(std::floor(camAngles.z() / (2.f * M_PIF)) * 2.f * M_PIF - camAngles.z());
if (rotMod < 0.f)
rotMod += 2.f * M_PIF;
zeus::CRelAngle angle(camAngles.z());
angle.makeRel();
zeus::CQuaternion ret;
ret.rotateZ(rotMod);
ret.rotateZ(angle);
ret.rotateX(zeus::degToRad(g_tweakAutoMapper->GetMiniCamXAngle()));
return ret;
}
@ -1356,6 +1362,7 @@ void CAutoMapper::Draw(const CStateManager& mgr, const zeus::CTransform& xf, flo
std::min(0.6f * g_tweakAutoMapper->GetMaxCamDist() / g_tweakAutoMapper->GetMinCamDist(), objectScale);
zeus::CEulerAngles eulers(mgr.GetCameraManager()->GetCurrentCameraTransform(mgr));
zeus::CRelAngle angle(eulers.z());
angle.makeRel();
zeus::CTransform playerXf(zeus::CMatrix3f::RotateZ(angle),
CMapArea::GetAreaPostTranslate(*x24_world, mgr.GetNextAreaId()) +
mgr.GetPlayer().GetTranslation());

View File

@ -102,6 +102,7 @@ void CBSProjectileAttack::Start(CBodyController& bc, CStateManager& mgr) {
zeus::CVector3f localDelta =
bc.GetOwner().GetTransform().transposeRotate(cmd->GetTargetPosition() - bc.GetOwner().GetTranslation());
zeus::CRelAngle angle = std::atan2(localDelta.y(), localDelta.x());
angle.makeRel();
float attackAngle = angle.asDegrees();
CPASAnimParmData parms(18, CPASAnimParm::FromEnum(s32(cmd->GetAttackSeverity())),
CPASAnimParm::FromReal32(angle.asDegrees()),
@ -184,6 +185,7 @@ void CBSFall::Start(CBodyController& bc, CStateManager& mgr) {
const CBCKnockDownCmd* cmd = static_cast<const CBCKnockDownCmd*>(bc.GetCommandMgr().GetCmd(EBodyStateCmd::KnockDown));
zeus::CVector3f localDir = bc.GetOwner().GetTransform().transposeRotate(cmd->GetHitDirection());
zeus::CRelAngle angle = std::atan2(localDir.y(), localDir.z());
angle.makeRel();
CPASAnimParmData parms(0, CPASAnimParm::FromReal32(angle.asDegrees()),
CPASAnimParm::FromEnum(s32(cmd->GetHitSeverity())));
std::pair<float, s32> best = bc.GetPASDatabase().FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
@ -193,7 +195,9 @@ void CBSFall::Start(CBodyController& bc, CStateManager& mgr) {
if (!knockdownState->GetAnimParmData(best.second, 2).GetBoolValue()) {
float animAngle = zeus::degToRad(knockdownState->GetAnimParmData(best.second, 0).GetReal32Value());
zeus::CRelAngle delta1 = angle - animAngle;
delta1.makeRel();
zeus::CRelAngle delta2 = animAngle - angle;
delta2.makeRel();
float minAngle = std::min(float(delta1), float(delta2));
x8_remTime = 0.15f * bc.GetAnimTimeRemaining();
float flippedAngle = (delta1 > M_PIF) ? -minAngle : minAngle;
@ -263,6 +267,7 @@ void CBSKnockBack::Start(CBodyController& bc, CStateManager& mgr) {
const CBCKnockBackCmd* cmd = static_cast<const CBCKnockBackCmd*>(bc.GetCommandMgr().GetCmd(EBodyStateCmd::KnockBack));
zeus::CVector3f localDir = bc.GetOwner().GetTransform().transposeRotate(cmd->GetHitDirection());
zeus::CRelAngle angle = std::atan2(localDir.y(), localDir.x());
angle.makeRel();
CPASAnimParmData parms(6, CPASAnimParm::FromReal32(angle.asDegrees()),
CPASAnimParm::FromEnum(s32(cmd->GetHitSeverity())));
std::pair<float, s32> best = bc.GetPASDatabase().FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
@ -272,7 +277,9 @@ void CBSKnockBack::Start(CBodyController& bc, CStateManager& mgr) {
if (!knockbackState->GetAnimParmData(best.second, 2).GetBoolValue()) {
float animAngle = zeus::degToRad(knockbackState->GetAnimParmData(best.second, 0).GetReal32Value());
zeus::CRelAngle delta1 = angle - animAngle;
delta1.makeRel();
zeus::CRelAngle delta2 = animAngle - angle;
delta2.makeRel();
float minAngle = std::min(float(delta1), float(delta2));
float flippedAngle = (delta1 > M_PIF) ? -minAngle : minAngle;
xc_remTime = 0.15f * bc.GetAnimTimeRemaining();
@ -705,6 +712,7 @@ void CBSGroundHit::Start(CBodyController& bc, CStateManager& mgr) {
const CBCKnockBackCmd* cmd = static_cast<const CBCKnockBackCmd*>(bc.GetCommandMgr().GetCmd(EBodyStateCmd::KnockBack));
zeus::CVector3f localDir = bc.GetOwner().GetTransform().transposeRotate(cmd->GetHitDirection());
zeus::CRelAngle angle = std::atan2(localDir.y(), localDir.x());
angle.makeRel();
CPASAnimParmData parms(11, CPASAnimParm::FromEnum(s32(bc.GetFallState())),
CPASAnimParm::FromReal32(angle.asDegrees()));
std::pair<float, s32> best = bc.GetPASDatabase().FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
@ -714,7 +722,9 @@ void CBSGroundHit::Start(CBodyController& bc, CStateManager& mgr) {
if (!groundHitState->GetAnimParmData(best.second, 2).GetBoolValue()) {
float animAngle = zeus::degToRad(groundHitState->GetAnimParmData(best.second, 1).GetReal32Value());
zeus::CRelAngle delta1 = angle - animAngle;
delta1.makeRel();
zeus::CRelAngle delta2 = animAngle - angle;
delta2.makeRel();
float minAngle = std::min(float(delta1), float(delta2));
float flippedAngle = (delta1 > M_PIF) ? -minAngle : minAngle;
x8_remTime = 0.15f * bc.GetAnimTimeRemaining();
@ -956,6 +966,7 @@ void CBSHurled::Start(CBodyController& bc, CStateManager& mgr) {
x4_state = pas::EHurledState(cmd->GetSkipLaunchState());
zeus::CVector3f localDir = bc.GetOwner().GetTransform().transposeRotate(cmd->GetHitDirection());
zeus::CRelAngle angle = std::atan2(localDir.y(), localDir.x());
angle.makeRel();
x8_knockAngle = angle.asDegrees();
CPASAnimParmData parms(14, CPASAnimParm::FromInt32(-1), CPASAnimParm::FromReal32(x8_knockAngle),
CPASAnimParm::FromEnum(s32(x4_state)));
@ -971,7 +982,9 @@ void CBSHurled::Start(CBodyController& bc, CStateManager& mgr) {
act->SetConstantForce(act->GetMass() * cmd->GetLaunchVelocity());
float animAngle = zeus::degToRad(hurledState->GetAnimParmData(best.second, 1).GetReal32Value());
zeus::CRelAngle delta1 = angle - animAngle;
delta1.makeRel();
zeus::CRelAngle delta2 = animAngle - angle;
delta2.makeRel();
float minAngle = std::min(float(delta1), float(delta2));
x14_remTime = 0.15f * bc.GetAnimTimeRemaining();
float flippedAngle = (delta1 > M_PIF) ? -minAngle : minAngle;
@ -1146,7 +1159,7 @@ void CBSSlide::Start(CBodyController& bc, CStateManager& mgr) {
if (timeRem > FLT_EPSILON) {
const CPASAnimState* slideState = bc.GetPASDatabase().GetAnimState(15);
float animAngle = zeus::degToRad(slideState->GetAnimParmData(best.second, 1).GetReal32Value());
float delta1 = zeus::CRelAngle(angle - animAngle);
float delta1 = zeus::CRelAngle(angle - animAngle).asRel();
float flippedAngle = (delta1 > M_PIF) ? delta1 - 2.f * M_PIF : delta1;
x4_rotateSpeed = flippedAngle / timeRem;
} else {

View File

@ -195,7 +195,7 @@ float CPASAnimState::ComputePercentErrorWeight(u32 idx, const CPASAnimParm& parm
}
if (range > FLT_EPSILON)
return (val / range) - 1.0f;
return 1.f - val / range;
return (val < FLT_EPSILON ? 1.f : 0.f);
}

View File

@ -194,6 +194,7 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
x204_chargeGaugeOvershootTimer = g_tweakTargeting->GetChargeGaugeOvershootDuration();
for (int i = 0; i < 9; ++i) {
zeus::CRelAngle baseAngle = g_tweakTargeting->GetOuterBeamSquareAngles(int(beam))[i];
baseAngle.makeRel();
SOuterItemInfo& icon = xe0_outerBeamIconSquares[i];
zeus::CRelAngle offshootAngleDelta = baseAngle.asRadians() - icon.x10_rotAng;
if ((i & 0x1) == 1)
@ -204,6 +205,7 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
icon.x14_baseAngle = baseAngle;
}
zeus::CRelAngle baseAngle = g_tweakTargeting->GetChargeGaugeAngle(int(beam));
baseAngle.makeRel();
float offshootAngleDelta = baseAngle.asRadians() - xc4_chargeGauge.x10_rotAng;
if ((rand() & 0x1) == 1)
offshootAngleDelta =
@ -254,8 +256,9 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
x1de_grapplePoint1 = kInvalidUniqueId;
}
x1f0_xrayRetAngle =
zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetXRayRetAngleSpeed() * dt) + x1f0_xrayRetAngle);
x1ec_seekerAngle = zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetSeekerAngleSpeed() * dt) + x1ec_seekerAngle);
zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetXRayRetAngleSpeed() * dt) + x1f0_xrayRetAngle).asRel();
x1ec_seekerAngle = zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetSeekerAngleSpeed() * dt) + x1ec_seekerAngle).
asRel();
}
void CTargetReticleRenderState::InterpolateWithClamp(const CTargetReticleRenderState& a, CTargetReticleRenderState& out,
@ -344,10 +347,12 @@ void CCompoundTargetReticle::UpdateCurrLockOnGroup(float dt, const CStateManager
1.f - x204_chargeGaugeOvershootTimer / g_tweakTargeting->GetChargeGaugeOvershootDuration());
for (int i = 0; i < 9; ++i) {
SOuterItemInfo& item = xe0_outerBeamIconSquares[i];
item.x10_rotAng = zeus::CRelAngle(item.x18_offshootAngleDelta * offshoot + item.xc_offshootBaseAngle);
item.x10_rotAng = zeus::CRelAngle(item.x18_offshootAngleDelta * offshoot + item.xc_offshootBaseAngle).
asRel();
}
xc4_chargeGauge.x10_rotAng =
zeus::CRelAngle(xc4_chargeGauge.x18_offshootAngleDelta * offshoot + xc4_chargeGauge.xc_offshootBaseAngle);
zeus::CRelAngle(xc4_chargeGauge.x18_offshootAngleDelta * offshoot + xc4_chargeGauge.xc_offshootBaseAngle).
asRel();
}
}
if (x208_lockonTimer > 0.f && x208_lockonTimer < g_tweakTargeting->GetLockonDuration())

View File

@ -105,6 +105,7 @@ void CHudRadarInterface::Draw(const CStateManager& mgr, float alpha) const {
float camZ =
zeus::CEulerAngles(zeus::CQuaternion(mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTransform().basis)).z();
zeus::CRelAngle angleZ(camZ);
angleZ.makeRel();
drawParms.xc_preTranslate = zeus::CTransform::RotateY(angleZ);
drawParms.x3c_postTranslate = x40_BaseWidget_RadarStuff->GetWorldTransform();
float enemyRadius = g_tweakGui->GetRadarEnemyPaintRadius();

View File

@ -223,6 +223,7 @@ void CSamusDoll::Update(float dt, CRandom16& rand) {
if (x250_phazonIndirectTexture) {
x260_phazonOffsetAngle += 0.03f;
x260_phazonOffsetAngle.makeRel();
g_Renderer->AllocatePhazonSuitMaskTexture();
}
@ -596,23 +597,23 @@ void CSamusDoll::SetRotation(float xDelta, float zDelta, float dt) {
zeus::CEulerAngles angles(xb0_userRot);
zeus::CRelAngle angX(angles.x());
angX.makeRel();
zeus::CRelAngle angZ(angles.z());
angZ.makeRel();
angX += xDelta;
angX.makeRel();
angZ += zDelta;
angZ.makeRel();
float angXCenter = angX;
if (angXCenter > M_PIF)
angXCenter -= 2.f * M_PIF;
angXCenter = zeus::clamp(-1.555f, angXCenter, 1.555f);
float angZCenter = angZ;
if (angZCenter > M_PIF)
angZCenter -= 2.f * M_PIF;
zeus::CQuaternion quat;
quat.rotateZ(angZCenter);
quat.rotateX(angXCenter);
quat.rotateZ(angZ);
quat.rotateX(zeus::CRelAngle(angXCenter).asRel());
xb0_userRot = quat;
}

View File

@ -131,7 +131,7 @@ void CPlayerGun::TakeDamage(bool bigStrike, bool notFromMetroid, CStateManager&
x364_gunStrikeCoolTimer = 0.75f;
if (x678_morph.GetGunState() == CGunMorph::EGunState::OutWipeDone) {
zeus::CVector3f localDamageLoc = mgr.GetPlayer().GetTransform().transposeRotate(x3dc_damageLocation);
angle = zeus::CRelAngle(std::atan2(localDamageLoc.y(), localDamageLoc.x())).asDegrees();
angle = zeus::CRelAngle(std::atan2(localDamageLoc.y(), localDamageLoc.x())).asRel().asDegrees();
hasStrikeAngle = true;
}
}

View File

@ -9,10 +9,16 @@
namespace urde {
CProjectileInfo::CProjectileInfo(urde::CInputStream& in)
: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), CAssetId(in)})), xc_damageInfo(in) {}
: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), CAssetId(in)})), xc_damageInfo(in) {
if (x0_weaponDescription.GetObjectTag()->id == 0xB4CB4495)
printf("");
}
CProjectileInfo::CProjectileInfo(CAssetId proj, const CDamageInfo& dInfo)
: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), proj})), xc_damageInfo(dInfo) {}
: x0_weaponDescription(g_SimplePool->GetObj({SBIG('WPSC'), proj})), xc_damageInfo(dInfo) {
if (x0_weaponDescription.GetObjectTag()->id == 0xB4CB4495)
printf("");
}
zeus::CVector3f CProjectileInfo::PredictInterceptPos(const zeus::CVector3f& gunPos, const zeus::CVector3f& aimPos,
const CPlayer& player, bool gravity, float speed, float dt) {

View File

@ -185,8 +185,6 @@ void CPhysicsActor::MoveToWR(const zeus::CVector3f& trans, float d) {
zeus::CAxisAngle CPhysicsActor::GetRotateToORAngularMomentumWR(const zeus::CQuaternion& q, float d) const {
if (q.w() > 0.99999976)
return zeus::CAxisAngle::skZero;
if (GetEditorId().Id() == 0x77)
printf("%f\n", q.yaw());
return (xf0_inertiaTensor *
(((2.f * std::acos(q.w())) * (1.f / d)) * x34_transform.rotate(q.getImaginary()).normalized()));
}

View File

@ -109,7 +109,7 @@ void CScriptPickup::Think(float dt, CStateManager& mgr) {
if (chargeFactor > CPlayerGun::skTractorBeamFactor) {
zeus::CVector3f posVec =
(GetTranslation() - mgr.GetCameraManager()->GetFirstPersonCamera()->GetTranslation()).normalized();
float relFov = zeus::CRelAngle(zeus::degToRad(g_tweakGame->GetFirstPersonFOV()));
float relFov = zeus::CRelAngle(zeus::degToRad(g_tweakGame->GetFirstPersonFOV())).asRel();
if (mgr.GetCameraManager()->GetFirstPersonCamera()->GetTransform().upVector().dot(posVec) > std::cos(relFov) &&
posVec.magSquared() < (30.f * 30.f)) {
x28c_25_ = true;

View File

@ -226,7 +226,7 @@ void CScriptPlayerActor::Think(float dt, CStateManager& mgr) {
if (x338_phazonIndirectTexture) {
x34c_phazonOffsetAngle += 0.03f;
x34c_phazonOffsetAngle = zeus::CRelAngle::FromRadians(x34c_phazonOffsetAngle);
x34c_phazonOffsetAngle = zeus::CRelAngle(x34c_phazonOffsetAngle).asRel();
}
CScriptActor::Think(dt, mgr);

2
hecl

@ -1 +1 @@
Subproject commit ce11625af079a4449796b129b463f7d78d6a39d5
Subproject commit ef8806b1d3789f992beb86c29679ffe36a9a25d6

@ -1 +1 @@
Subproject commit 9ea12bded618ec4ac3198e86cb1937dece17239b
Subproject commit 8da97f6c95872fb3fe7211c8bd6cf6a0f13050a6