2016-04-17 22:38:05 +00:00
|
|
|
#ifndef __URDE_CGAMECOLLISION_HPP__
|
|
|
|
#define __URDE_CGAMECOLLISION_HPP__
|
2017-01-04 04:08:30 +00:00
|
|
|
#include "zeus/CVector3f.hpp"
|
2017-03-30 22:36:18 +00:00
|
|
|
#include "zeus/CPlane.hpp"
|
2017-03-24 05:30:16 +00:00
|
|
|
#include "rstl.hpp"
|
|
|
|
#include "RetroTypes.hpp"
|
2017-03-30 22:36:18 +00:00
|
|
|
#include "CRayCastResult.hpp"
|
2017-06-18 01:58:13 +00:00
|
|
|
#include "CMetroidAreaCollider.hpp"
|
|
|
|
#include "CCollisionPrimitive.hpp"
|
2016-04-17 22:38:05 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
class CActor;
|
|
|
|
class CCollisionInfo;
|
|
|
|
class CCollisionInfoList;
|
|
|
|
class CMaterialList;
|
|
|
|
class CStateManager;
|
2017-03-26 05:53:04 +00:00
|
|
|
class CPhysicsActor;
|
2017-03-30 22:36:18 +00:00
|
|
|
class CMaterialFilter;
|
2017-04-10 06:57:00 +00:00
|
|
|
class CGameArea;
|
2017-06-18 01:58:13 +00:00
|
|
|
class ICollisionFilter;
|
2017-03-24 05:30:16 +00:00
|
|
|
|
2016-04-17 22:38:05 +00:00
|
|
|
class CGameCollision
|
|
|
|
{
|
2017-06-18 01:58:13 +00:00
|
|
|
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);
|
2016-04-17 22:38:05 +00:00
|
|
|
public:
|
2017-06-18 01:58:13 +00:00
|
|
|
static float GetCoefficientOfRestitution(const CCollisionInfo&) { return 0.f; }
|
2017-01-04 04:08:30 +00:00
|
|
|
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; }
|
2016-04-17 22:38:05 +00:00
|
|
|
static void InitCollision();
|
2017-06-18 01:58:13 +00:00
|
|
|
static void Move(CStateManager& mgr, CPhysicsActor& actor, float dt,
|
|
|
|
const rstl::reserved_vector<TUniqueId, 1024>* colliderList);
|
2016-04-17 22:38:05 +00:00
|
|
|
|
2017-01-04 04:08:30 +00:00
|
|
|
static bool CanBlock(const CMaterialList&, const zeus::CVector3f&);
|
|
|
|
static bool IsFloor(const CMaterialList&, const zeus::CVector3f&);
|
2017-06-18 01:58:13 +00:00
|
|
|
static void SendMaterialMessage(CStateManager&, const CMaterialList&, CActor&);
|
2017-03-30 22:36:18 +00:00
|
|
|
static CRayCastResult RayStaticIntersection(const CStateManager& mgr, const zeus::CVector3f& pos,
|
|
|
|
const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter);
|
2017-04-15 05:49:01 +00:00
|
|
|
static bool RayStaticIntersectionBool(const CStateManager& mgr, const zeus::CVector3f& start,
|
|
|
|
const zeus::CVector3f& dir, float length,
|
|
|
|
const CMaterialFilter& filter);
|
2017-03-30 22:36:18 +00:00
|
|
|
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);
|
2017-04-15 05:49:01 +00:00
|
|
|
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);
|
2017-03-30 22:36:18 +00:00
|
|
|
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);
|
2017-04-15 05:49:01 +00:00
|
|
|
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);
|
2017-06-18 01:58:13 +00:00
|
|
|
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,
|
2017-06-18 01:58:13 +00:00
|
|
|
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,
|
2017-06-18 01:58:13 +00:00
|
|
|
const zeus::CTransform& xf, const CMaterialFilter& filter);
|
2017-09-17 03:13:03 +00:00
|
|
|
static bool DetectStaticCollisionBoolean_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
|
2017-06-18 01:58:13 +00:00
|
|
|
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,
|
2017-06-18 01:58:13 +00:00
|
|
|
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,
|
2017-06-18 01:58:13 +00:00
|
|
|
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,
|
2017-06-18 01:58:13 +00:00
|
|
|
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,
|
2017-06-22 17:56:51 +00:00
|
|
|
CCollisionInfo& infoOut, double& d);
|
2017-06-18 01:58:13 +00:00
|
|
|
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);
|
2017-06-18 01:58:13 +00:00
|
|
|
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,
|
2017-06-18 01:58:13 +00:00
|
|
|
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);
|
2017-01-04 04:08:30 +00:00
|
|
|
};
|
2016-04-17 22:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_CGAMECOLLISION_HPP__
|