metaforce/Runtime/Collision/CGameCollision.hpp

127 lines
9.2 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
#include "zeus/CVector3f.hpp"
#include "zeus/CPlane.hpp"
2017-03-24 05:30:16 +00:00
#include "rstl.hpp"
#include "RetroTypes.hpp"
#include "CRayCastResult.hpp"
#include "CMetroidAreaCollider.hpp"
#include "CCollisionPrimitive.hpp"
namespace urde
{
class CActor;
class CCollisionInfo;
class CCollisionInfoList;
class CMaterialList;
class CStateManager;
2017-03-26 05:53:04 +00:00
class CPhysicsActor;
class CMaterialFilter;
class CGameArea;
class ICollisionFilter;
2017-03-24 05:30:16 +00:00
class CGameCollision
{
static void MovePlayer(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList);
static void MoveAndCollide(CStateManager& mgr, CPhysicsActor& actor, float dt, const ICollisionFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList);
static zeus::CVector3f GetActorRelativeVelocities(const CPhysicsActor& act0, const CPhysicsActor* act1);
public:
static float GetCoefficientOfRestitution(const CCollisionInfo&) { return 0.f; }
static bool NullMovingCollider(const CInternalCollisionStructure&, const zeus::CVector3f&, double&, CCollisionInfo&)
{
return false;
}
static bool NullBooleanCollider(const CInternalCollisionStructure&) { return false; }
static bool NullCollisionCollider(const CInternalCollisionStructure&, CCollisionInfoList&) { return false; }
static void InitCollision();
static void Move(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList);
static bool CanBlock(const CMaterialList&, const zeus::CVector3f&);
static bool IsFloor(const CMaterialList&, const zeus::CVector3f&);
static void SendMaterialMessage(CStateManager&, const CMaterialList&, CActor&);
static CRayCastResult RayStaticIntersection(const CStateManager& mgr, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter);
static bool RayStaticIntersectionBool(const CStateManager& mgr, const zeus::CVector3f& start,
const zeus::CVector3f& dir, float length,
const CMaterialFilter& filter);
static CRayCastResult RayDynamicIntersection(const CStateManager& mgr, TUniqueId& idOut, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList);
static bool RayDynamicIntersectionBool(const CStateManager& mgr,
const zeus::CVector3f& pos, const zeus::CVector3f& dir,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const CActor* damagee, float length);
static CRayCastResult RayWorldIntersection(const CStateManager& mgr, TUniqueId& idOut, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList);
static bool RayStaticIntersectionArea(const CGameArea& area, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter);
2017-09-17 03:13:03 +00:00
static void BuildAreaCollisionCache(const CStateManager& mgr, CAreaCollisionCache& cache);
static float GetMinExtentForCollisionPrimitive(const CCollisionPrimitive& prim);
2017-09-17 03:13:03 +00:00
static bool DetectCollisionBoolean(const CStateManager& mgr, const CCollisionPrimitive& prim,
2017-07-23 23:45:04 +00:00
const zeus::CTransform& xf, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList);
2017-09-17 03:13:03 +00:00
static bool DetectCollisionBoolean_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList);
2017-09-17 03:13:03 +00:00
static bool DetectStaticCollisionBoolean(const CStateManager& mgr, const CCollisionPrimitive& prim,
const zeus::CTransform& xf, const CMaterialFilter& filter);
2017-09-17 03:13:03 +00:00
static bool DetectStaticCollisionBoolean_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter);
static bool DetectDynamicCollisionBoolean(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
2017-09-17 03:13:03 +00:00
const CStateManager& mgr);
static bool DetectCollision_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
TUniqueId& idOut, CCollisionInfoList& infoList);
2017-09-17 03:13:03 +00:00
static bool DetectCollision_Cached_Moving(const CStateManager& mgr, CAreaCollisionCache& cache,
2017-06-19 07:00:50 +00:00
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const zeus::CVector3f& vec,
TUniqueId& idOut, CCollisionInfo& infoOut, double&);
2017-09-17 03:13:03 +00:00
static bool DetectStaticCollision(const CStateManager& mgr, const CCollisionPrimitive& prim,
const zeus::CTransform& xf, const CMaterialFilter& filter,
CCollisionInfoList& list);
2017-09-17 03:13:03 +00:00
static bool DetectStaticCollision_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter, CCollisionInfoList& list);
2017-09-17 03:13:03 +00:00
static bool DetectStaticCollision_Cached_Moving(const CStateManager& mgr, CAreaCollisionCache& cache,
2017-06-21 07:24:26 +00:00
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter, const zeus::CVector3f& vec,
CCollisionInfo& infoOut, double& d);
static bool DetectDynamicCollision(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
2017-09-17 03:13:03 +00:00
TUniqueId& idOut, CCollisionInfoList& list, const CStateManager& mgr);
2017-06-21 07:24:26 +00:00
static bool DetectDynamicCollisionMoving(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const zeus::CVector3f& vec, TUniqueId& idOut,
2017-09-17 03:13:03 +00:00
CCollisionInfo& infoOut, double& d, const CStateManager& mgr);
static void MakeCollisionCallbacks(CStateManager& mgr, CPhysicsActor& actor, TUniqueId id,
const CCollisionInfoList& list);
static void SendScriptMessages(CStateManager& mgr, CActor& a0, CActor* a1, const CCollisionInfoList& list);
static void ResolveCollisions(CPhysicsActor& a0, CPhysicsActor* a1, const CCollisionInfoList& list);
static void CollideWithDynamicBodyNoRot(CPhysicsActor& a0, CPhysicsActor& a1, const CCollisionInfo& info,
float restitution, bool);
static void CollideWithStaticBodyNoRot(CPhysicsActor& a0, const CMaterialList& m0, const CMaterialList& m1,
const zeus::CUnitVector3f& normal, float restitution, bool);
2017-09-17 03:13:03 +00:00
static void CollisionFailsafe(const CStateManager& mgr, CAreaCollisionCache& cache,
CPhysicsActor& actor, const CCollisionPrimitive& prim,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
float, u32 failsafeTicks);
2017-06-19 07:00:50 +00:00
static std::experimental::optional<zeus::CVector3f>
2017-09-17 03:13:03 +00:00
FindNonIntersectingVector(const CStateManager& mgr, CAreaCollisionCache& cache,
2017-06-19 07:00:50 +00:00
CPhysicsActor& actor, const CCollisionPrimitive& prim,
const rstl::reserved_vector<TUniqueId, 1024>& nearList);
};
}