diff --git a/Runtime/Character/CRagDoll.cpp b/Runtime/Character/CRagDoll.cpp index 587a30061..d4b90cf8d 100644 --- a/Runtime/Character/CRagDoll.cpp +++ b/Runtime/Character/CRagDoll.cpp @@ -247,7 +247,7 @@ bool CRagDoll::SatisfyWorldConstraints(CStateManager& mgr, int pass) { float dot = delta.dot(info.GetNormalLeft()); particle.x2c_impactResponseDelta = -0.125f * dot * deltaMag * info.GetNormalLeft(); particle.x38_impactFrameVel = -dot * deltaMag; - particle.x4_curPos += float(0.0001f - (deltaMag - d) * dot) * info.GetNormalLeft(); + particle.x4_curPos += (0.0001f - (deltaMag - float(d)) * dot) * info.GetNormalLeft(); break; } case 2: @@ -309,7 +309,7 @@ void CRagDoll::Prime(CStateManager& mgr, const zeus::CTransform& xf, CModelData& aData->BuildPose(); for (auto& particle : x4_particles) if (particle.x0_id != 0xff) - particle.x4_curPos = xf * aData->GetPose().GetOffset(particle.x0_id) * scale; + particle.x4_curPos = xf * (aData->GetPose().GetOffset(particle.x0_id) * scale); SatisfyWorldConstraints(mgr, 2); for (auto& particle : x4_particles) particle.x3c_24_impactPending = false; diff --git a/Runtime/Collision/CMetroidAreaCollider.cpp b/Runtime/Collision/CMetroidAreaCollider.cpp index 347f1f5da..dbac807c7 100644 --- a/Runtime/Collision/CMetroidAreaCollider.cpp +++ b/Runtime/Collision/CMetroidAreaCollider.cpp @@ -796,9 +796,9 @@ bool CMetroidAreaCollider::MovingSphereCollisionCheck_Cached(const COctreeLeafCa zeus::CVector3f intersectPoint = sphere.position + mag * dir; bool outsideEdges[] = { - (intersectPoint - surf.GetVert(0)).dot((surf.GetVert(1) - surf.GetVert(0)).cross(surfNormal)) < 0.f, - (intersectPoint - surf.GetVert(1)).dot((surf.GetVert(2) - surf.GetVert(1)).cross(surfNormal)) < 0.f, - (intersectPoint - surf.GetVert(2)).dot((surf.GetVert(0) - surf.GetVert(2)).cross(surfNormal)) < + (intersectPoint - surf.GetVert(0)).dot(surfNormal.cross(surf.GetVert(1) - surf.GetVert(0))) < 0.f, + (intersectPoint - surf.GetVert(1)).dot(surfNormal.cross(surf.GetVert(2) - surf.GetVert(1))) < 0.f, + (intersectPoint - surf.GetVert(2)).dot(surfNormal.cross(surf.GetVert(0) - surf.GetVert(2))) < 0.f}; if (mag >= 0.f && !outsideEdges[0] && !outsideEdges[1] && !outsideEdges[2] && mag < dOut) { diff --git a/Runtime/MP1/World/CSpacePirate.cpp b/Runtime/MP1/World/CSpacePirate.cpp index 183ff3fbd..d1d4e38c1 100644 --- a/Runtime/MP1/World/CSpacePirate.cpp +++ b/Runtime/MP1/World/CSpacePirate.cpp @@ -144,32 +144,35 @@ void CPirateRagDoll::PreRender(const zeus::CVector3f& v, CModelData& mData) { if (aData->GetCharLayoutInfo().GetRootNode()->GetBoneMap()[id].x10_children.size() > 1) aData->PoseBuilder().GetTreeMap()[id].x4_rotation = zeus::CQuaternion::skNoRotation; CSegId rootId = aData->GetLocatorSegId("Skeleton_Root"sv); + // R_hip, L_hip aData->PoseBuilder().GetTreeMap()[rootId].x14_offset = (0.5f * (x4_particles[8].GetPosition() + x4_particles[11].GetPosition()) - v) / mData.GetScale(); - zeus::CVector3f _7c = x4_particles[2].GetPosition() - x4_particles[5].GetPosition(); - zeus::CVector3f _88 = + // R_shoulder, L_shoulder + zeus::CVector3f rootRight = x4_particles[2].GetPosition() - x4_particles[5].GetPosition(); + // Collar, R_hip, L_hip + zeus::CVector3f rootUp = (x4_particles[0].GetPosition() - (x4_particles[8].GetPosition() + x4_particles[11].GetPosition()) * 0.5f) .normalized(); - zeus::CVector3f _x94 = _88.cross(_7c).normalized(); - zeus::CQuaternion _a4(zeus::CMatrix3f(_x94.cross(_88), _x94, _88).transposed()); - aData->PoseBuilder().GetTreeMap()[rootId].x4_rotation = _a4; + zeus::CVector3f rootFore = rootUp.cross(rootRight).normalized(); + zeus::CQuaternion rootRot(zeus::CMatrix3f(rootFore.cross(rootUp), rootFore, rootUp)); + aData->PoseBuilder().GetTreeMap()[rootId].x4_rotation = rootRot; if (x6c_spacePirate->x7b4_attachedActor == kInvalidUniqueId) { - zeus::CVector3f _b0 = aData->GetCharLayoutInfo().GetFromParentUnrotated(x4_particles[1].GetBone()); + zeus::CVector3f neckRestVec = aData->GetCharLayoutInfo().GetFromParentUnrotated(x4_particles[1].GetBone()); aData->PoseBuilder().GetTreeMap()[x4_particles[1].GetBone()].x4_rotation = zeus::CQuaternion::shortestRotationArc( - _b0, _a4.inverse().transform(x4_particles[1].GetPosition() - x4_particles[0].GetPosition())); + neckRestVec, rootRot.inverse().transform(x4_particles[1].GetPosition() - x4_particles[0].GetPosition())); } BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 3, 4, - _a4 * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 2, 3, _a4)); + rootRot * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 2, 3, rootRot)); BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 6, 7, - _a4 * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 5, 6, _a4)); + rootRot * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 5, 6, rootRot)); BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 9, 10, - _a4 * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 8, 9, _a4)); + rootRot * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 8, 9, rootRot)); BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 12, 13, - _a4 * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 11, 12, _a4)); + rootRot * BoneAlign(aData->PoseBuilder(), aData->GetCharLayoutInfo(), 11, 12, rootRot)); zeus::CQuaternion q; q.rotateX(zeus::degToRad(-70.f)); - aData->PoseBuilder().GetTreeMap()[x4_particles[10].GetBone()].x4_rotation = q; - aData->PoseBuilder().GetTreeMap()[x4_particles[13].GetBone()].x4_rotation = q; + aData->PoseBuilder().GetTreeMap()[x4_particles[10].GetBone()].x4_rotation = q; // R_ankle + aData->PoseBuilder().GetTreeMap()[x4_particles[13].GetBone()].x4_rotation = q; // L_ankle aData->MarkPoseDirty(); } } @@ -405,9 +408,6 @@ CSpacePirate::CSpacePirate(TUniqueId uid, std::string_view name, const CEntityIn else if (GetDamageVulnerability()->WeaponHurts(CWeaponMode(EWeaponType::Wave), false)) x8cc_trooperColor = zeus::CColor(0.776f, 0.054f, 1.f, 1.f); } - - if (GetEditorId().Id() == 0x77) - SetActive(true); } void CSpacePirate::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CAi.hpp b/Runtime/World/CAi.hpp index 1cdfac67e..1535756c4 100644 --- a/Runtime/World/CAi.hpp +++ b/Runtime/World/CAi.hpp @@ -23,6 +23,7 @@ class CTeamAiRole; class CAi : public CPhysicsActor { static CAiFuncMap* m_FuncMap; +protected: CHealthInfo x258_healthInfo; CDamageVulnerability x260_damageVulnerability; TLockedToken x2c8_stateMachine; diff --git a/Runtime/World/CKnockBackController.cpp b/Runtime/World/CKnockBackController.cpp index 8f7a7ec56..8ac64f76d 100644 --- a/Runtime/World/CKnockBackController.cpp +++ b/Runtime/World/CKnockBackController.cpp @@ -365,7 +365,7 @@ CKnockBackController::CKnockBackController(EKnockBackVariant variant) : x0_varia x81_30_enableLaggedBurnDeath = true; x81_31_ = true; x82_24_ = true; - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < 5; ++i) { x24_.push_back(std::make_pair(0.f, FLT_MAX)); x80_availableStates.set(i); } diff --git a/Runtime/World/CKnockBackController.hpp b/Runtime/World/CKnockBackController.hpp index 29a4fe690..0c552952c 100644 --- a/Runtime/World/CKnockBackController.hpp +++ b/Runtime/World/CKnockBackController.hpp @@ -70,7 +70,7 @@ private: EKnockBackAnimationState x18_minAnimState = EKnockBackAnimationState::None; EKnockBackAnimationState x1c_maxAnimState = EKnockBackAnimationState::Fall; u32 x20_impulseDurationIdx = 0; - rstl::reserved_vector, 4> x24_; + rstl::reserved_vector, 5> x24_; zeus::CVector3f x50_impulseDir; float x5c_impulseMag = 0.f; float x60_impulseRemTime = 0.f; diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 460f9d1b8..f09717af8 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -27,6 +27,8 @@ namespace urde { +static logvisor::Module Log("urde::CPlayer"); + static const CMaterialFilter SolidMaterialFilter = CMaterialFilter::MakeInclude(CMaterialList(EMaterialTypes::Solid)); static const CMaterialFilter LineOfSightFilter = CMaterialFilter::MakeIncludeExclude( @@ -3567,6 +3569,12 @@ void CPlayer::SetOrbitState(EPlayerOrbitState state, CStateManager& mgr) { CFirstPersonCamera* cam = mgr.GetCameraManager()->GetFirstPersonCamera(); switch (x304_orbitState) { case EPlayerOrbitState::OrbitObject: +#ifndef NDEBUG + if (x310_orbitTargetId != kInvalidUniqueId) { + if (const CEntity* ent = mgr.GetObjectById(x310_orbitTargetId)) + Log.report(logvisor::Info, "Orbiting %08X %s", ent->GetEditorId(), ent->GetName().data()); + } +#endif cam->SetLockCamera(false); break; case EPlayerOrbitState::OrbitCarcass: {