CRagDoll fixes

This commit is contained in:
Jack Andersen 2018-12-26 20:26:34 -10:00
parent ef63509bb3
commit 0ec81477cf
7 changed files with 32 additions and 23 deletions

View File

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

View File

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

View File

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

View File

@ -23,6 +23,7 @@ class CTeamAiRole;
class CAi : public CPhysicsActor {
static CAiFuncMap* m_FuncMap;
protected:
CHealthInfo x258_healthInfo;
CDamageVulnerability x260_damageVulnerability;
TLockedToken<CStateMachine> x2c8_stateMachine;

View File

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

View File

@ -70,7 +70,7 @@ private:
EKnockBackAnimationState x18_minAnimState = EKnockBackAnimationState::None;
EKnockBackAnimationState x1c_maxAnimState = EKnockBackAnimationState::Fall;
u32 x20_impulseDurationIdx = 0;
rstl::reserved_vector<std::pair<float, float>, 4> x24_;
rstl::reserved_vector<std::pair<float, float>, 5> x24_;
zeus::CVector3f x50_impulseDir;
float x5c_impulseMag = 0.f;
float x60_impulseRemTime = 0.f;

View File

@ -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: {