mirror of https://github.com/AxioDL/metaforce.git
CGroundMovement: Fix CheckFalling not being called consistently
This commit is contained in:
parent
92076a3bd3
commit
abfd5a464f
|
@ -23,15 +23,15 @@ void CGroundMovement::CheckFalling(CPhysicsActor& actor, CStateManager& mgr, flo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!oob) {
|
if (oob) {
|
||||||
mgr.SendScriptMsg(&actor, kInvalidUniqueId, EScriptObjectMessage::Falling);
|
|
||||||
} else {
|
|
||||||
mgr.SendScriptMsg(&actor, kInvalidUniqueId, EScriptObjectMessage::OnFloor);
|
mgr.SendScriptMsg(&actor, kInvalidUniqueId, EScriptObjectMessage::OnFloor);
|
||||||
actor.SetAngularVelocityWR(actor.GetAngularVelocityWR() * 0.98f);
|
actor.SetAngularVelocityWR(actor.GetAngularVelocityWR() * 0.98f);
|
||||||
zeus::CVector3f vel = actor.GetTransform().transposeRotate(actor.GetVelocity());
|
zeus::CVector3f vel = actor.GetTransform().transposeRotate(actor.GetVelocity());
|
||||||
vel.z() = 0.f;
|
vel.z() = 0.f;
|
||||||
actor.SetVelocityOR(vel);
|
actor.SetVelocityOR(vel);
|
||||||
actor.SetMomentumWR(zeus::skZero3f);
|
actor.SetMomentumWR(zeus::skZero3f);
|
||||||
|
} else {
|
||||||
|
mgr.SendScriptMsg(&actor, kInvalidUniqueId, EScriptObjectMessage::Falling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,22 +83,20 @@ void CGroundMovement::MoveGroundCollider(CStateManager& mgr, CPhysicsActor& acto
|
||||||
float resolved = 0.f;
|
float resolved = 0.f;
|
||||||
collisionList.Clear();
|
collisionList.Clear();
|
||||||
TUniqueId stepZId = kInvalidUniqueId;
|
TUniqueId stepZId = kInvalidUniqueId;
|
||||||
if (stepDown >= 0.f) {
|
if (stepDown >= 0.f && MoveGroundColliderZ(cache, mgr, actor, actor.GetMaterialFilter(), useColliderList, -stepDown,
|
||||||
if (MoveGroundColliderZ(cache, mgr, actor, actor.GetMaterialFilter(), useColliderList, -stepDown, resolved,
|
resolved, collisionList, stepZId)) {
|
||||||
collisionList, stepZId)) {
|
if (collisionList.GetCount() > 0) {
|
||||||
if (collisionList.GetCount() > 0) {
|
CCollisionInfoList filteredList;
|
||||||
CCollisionInfoList filteredList;
|
CollisionUtil::FilterByClosestNormal(zeus::CVector3f{0.f, 0.f, 1.f}, collisionList, filteredList);
|
||||||
CollisionUtil::FilterByClosestNormal(zeus::CVector3f{0.f, 0.f, 1.f}, collisionList, filteredList);
|
if (filteredList.GetCount() > 0) {
|
||||||
if (filteredList.GetCount() > 0) {
|
if (CGameCollision::IsFloor(filteredList.Front().GetMaterialLeft(), filteredList.Front().GetNormalLeft())) {
|
||||||
if (CGameCollision::IsFloor(filteredList.Front().GetMaterialLeft(),
|
if (TCastToPtr<CScriptPlatform> plat = mgr.ObjectById(stepZId)) {
|
||||||
filteredList.Front().GetNormalLeft())) {
|
mgr.SendScriptMsg(plat.GetPtr(), actor.GetUniqueId(), EScriptObjectMessage::AddPlatformRider);
|
||||||
if (TCastToPtr<CScriptPlatform> plat = mgr.ObjectById(stepZId))
|
|
||||||
mgr.SendScriptMsg(plat.GetPtr(), actor.GetUniqueId(), EScriptObjectMessage::AddPlatformRider);
|
|
||||||
CGameCollision::SendMaterialMessage(mgr, filteredList.Front().GetMaterialLeft(), actor);
|
|
||||||
mgr.SendScriptMsg(&actor, kInvalidUniqueId, EScriptObjectMessage::OnFloor);
|
|
||||||
} else {
|
|
||||||
CheckFalling(actor, mgr, dt);
|
|
||||||
}
|
}
|
||||||
|
CGameCollision::SendMaterialMessage(mgr, filteredList.Front().GetMaterialLeft(), actor);
|
||||||
|
mgr.SendScriptMsg(&actor, kInvalidUniqueId, EScriptObjectMessage::OnFloor);
|
||||||
|
} else {
|
||||||
|
CheckFalling(actor, mgr, dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +171,7 @@ bool CGroundMovement::ResolveUpDown(CAreaCollisionCache& cache, CStateManager& m
|
||||||
|
|
||||||
bool CGroundMovement::MoveGroundColliderZ(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
|
bool CGroundMovement::MoveGroundColliderZ(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
|
||||||
const CMaterialFilter& filter,
|
const CMaterialFilter& filter,
|
||||||
rstl::reserved_vector<TUniqueId, 1024>& nearList, float amt, float&,
|
rstl::reserved_vector<TUniqueId, 1024>& nearList, float amt, float& resolved,
|
||||||
CCollisionInfoList& list, TUniqueId& idOut) {
|
CCollisionInfoList& list, TUniqueId& idOut) {
|
||||||
actor.MoveCollisionPrimitive({0.f, 0.f, amt});
|
actor.MoveCollisionPrimitive({0.f, 0.f, amt});
|
||||||
|
|
||||||
|
@ -186,16 +184,18 @@ bool CGroundMovement::MoveGroundColliderZ(CAreaCollisionCache& cache, CStateMana
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::CAABox actorAABB = actor.GetBoundingBox();
|
zeus::CAABox actorAABB = actor.GetBoundingBox();
|
||||||
float zextent;
|
float zextent = 0.f;
|
||||||
if (amt > 0.f)
|
if (amt > 0.f) {
|
||||||
zextent = aabb.min.z() - actorAABB.max.z() - 0.02f + amt;
|
zextent = aabb.min.z() - actorAABB.max.z() - 0.02f + amt;
|
||||||
else
|
} else {
|
||||||
zextent = aabb.max.z() - actorAABB.min.z() + 0.02f + amt;
|
zextent = aabb.max.z() - actorAABB.min.z() + 0.02f + amt;
|
||||||
|
}
|
||||||
|
|
||||||
actor.MoveCollisionPrimitive({0.f, 0.f, zextent});
|
actor.MoveCollisionPrimitive({0.f, 0.f, zextent});
|
||||||
|
|
||||||
if (!CGameCollision::DetectCollisionBoolean_Cached(mgr, cache, *actor.GetCollisionPrimitive(),
|
if (!CGameCollision::DetectCollisionBoolean_Cached(mgr, cache, *actor.GetCollisionPrimitive(),
|
||||||
actor.GetPrimitiveTransform(), filter, nearList)) {
|
actor.GetPrimitiveTransform(), filter, nearList)) {
|
||||||
|
resolved = zextent;
|
||||||
actor.SetTranslation(actor.GetTranslation() + zeus::CVector3f(0.f, 0.f, zextent));
|
actor.SetTranslation(actor.GetTranslation() + zeus::CVector3f(0.f, 0.f, zextent));
|
||||||
actor.MoveCollisionPrimitive(zeus::skZero3f);
|
actor.MoveCollisionPrimitive(zeus::skZero3f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,9 +225,7 @@ bool CGameCollision::CanBlock(const CMaterialList& mat, const zeus::CVector3f& v
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGameCollision::IsFloor(const CMaterialList& mat, const zeus::CVector3f& v) {
|
bool CGameCollision::IsFloor(const CMaterialList& mat, const zeus::CVector3f& v) {
|
||||||
if (mat.HasMaterial(EMaterialTypes::Floor))
|
return mat.HasMaterial(EMaterialTypes::Floor) || v.z() > 0.85f;
|
||||||
return true;
|
|
||||||
return (v.z() > 0.85f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameCollision::SendMaterialMessage(CStateManager& mgr, const CMaterialList& mat, CActor& act) {
|
void CGameCollision::SendMaterialMessage(CStateManager& mgr, const CMaterialList& mat, CActor& act) {
|
||||||
|
|
Loading…
Reference in New Issue