De-hardcode max entity count

This commit is contained in:
Phillip Stephens 2021-06-06 16:53:41 -07:00
parent 89378700f7
commit 5f1aed51cb
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
64 changed files with 246 additions and 238 deletions

View File

@ -27,7 +27,7 @@ class CObjectList {
s16 next = -1;
s16 prev = -1;
};
std::array<SObjectListEntry, 1024> x0_list; // was an rstl::prereserved_vector
std::array<SObjectListEntry, kMaxEntities> x0_list; // was an rstl::reserved_vector
EGameObjectList x2004_listEnum;
s16 x2008_firstId = -1;
u16 x200a_count = 0;

View File

@ -233,7 +233,7 @@ s16 CSortedListManager::CalculateIntersections(ESortedList la, ESortedList lb, s
return headId;
}
void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const zeus::CVector3f& pos,
void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& out, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter,
const CActor* actor) {
if (mag == 0.f) {
@ -246,7 +246,7 @@ void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& o
BuildNearList(out, zeus::CAABox(mins, maxs), filter, actor);
}
void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const CActor& actor,
void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& out, const CActor& actor,
const zeus::CAABox& aabb) {
const CMaterialFilter& filter = actor.GetMaterialFilter();
s16 id = ConstructIntersectionArray(aabb);
@ -262,7 +262,7 @@ void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& o
}
}
void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const zeus::CAABox& aabb,
void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& out, const zeus::CAABox& aabb,
const CMaterialFilter& filter, const CActor* actor) {
s16 id = ConstructIntersectionArray(aabb);
while (id != -1) {

View File

@ -11,7 +11,7 @@ namespace metaforce {
enum class ESortedList { MinX, MinY, MinZ, MaxX, MaxY, MaxZ };
struct SSortedList {
std::array<s16, 1024> x0_ids;
std::array<s16, kMaxEntities> x0_ids;
u32 x800_size = 0;
void Reset() { x0_ids.fill(-1); }
SSortedList() { Reset(); }
@ -28,7 +28,7 @@ class CSortedListManager {
SNode() = default;
SNode(const CActor* act, const zeus::CAABox& aabb) : x0_actor(act), x4_box(aabb), x2a_populated(true) {}
};
std::array<SNode, 1024> x0_nodes;
std::array<SNode, kMaxEntities> x0_nodes;
std::array<SSortedList, 6> xb000_sortedLists;
void Reset();
void AddToLinkedList(s16 nodeId, s16& headId, s16& tailId);
@ -43,10 +43,10 @@ class CSortedListManager {
public:
CSortedListManager();
void BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const zeus::CVector3f& pos,
void BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& out, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter, const CActor* actor);
void BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const CActor& actor, const zeus::CAABox& aabb);
void BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const zeus::CAABox& aabb,
void BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& out, const CActor& actor, const zeus::CAABox& aabb);
void BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& out, const zeus::CAABox& aabb,
const CMaterialFilter& filter, const CActor* actor);
void Remove(const CActor* actor);
void Move(const CActor* actor, const zeus::CAABox& aabb);

View File

@ -374,7 +374,7 @@ TAreaId CStateManager::GetVisAreaId() const {
const zeus::CVector3f& camTranslation = ballCam->GetTranslation();
zeus::CAABox camAABB(camTranslation, camTranslation);
camAABB.accumulateBounds(x84c_player->GetTranslation());
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
BuildNearList(nearList, camAABB,
CMaterialFilter(EMaterialTypes::AIBlock, CMaterialList(), CMaterialFilter::EFilterType::Include),
nullptr);
@ -811,7 +811,7 @@ void CStateManager::DrawWorld() {
bool morphingPlayerVisible = false;
int thermalActorCount = 0;
std::array<CActor*, 1024> thermalActorArr;
std::array<CActor*, kMaxEntities> thermalActorArr;
for (int i = 0; i < areaCount; ++i) {
const CGameArea& area = *areaArr[i];
CPVSVisSet& pvs = pvsArr[i];
@ -1696,7 +1696,7 @@ void CStateManager::ApplyDamageToWorld(TUniqueId damager, const CActor& actor, c
bomb = True(weapon->GetAttribField() & (EProjectileAttrib::Bombs | EProjectileAttrib::PowerBombs));
}
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
BuildNearList(nearList, aabb, filter, &actor);
for (const auto& id : nearList) {
CEntity* ent = ObjectById(id);
@ -1735,7 +1735,7 @@ void CStateManager::ApplyDamageToWorld(TUniqueId damager, const CActor& actor, c
void CStateManager::ProcessRadiusDamage(const CActor& damager, CActor& damagee, TUniqueId senderId,
const CDamageInfo& info, const CMaterialFilter& filter) {
const zeus::CAABox aabb(damager.GetTranslation() - info.GetRadius(), damager.GetTranslation() + info.GetRadius());
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
BuildNearList(nearList, aabb, filter, nullptr);
for (const auto& id : nearList) {
CEntity* ent = ObjectById(id);
@ -1797,7 +1797,7 @@ void CStateManager::ApplyRadiusDamage(const CActor& a1, const zeus::CVector3f& p
}
bool CStateManager::TestRayDamage(const zeus::CVector3f& pos, const CActor& damagee,
const rstl::reserved_vector<TUniqueId, 1024>& nearList) const {
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList) const {
const CHealthInfo* hInfo = const_cast<CActor&>(damagee).HealthInfo(const_cast<CStateManager&>(*this));
if (hInfo == nullptr) {
return false;
@ -1846,20 +1846,20 @@ bool CStateManager::RayCollideWorld(const zeus::CVector3f& start, const zeus::CV
zeus::CVector3f delta = end - start;
const float mag = delta.magnitude();
delta = delta / mag;
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
BuildNearList(nearList, start, delta, mag, filter, damagee);
return RayCollideWorldInternal(start, end, filter, nearList, damagee);
}
bool CStateManager::RayCollideWorld(const zeus::CVector3f& start, const zeus::CVector3f& end,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const CMaterialFilter& filter, const CActor* damagee) const {
return RayCollideWorldInternal(start, end, filter, nearList, damagee);
}
bool CStateManager::RayCollideWorldInternal(const zeus::CVector3f& start, const zeus::CVector3f& end,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const CActor* damagee) const {
const zeus::CVector3f delta = end - start;
if (!delta.canBeNormalized()) {
@ -2373,8 +2373,8 @@ void CStateManager::MoveActors(float dt) {
}
void CStateManager::CrossTouchActors() {
std::array<bool, 1024> visits{};
rstl::reserved_vector<TUniqueId, 1024> nearList;
std::array<bool, kMaxEntities> visits{};
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
for (CEntity* ent : GetActorObjectList()) {
if (ent == nullptr) {
@ -2681,18 +2681,18 @@ void CStateManager::AreaLoaded(TAreaId aid) {
x880_envFxManager->AreaLoaded();
}
void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const zeus::CVector3f& v1,
void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& listOut, const zeus::CVector3f& v1,
const zeus::CVector3f& v2, float f1, const CMaterialFilter& filter,
const CActor* actor) const {
x874_sortedListManager->BuildNearList(listOut, v1, v2, f1, filter, actor);
}
void CStateManager::BuildColliderList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const CActor& actor,
void CStateManager::BuildColliderList(rstl::reserved_vector<TUniqueId, kMaxEntities>& listOut, const CActor& actor,
const zeus::CAABox& aabb) const {
x874_sortedListManager->BuildNearList(listOut, actor, aabb);
}
void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const zeus::CAABox& aabb,
void CStateManager::BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& listOut, const zeus::CAABox& aabb,
const CMaterialFilter& filter, const CActor* actor) const {
x874_sortedListManager->BuildNearList(listOut, aabb, filter, actor);
}
@ -2800,7 +2800,7 @@ CRayCastResult CStateManager::RayStaticIntersection(const zeus::CVector3f& pos,
CRayCastResult CStateManager::RayWorldIntersection(TUniqueId& idOut, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, float length,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& list) const {
const rstl::reserved_vector<TUniqueId, kMaxEntities>& list) const {
return CGameCollision::RayWorldIntersection(*this, idOut, pos, dir, length, filter, list);
}

View File

@ -86,7 +86,7 @@ public:
private:
s16 x0_nextFreeIndex = 0;
std::array<u16, 1024> x4_idxArr{};
std::array<u16, kMaxEntities> x4_idxArr{};
/*
std::unique_ptr<CObjectList> x80c_allObjs;
@ -298,14 +298,14 @@ public:
void ProcessRadiusDamage(const CActor&, CActor&, TUniqueId senderId, const CDamageInfo& info, const CMaterialFilter&);
void ApplyRadiusDamage(const CActor&, const zeus::CVector3f&, CActor&, const CDamageInfo& info);
bool TestRayDamage(const zeus::CVector3f& pos, const CActor& damagee,
const rstl::reserved_vector<TUniqueId, 1024>& nearList) const;
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList) const;
bool RayCollideWorld(const zeus::CVector3f& start, const zeus::CVector3f& end, const CMaterialFilter& filter,
const CActor* damagee) const;
bool RayCollideWorld(const zeus::CVector3f& start, const zeus::CVector3f& end,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, const CMaterialFilter& filter,
const CActor* damagee) const;
bool RayCollideWorldInternal(const zeus::CVector3f& start, const zeus::CVector3f& end, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, const CActor* damagee) const;
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, const CActor* damagee) const;
bool MultiRayCollideWorld(const zeus::CMRay& ray, const CMaterialFilter& filter) const;
void TestBombHittingWater(const CActor& damager, const zeus::CVector3f& pos, CActor& damagee);
bool ApplyLocalDamage(const zeus::CVector3f&, const zeus::CVector3f&, CActor&, float, const CWeaponMode&);
@ -344,10 +344,10 @@ public:
void AreaUnloaded(TAreaId);
void PrepareAreaUnload(TAreaId);
void AreaLoaded(TAreaId);
void BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const zeus::CVector3f&, const zeus::CVector3f&,
void BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& listOut, const zeus::CVector3f&, const zeus::CVector3f&,
float, const CMaterialFilter&, const CActor*) const;
void BuildColliderList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const CActor&, const zeus::CAABox&) const;
void BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& listOut, const zeus::CAABox&, const CMaterialFilter&,
void BuildColliderList(rstl::reserved_vector<TUniqueId, kMaxEntities>& listOut, const CActor&, const zeus::CAABox&) const;
void BuildNearList(rstl::reserved_vector<TUniqueId, kMaxEntities>& listOut, const zeus::CAABox&, const CMaterialFilter&,
const CActor*) const;
void UpdateActorInSortedLists(CActor&);
void UpdateSortedLists();
@ -358,7 +358,7 @@ public:
const CMaterialFilter& filter) const;
CRayCastResult RayWorldIntersection(TUniqueId& idOut, const zeus::CVector3f& pos, const zeus::CVector3f& dir,
float length, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& list) const;
const rstl::reserved_vector<TUniqueId, kMaxEntities>& list) const;
void UpdateObjectInLists(CEntity&);
TUniqueId AllocateUniqueId();
void DeferStateTransition(EStateManagerTransition t);

View File

@ -266,7 +266,7 @@ constexpr CMaterialFilter BallCameraFilter = CMaterialFilter::MakeIncludeExclude
void CBallCamera::BuildSplineNav(CStateManager& mgr) {
zeus::CVector3f ballPos = mgr.GetPlayer().GetBallPosition();
TUniqueId intersectId = kInvalidUniqueId;
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
CRayCastResult result =
mgr.RayWorldIntersection(intersectId, ballPos, zeus::skDown, 20.f, BallCameraFilter, nearList);
float downFactor = result.IsValid() ? zeus::clamp(0.f, result.GetT() / 20.f, 1.f) : 1.f;
@ -325,7 +325,7 @@ void CBallCamera::BuildSplineArc(CStateManager& mgr) {
delta = rot.transform(delta);
zeus::CVector3f pt1 = halfwayPoint + delta;
TUniqueId intersectId = kInvalidUniqueId;
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
CRayCastResult result =
mgr.RayWorldIntersection(intersectId, pt1, -delta.normalized(), delta.magnitude(), BallCameraFilter, nearList);
if (result.IsValid()) {
@ -529,7 +529,7 @@ void CBallCamera::CheckFailsafe(float dt, CStateManager& mgr) {
zeus::CVector3f camToBall = ballPos - GetTranslation();
float camToBallMag = camToBall.magnitude();
camToBall.normalize();
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, GetTranslation(), camToBall, camToBallMag, BallCameraFilter, nullptr);
CRayCastResult result = mgr.RayWorldIntersection(x368_obscuringObjectId, GetTranslation(), camToBall, camToBallMag,
BallCameraFilter, nearList);
@ -984,7 +984,7 @@ zeus::CVector3f CBallCamera::ApplyColliders() {
}
void CBallCamera::UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& it,
int count, float tolerance, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
int count, float tolerance, const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
float dt, CStateManager& mgr) {
if (it < colliderList.size()) {
x310_idealLookVec = {0.f, g_tweakBall->GetBallCameraOffset().y(), g_tweakPlayer->GetPlayerBallHalfExtent()};
@ -1033,7 +1033,7 @@ void CBallCamera::UpdateColliders(const zeus::CTransform& xf, std::vector<CCamer
}
zeus::CVector3f CBallCamera::AvoidGeometry(const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, float dt,
CStateManager& mgr) {
switch (x328_avoidGeomCycle) {
case 0:
@ -1059,7 +1059,7 @@ zeus::CVector3f CBallCamera::AvoidGeometry(const zeus::CTransform& xf,
}
zeus::CVector3f CBallCamera::AvoidGeometryFull(const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, float dt,
CStateManager& mgr) {
UpdateColliders(xf, x264_smallColliders, x2d0_smallColliderIt, x264_smallColliders.size(), 4.f, nearList, dt, mgr);
UpdateColliders(xf, x274_mediumColliders, x2d4_mediumColliderIt, x274_mediumColliders.size(), 4.f, nearList, dt, mgr);
@ -1153,7 +1153,7 @@ void CBallCamera::UpdateUsingColliders(float dt, CStateManager& mgr) {
}
}
x334_collidersAABB = CalculateCollidersBoundingBox(x284_largeColliders, mgr);
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, x334_collidersAABB, BallCameraFilter,
TCastToConstPtr<CActor>(mgr.GetObjectById(x46c_collisionActorId)).GetPtr());
if (!x18c_31_clearLOS && x368_obscuringObjectId == kInvalidUniqueId) {
@ -1549,7 +1549,7 @@ zeus::CVector3f CBallCamera::GetFailsafeSplinePoint(const std::vector<zeus::CVec
bool CBallCamera::CheckFailsafeFromMorphBallState(CStateManager& mgr) const {
TUniqueId xbb8 = kInvalidUniqueId;
float curT = 0.f;
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
rstl::reserved_vector<CRayCastResult, 6> resultsA;
rstl::reserved_vector<CRayCastResult, 6> resultsB;
while (curT < 6.f) {
@ -1584,7 +1584,7 @@ bool CBallCamera::CheckFailsafeFromMorphBallState(CStateManager& mgr) const {
}
bool CBallCamera::SplineIntersectTest(CMaterialList& intersectMat, CStateManager& mgr) const {
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
TUniqueId xe38 = kInvalidUniqueId;
rstl::reserved_vector<CRayCastResult, 12> xacc;
rstl::reserved_vector<CRayCastResult, 12> xd10;
@ -1731,7 +1731,7 @@ zeus::CVector3f CBallCamera::FindDesiredPosition(float distance, float elevation
zeus::CAABox x13ac(ballPos - distance, ballPos + distance);
x13ac.min.z() = float(ballPos.z());
x13ac.max.z() = elev + ballPos.z();
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, x13ac, BallCameraFilter,
TCastToConstPtr<CActor>(mgr.GetObjectById(x46c_collisionActorId)).GetPtr());
zeus::CQuaternion rotNeg;
@ -1803,7 +1803,7 @@ zeus::CVector3f CBallCamera::FindDesiredPosition(float distance, float elevation
zeus::CAABox findBounds(ballPos - distance, ballPos + distance);
findBounds.min.z() = float(ballPos.z());
findBounds.max.z() = elev + ballPos.z();
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, findBounds, BallCameraFilter,
TCastToConstPtr<CActor>(mgr.GetObjectById(x46c_collisionActorId)).GetPtr());
zeus::CQuaternion rotNeg2;
@ -1858,7 +1858,7 @@ bool CBallCamera::DetectCollision(const zeus::CVector3f& from, const zeus::CVect
aabb.accumulateBounds(from);
aabb.accumulateBounds(to);
aabb = zeus::CAABox(aabb.min - margin, aabb.max + margin);
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildColliderList(nearList, mgr.GetPlayer(), aabb);
CAreaCollisionCache cache(aabb);
CGameCollision::BuildAreaCollisionCache(mgr, cache);
@ -1978,7 +1978,7 @@ bool CBallCamera::CheckTransitionLineOfSight(const zeus::CVector3f& eyePos, cons
aabb.accumulateBounds(eyePos);
aabb.accumulateBounds(behindPos);
aabb = zeus::CAABox(aabb.min - margin, aabb.max + margin);
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildColliderList(nearList, mgr.GetPlayer(), aabb);
CAreaCollisionCache cache(aabb);
CGameCollision::BuildAreaCollisionCache(mgr, cache);

View File

@ -212,11 +212,11 @@ private:
int numObscured) const;
zeus::CVector3f ApplyColliders();
void UpdateColliders(const zeus::CTransform& xf, std::vector<CCameraCollider>& colliderList, int& it, int count,
float tolerance, const rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt,
float tolerance, const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, float dt,
CStateManager& mgr);
zeus::CVector3f AvoidGeometry(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
zeus::CVector3f AvoidGeometry(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
float dt, CStateManager& mgr);
zeus::CVector3f AvoidGeometryFull(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
zeus::CVector3f AvoidGeometryFull(const zeus::CTransform& xf, const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
float dt, CStateManager& mgr);
zeus::CAABox CalculateCollidersBoundingBox(const std::vector<CCameraCollider>& colliderList,
CStateManager& mgr) const;

View File

@ -38,14 +38,14 @@ void CGroundMovement::CheckFalling(CPhysicsActor& actor, CStateManager& mgr, flo
}
void CGroundMovement::MoveGroundCollider(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* nearList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>* nearList) {
CMotionState oldState = actor.GetMotionState();
CMotionState newState = actor.PredictMotion_Internal(dt);
float deltaMag = newState.x0_translation.magnitude();
TUniqueId idDetect = kInvalidUniqueId;
CCollisionInfoList collisionList;
zeus::CAABox motionVol = actor.GetMotionVolume(dt);
rstl::reserved_vector<TUniqueId, 1024> useColliderList;
rstl::reserved_vector<TUniqueId, kMaxEntities> useColliderList;
if (nearList != nullptr) {
useColliderList = *nearList;
}
@ -114,7 +114,7 @@ void CGroundMovement::MoveGroundCollider(CStateManager& mgr, CPhysicsActor& acto
}
bool CGroundMovement::ResolveUpDown(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, 1024>& nearList,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
float stepUp, float stepDown, float& fOut, CCollisionInfoList& list) {
float zextent = stepDown;
if (list.GetCount() <= 0) {
@ -178,7 +178,7 @@ bool CGroundMovement::ResolveUpDown(CAreaCollisionCache& cache, CStateManager& m
bool CGroundMovement::MoveGroundColliderZ(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
const CMaterialFilter& filter,
rstl::reserved_vector<TUniqueId, 1024>& nearList, float amt, float& resolved,
rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, float amt, float& resolved,
CCollisionInfoList& list, TUniqueId& idOut) {
actor.MoveCollisionPrimitive({0.f, 0.f, amt});
@ -238,7 +238,7 @@ bool CGroundMovement::MoveGroundColliderZ(CAreaCollisionCache& cache, CStateMana
void CGroundMovement::MoveGroundColliderXY(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
const CMaterialFilter& filter,
rstl::reserved_vector<TUniqueId, 1024>& nearList, float dt) {
rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, float dt) {
bool didCollide = false;
bool isPlayer = actor.GetMaterialList().HasMaterial(EMaterialTypes::Player);
float remDt = dt;
@ -335,9 +335,9 @@ zeus::CVector3f CGroundMovement::CollisionDamping(const zeus::CVector3f& vel, co
}
void CGroundMovement::MoveGroundCollider_New(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* nearList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>* nearList) {
zeus::CAABox motionVol = actor.GetMotionVolume(dt);
rstl::reserved_vector<TUniqueId, 1024> useNearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> useNearList;
if (nearList != nullptr) {
useNearList = *nearList;
} else {
@ -638,7 +638,7 @@ static bool RemovePositiveZComponentFromNormal(zeus::CVector3f& vec) {
}
CMaterialList CGroundMovement::MoveObjectAnalytical(CStateManager& mgr, CPhysicsActor& actor, float dt,
rstl::reserved_vector<TUniqueId, 1024>& nearList,
rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
CAreaCollisionCache& cache, const SMovementOptions& opts,
SMoveObjectResult& result) {
result.x6c_processedCollisions = 0;

View File

@ -47,24 +47,24 @@ public:
static void CheckFalling(CPhysicsActor& actor, CStateManager& mgr, float);
static void MoveGroundCollider(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* nearList);
const rstl::reserved_vector<TUniqueId, kMaxEntities>* nearList);
static bool ResolveUpDown(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, 1024>& nearList, float,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, float,
float, float&, CCollisionInfoList& list);
static bool MoveGroundColliderZ(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, 1024>& nearList,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
float, float&, CCollisionInfoList& list, TUniqueId& idOut);
static void MoveGroundColliderXY(CAreaCollisionCache& cache, CStateManager& mgr, CPhysicsActor& actor,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, 1024>& nearList,
const CMaterialFilter& filter, rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
float);
static zeus::CVector3f CollisionDamping(const zeus::CVector3f& a, const zeus::CVector3f& b, const zeus::CVector3f& c,
float d, float e);
static void MoveGroundCollider_New(CStateManager& mgr, CPhysicsActor& actor, float,
const rstl::reserved_vector<TUniqueId, 1024>* nearList);
const rstl::reserved_vector<TUniqueId, kMaxEntities>* nearList);
static bool RemoveNormalComponent(const zeus::CVector3f&, const zeus::CVector3f&, zeus::CVector3f&, float&);
static bool RemoveNormalComponent(const zeus::CVector3f& a, zeus::CVector3f& b);
static CMaterialList MoveObjectAnalytical(CStateManager& mgr, CPhysicsActor& actor, float,
rstl::reserved_vector<TUniqueId, 1024>& nearList,
rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
CAreaCollisionCache& cache, const SMovementOptions& opts,
SMoveObjectResult& result);
};

View File

@ -226,7 +226,7 @@ bool CRagDoll::SatisfyWorldConstraints(CStateManager& mgr, int pass) {
else
exclude = CMaterialList(EMaterialTypes::Character, EMaterialTypes::Player);
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
CMaterialFilter filter = CMaterialFilter::MakeIncludeExclude(include, exclude);
mgr.BuildNearList(nearList, aabb, filter, nullptr);

View File

@ -55,7 +55,7 @@ zeus::CVector3f CSteeringBehaviors::Separation(const CPhysicsActor& actor, const
return (1.f - (posDiff.magSquared() / (separation * separation))) * posDiff.normalized();
}
zeus::CVector3f CSteeringBehaviors::Alignment(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, 1024>& list,
zeus::CVector3f CSteeringBehaviors::Alignment(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, kMaxEntities>& list,
const CStateManager& mgr) const {
zeus::CVector3f align;
@ -71,7 +71,7 @@ zeus::CVector3f CSteeringBehaviors::Alignment(const CPhysicsActor& actor, rstl::
return align * (diff / M_PIF);
}
zeus::CVector3f CSteeringBehaviors::Cohesion(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, 1024>& list,
zeus::CVector3f CSteeringBehaviors::Cohesion(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, kMaxEntities>& list,
float dampingRadius, const CStateManager& mgr) const {
zeus::CVector3f dest;
if (!list.empty()) {

View File

@ -19,9 +19,9 @@ public:
zeus::CVector3f Arrival(const CPhysicsActor& actor, const zeus::CVector3f& dest, float dampingRadius) const;
zeus::CVector3f Pursuit(const CPhysicsActor& actor, const zeus::CVector3f& v0, const zeus::CVector3f& v1) const;
zeus::CVector3f Separation(const CPhysicsActor& actor, const zeus::CVector3f& pos, float separation) const;
zeus::CVector3f Alignment(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, 1024>& list,
zeus::CVector3f Alignment(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, kMaxEntities>& list,
const CStateManager& mgr) const;
zeus::CVector3f Cohesion(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, 1024>& list,
zeus::CVector3f Cohesion(const CPhysicsActor& actor, rstl::reserved_vector<TUniqueId, kMaxEntities>& list,
float dampingRadius, const CStateManager& mgr) const;
zeus::CVector2f Flee2D(const CPhysicsActor& actor, const zeus::CVector2f& v0) const;
zeus::CVector2f Arrival2D(const CPhysicsActor& actor, const zeus::CVector2f& v0) const;

View File

@ -23,8 +23,8 @@ class CPreAdvanceIndicator {
/*
u32 x10_;
u32 x14_;
u32 x18_;
u32 x1c_;
u32 x18_fireTime;
u32 x1c_damageDelay;
u32 x20_;
u32 x24_;
u32 x28_;

View File

@ -59,7 +59,7 @@ void CGameCollision::InitCollision() {
}
void CGameCollision::MovePlayer(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>* colliderList) {
actor.SetAngularEnabled(true);
actor.AddMotionState(actor.PredictAngularMotion(dt));
if (!actor.IsUseStandardCollider()) {
@ -77,7 +77,7 @@ void CGameCollision::MovePlayer(CStateManager& mgr, CPhysicsActor& actor, float
}
void CGameCollision::MoveAndCollide(CStateManager& mgr, CPhysicsActor& actor, float dt, const ICollisionFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>* colliderList) {
bool isPlayer = actor.GetMaterialList().HasMaterial(EMaterialTypes::Player);
bool r28 = false;
bool r27 = false;
@ -94,7 +94,7 @@ void CGameCollision::MoveAndCollide(CStateManager& mgr, CPhysicsActor& actor, fl
float m3 = 0.001f / actor.GetCollisionAccuracyModifier();
zeus::CAABox motionVol = actor.GetMotionVolume(dt);
rstl::reserved_vector<TUniqueId, 1024> useColliderList;
rstl::reserved_vector<TUniqueId, kMaxEntities> useColliderList;
if (colliderList)
useColliderList = *colliderList;
else
@ -196,7 +196,7 @@ zeus::CVector3f CGameCollision::GetActorRelativeVelocities(const CPhysicsActor&
}
void CGameCollision::Move(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>* colliderList) {
if (!actor.IsMovable())
return;
if (actor.GetMaterialList().HasMaterial(EMaterialTypes::GroundCollider) || actor.WillMove(mgr)) {
@ -297,7 +297,7 @@ bool CGameCollision::RayStaticIntersectionBool(const CStateManager& mgr, const z
CRayCastResult CGameCollision::RayDynamicIntersection(const CStateManager& mgr, TUniqueId& idOut,
const zeus::CVector3f& pos, const zeus::CVector3f& dir,
float length, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList) {
CRayCastResult ret;
float bestT = length;
if (bestT <= 0.f) {
@ -323,7 +323,7 @@ CRayCastResult CGameCollision::RayDynamicIntersection(const CStateManager& mgr,
bool CGameCollision::RayDynamicIntersectionBool(const CStateManager& mgr, const zeus::CVector3f& pos,
const zeus::CVector3f& dir, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const CActor* damagee, float length) {
if (length <= 0.f) {
length = 100000.f;
@ -350,7 +350,7 @@ bool CGameCollision::RayDynamicIntersectionBool(const CStateManager& mgr, const
CRayCastResult CGameCollision::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) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList) {
CRayCastResult staticRes = RayStaticIntersection(mgr, pos, dir, mag, filter);
CRayCastResult dynamicRes = RayDynamicIntersection(mgr, idOut, pos, dir, mag, filter, nearList);
@ -405,7 +405,7 @@ float CGameCollision::GetMinExtentForCollisionPrimitive(const CCollisionPrimitiv
bool CGameCollision::DetectCollisionBoolean(const CStateManager& mgr, const CCollisionPrimitive& prim,
const zeus::CTransform& xf, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList) {
if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision) &&
DetectStaticCollisionBoolean(mgr, prim, xf, filter)) {
return true;
@ -419,7 +419,7 @@ bool CGameCollision::DetectCollisionBoolean(const CStateManager& mgr, const CCol
bool CGameCollision::DetectCollisionBoolean_Cached(const CStateManager& mgr, CAreaCollisionCache& cache,
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList) {
if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision) &&
DetectStaticCollisionBoolean_Cached(mgr, cache, prim, xf, filter)) {
return true;
@ -501,7 +501,7 @@ bool CGameCollision::DetectStaticCollisionBoolean_Cached(const CStateManager& mg
}
bool CGameCollision::DetectDynamicCollisionBoolean(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const CStateManager& mgr) {
for (const auto& id : nearList) {
if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) {
@ -520,7 +520,7 @@ bool CGameCollision::DetectDynamicCollisionBoolean(const CCollisionPrimitive& pr
bool CGameCollision::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,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, TUniqueId& idOut,
CCollisionInfoList& infoList) {
idOut = kInvalidUniqueId;
bool ret = false;
@ -542,7 +542,7 @@ bool CGameCollision::DetectCollision_Cached(const CStateManager& mgr, CAreaColli
bool CGameCollision::DetectCollision_Cached_Moving(const CStateManager& mgr, CAreaCollisionCache& cache,
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const zeus::CVector3f& dir, TUniqueId& idOut,
CCollisionInfo& infoOut, double& d) {
bool ret = false;
@ -686,7 +686,7 @@ bool CGameCollision::DetectStaticCollision_Cached_Moving(const CStateManager& mg
}
bool CGameCollision::DetectDynamicCollision(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, TUniqueId& idOut,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, TUniqueId& idOut,
CCollisionInfoList& list, const CStateManager& mgr) {
for (const auto& id : nearList) {
if (const TCastToConstPtr<CPhysicsActor> actor = mgr.GetObjectById(id)) {
@ -704,7 +704,7 @@ bool CGameCollision::DetectDynamicCollision(const CCollisionPrimitive& prim, con
}
bool CGameCollision::DetectDynamicCollisionMoving(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const zeus::CVector3f& dir, TUniqueId& idOut, CCollisionInfo& infoOut,
double& dOut, const CStateManager& mgr) {
bool ret = false;
@ -729,7 +729,7 @@ bool CGameCollision::DetectDynamicCollisionMoving(const CCollisionPrimitive& pri
bool CGameCollision::DetectCollision(const CStateManager& mgr, const CCollisionPrimitive& prim,
const zeus::CTransform& xf, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, TUniqueId& idOut,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, TUniqueId& idOut,
CCollisionInfoList& infoOut) {
bool ret = false;
CMaterialList exclude = filter.ExcludeList();
@ -894,7 +894,7 @@ void CGameCollision::CollideWithStaticBodyNoRot(CPhysicsActor& a0, const CMateri
void CGameCollision::CollisionFailsafe(const CStateManager& mgr, CAreaCollisionCache& cache, CPhysicsActor& actor,
const CCollisionPrimitive& prim,
const rstl::reserved_vector<TUniqueId, 1024>& nearList, float f1,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, float f1,
u32 failsafeTicks) {
actor.MoveCollisionPrimitive(zeus::skZero3f);
if (f1 > 0.5f) {
@ -943,7 +943,7 @@ void CGameCollision::CollisionFailsafe(const CStateManager& mgr, CAreaCollisionC
std::optional<zeus::CVector3f>
CGameCollision::FindNonIntersectingVector(const CStateManager& mgr, CAreaCollisionCache& cache, CPhysicsActor& actor,
const CCollisionPrimitive& prim,
const rstl::reserved_vector<TUniqueId, 1024>& nearList) {
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList) {
zeus::CTransform xf = actor.GetPrimitiveTransform();
zeus::CVector3f origOrigin = xf.origin;
zeus::CVector3f center = prim.CalculateAABox(xf).center();

View File

@ -25,9 +25,9 @@ class ICollisionFilter;
class CGameCollision {
static void MovePlayer(CStateManager& mgr, CPhysicsActor& actor, float dt,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList);
const rstl::reserved_vector<TUniqueId, kMaxEntities>* colliderList);
static void MoveAndCollide(CStateManager& mgr, CPhysicsActor& actor, float dt, const ICollisionFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>* colliderList);
const rstl::reserved_vector<TUniqueId, kMaxEntities>* colliderList);
static zeus::CVector3f GetActorRelativeVelocities(const CPhysicsActor& act0, const CPhysicsActor* act1);
public:
@ -39,7 +39,7 @@ public:
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);
const rstl::reserved_vector<TUniqueId, kMaxEntities>* colliderList);
static bool CanBlock(const CMaterialList&, const zeus::CUnitVector3f&);
static bool IsFloor(const CMaterialList&, const zeus::CUnitVector3f&);
@ -50,42 +50,42 @@ public:
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);
const rstl::reserved_vector<TUniqueId, kMaxEntities>& 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,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& 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);
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList);
static bool RayStaticIntersectionArea(const CGameArea& area, const zeus::CVector3f& pos, const zeus::CVector3f& dir,
float mag, const CMaterialFilter& filter);
static void BuildAreaCollisionCache(const CStateManager& mgr, CAreaCollisionCache& cache);
static float GetMinExtentForCollisionPrimitive(const CCollisionPrimitive& prim);
static bool DetectCollisionBoolean(const CStateManager& mgr, const CCollisionPrimitive& prim,
const zeus::CTransform& xf, const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList);
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList);
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);
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList);
static bool DetectStaticCollisionBoolean(const CStateManager& mgr, const CCollisionPrimitive& prim,
const zeus::CTransform& xf, const CMaterialFilter& filter);
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,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
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,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, TUniqueId& idOut,
CCollisionInfoList& infoList);
static bool DetectCollision_Cached_Moving(const CStateManager& mgr, CAreaCollisionCache& cache,
const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const zeus::CVector3f& vec, TUniqueId& idOut, CCollisionInfo& infoOut,
double&);
static bool DetectStaticCollision(const CStateManager& mgr, const CCollisionPrimitive& prim,
@ -99,14 +99,14 @@ public:
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, TUniqueId& idOut,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList, TUniqueId& idOut,
CCollisionInfoList& list, const CStateManager& mgr);
static bool DetectDynamicCollisionMoving(const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
const zeus::CVector3f& vec, TUniqueId& idOut, CCollisionInfo& infoOut,
double& d, const CStateManager& mgr);
static bool DetectCollision(const CStateManager& mgr, const CCollisionPrimitive& prim, const zeus::CTransform& xf,
const CMaterialFilter& filter, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const CMaterialFilter& filter, const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
TUniqueId& idOut, CCollisionInfoList& infoOut);
static void MakeCollisionCallbacks(CStateManager& mgr, CPhysicsActor& actor, TUniqueId id,
const CCollisionInfoList& list);
@ -117,11 +117,11 @@ public:
static void CollideWithStaticBodyNoRot(CPhysicsActor& a0, const CMaterialList& m0, const CMaterialList& m1,
const zeus::CUnitVector3f& normal, float restitution, bool);
static void CollisionFailsafe(const CStateManager& mgr, CAreaCollisionCache& cache, CPhysicsActor& actor,
const CCollisionPrimitive& prim, const rstl::reserved_vector<TUniqueId, 1024>& nearList,
const CCollisionPrimitive& prim, const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList,
float, u32 failsafeTicks);
static std::optional<zeus::CVector3f>
FindNonIntersectingVector(const CStateManager& mgr, CAreaCollisionCache& cache, CPhysicsActor& actor,
const CCollisionPrimitive& prim, const rstl::reserved_vector<TUniqueId, 1024>& nearList);
const CCollisionPrimitive& prim, const rstl::reserved_vector<TUniqueId, kMaxEntities>& nearList);
static void AvoidStaticCollisionWithinRadius(const CStateManager& mgr, CPhysicsActor& actor, u32 iterations, float dt,
float height, float size, float mass, float radius);
};

View File

@ -58,7 +58,7 @@ void CSimpleShadow::Calculate(const zeus::CAABox& aabb, const zeus::CTransform&
if (height > 0.1f + halfHeight) {
TUniqueId cid = kInvalidUniqueId;
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
CRayCastResult resD = CGameCollision::RayDynamicIntersection(
mgr, cid, pos, zeus::skDown, x40_maxObjHeight, CMaterialFilter::skPassEverything, nearList);
if (resD.IsValid() && resD.GetT() < height) {

View File

@ -128,7 +128,7 @@ void CHudRadarInterface::Draw(const CStateManager& mgr, float alpha) {
player.GetTranslation().z() - drawParms.x7c_zRadius, player.GetTranslation().x() + drawParms.x78_xyRadius,
player.GetTranslation().y() + drawParms.x78_xyRadius, player.GetTranslation().z() + drawParms.x7c_zRadius);
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, radarBounds,
CMaterialFilter(CMaterialList(EMaterialTypes::Target, EMaterialTypes::RadarObject),
CMaterialList(EMaterialTypes::ExcludeFromRadar),

View File

@ -18,7 +18,7 @@ void ClearIniSettings();
namespace metaforce {
std::array<ImGuiEntityEntry, 1024> ImGuiConsole::entities;
std::array<ImGuiEntityEntry, kMaxEntities> ImGuiConsole::entities;
std::set<TUniqueId> ImGuiConsole::inspectingEntities;
ImGuiPlayerLoadouts ImGuiConsole::loadouts;
@ -246,7 +246,7 @@ void ImGuiConsole::ShowInspectWindow(bool* isOpen) {
if (ImGui::Begin("Inspect", isOpen)) {
CObjectList& list = g_StateManager->GetAllObjectList();
ImGui::Text("Objects: %d / 1024", list.size());
ImGui::Text("Objects: %d / %d", list.size(), kMaxEntities);
ImGui::SameLine();
if (ImGui::SmallButton("Deselect all")) {
for (auto* const ent : list) {
@ -710,17 +710,7 @@ void ImGuiConsole::ShowDebugOverlay() {
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoNav;
if (m_debugOverlayCorner != -1) {
const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImVec2 workPos = viewport->WorkPos; // Use work area to avoid menu-bar/task-bar, if any!
ImVec2 workSize = viewport->WorkSize;
ImVec2 windowPos;
ImVec2 windowPosPivot;
constexpr float padding = 10.0f;
windowPos.x = (m_debugOverlayCorner & 1) != 0 ? (workPos.x + workSize.x - padding) : (workPos.x + padding);
windowPos.y = (m_debugOverlayCorner & 2) != 0 ? (workPos.y + workSize.y - padding) : (workPos.y + padding);
windowPosPivot.x = (m_debugOverlayCorner & 1) != 0 ? 1.0f : 0.0f;
windowPosPivot.y = (m_debugOverlayCorner & 2) != 0 ? 1.0f : 0.0f;
ImGui::SetNextWindowPos(windowPos, ImGuiCond_Always, windowPosPivot);
SetOverlayWindowLocation(m_debugOverlayCorner);
windowFlags |= ImGuiWindowFlags_NoMove;
}
ImGui::SetNextWindowBgAlpha(0.65f);

View File

@ -34,7 +34,7 @@ struct ImGuiEntityEntry {
class ImGuiConsole {
public:
static std::set<TUniqueId> inspectingEntities;
static std::array<ImGuiEntityEntry, 1024> entities;
static std::array<ImGuiEntityEntry, kMaxEntities> entities;
static ImGuiPlayerLoadouts loadouts;
ImGuiConsole(hecl::CVarManager& cvarMgr, hecl::CVarCommons& cvarCommons)

View File

@ -442,7 +442,7 @@ IMGUI_ENTITY_INSPECT(CScriptDistanceFog, CEntity, ScriptDistanceFog, {})
IMGUI_ENTITY_INSPECT(CScriptDockAreaChange, CEntity, ScriptDockAreaChange, {})
IMGUI_ENTITY_INSPECT(CScriptGenerator, CEntity, ScriptGenerator, {
int count = x34_spawnCount;
if (ImGui::SliderInt("Spawn Count", &count, 0, 1024)) {
if (ImGui::SliderInt("Spawn Count", &count, 0, kMaxEntities)) {
x34_spawnCount = count;
}
BITFIELD_CHECKBOX("Don't Reuse Followers", x38_24_noReuseFollowers);

View File

@ -533,7 +533,7 @@ void CSamusHud::UpdateThreatAssessment(float dt, const CStateManager& mgr) {
zeus::CAABox aabb;
aabb.accumulateBounds(player.GetTranslation() - g_tweakGui->GetThreatRange());
aabb.accumulateBounds(player.GetTranslation() + g_tweakGui->GetThreatRange());
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, aabb, filter, nullptr);
float threatDist = 9999.f;

View File

@ -443,7 +443,7 @@ void CBeetle::Generate(CStateManager& mgr, EStateMsg msg, float dt) {
if (x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Generate) {
x568_stateProg = 4;
} else if (x68_material.HasMaterial(EMaterialTypes::Solid) && x5a8_animTimeRem > 0.f) {
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, zeus::CAABox(GetTranslation() - 5.f, GetTranslation() + 5.f),
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}), this);
if (!nearList.empty()) {
@ -889,7 +889,7 @@ bool CBeetle::ShouldDoubleSnap(CStateManager& mgr, float arg) {
targetPos = role->GetTeamPosition();
zeus::CVector3f delta = targetPos - GetTranslation();
if (delta.magSquared() > dist * dist && GetTransform().basis[1].dot(delta.normalized()) > 0.98f) {
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, GetTranslation(), GetTransform().basis[1], x5a0_headbuttDist,
CMaterialFilter::MakeInclude({EMaterialTypes::Character}), this);
TUniqueId bestId = kInvalidUniqueId;
@ -915,7 +915,7 @@ bool CBeetle::ShouldJumpBack(CStateManager& mgr, float arg) {
zeus::CVector3f backDir = -GetTransform().basis[1];
const auto& aabb = GetBaseBoundingBox();
zeus::CVector3f pos = GetTranslation() + zeus::CVector3f(0.f, 0.f, (aabb.max.z() - aabb.min.z()) * 0.5f);
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, pos, backDir, x5a4_jumpBackwardDist,
CMaterialFilter::MakeInclude({EMaterialTypes::Character}), this);
TUniqueId bestId = kInvalidUniqueId;

View File

@ -177,7 +177,7 @@ void CBouncyGrenade::Explode(CStateManager& mgr, TUniqueId uid) {
if (radius > 1.f) {
const zeus::CVector3f& pos = GetTranslation();
const CMaterialFilter filter = CMaterialFilter::MakeInclude({EMaterialTypes::Player, EMaterialTypes::Character});
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, {pos - radius, pos + radius}, filter, nullptr);
for (const auto& id : nearList) {

View File

@ -191,7 +191,7 @@ void CDrone::Think(float dt, CStateManager& mgr) {
if (IsAlive() && x835_25_) {
zeus::CAABox box = GetBoundingBox();
box.accumulateBounds(GetTranslation() + 20.f * zeus::skDown);
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
mgr.BuildNearList(nearList, GetBoundingBox(), CMaterialFilter::MakeInclude({EMaterialTypes::Trigger}), this);
for (TUniqueId id : nearList) {
if (const TCastToConstPtr<CScriptWater> water = mgr.GetObjectById(id)) {
@ -468,7 +468,7 @@ void CDrone::Patrol(CStateManager& mgr, EStateMsg msg, float dt) {
SetLightEnabled(mgr, true);
x834_25_ = true;
} else if (msg == EStateMsg::Update) {
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
BuildNearList(EMaterialTypes::Character, EMaterialTypes::Player, nearList, 5.f, mgr);
if (!nearList.empty()) {
zeus::CVector3f sep = x45c_steeringBehaviors.Separation(
@ -878,7 +878,7 @@ bool CDrone::ShouldFire(CStateManager& mgr, float arg) {
}
bool CDrone::HearShot(CStateManager& mgr, float arg) {
rstl::reserved_vector<TUniqueId, 1024> nearList;
rstl::reserved_vector<TUniqueId, kMaxEntities> nearList;
BuildNearList(EMaterialTypes::Projectile, EMaterialTypes::Player, nearList, 10.f, mgr);
return std::any_of(nearList.begin(), nearList.end(), [&mgr](TUniqueId uid) {
if (TCastToConstPtr<CWeapon> wp = mgr.GetObjectById(uid))
@ -914,7 +914,7 @@ void CDrone::Burn(float duration, float damage) {
CPathFindSearch* CDrone::GetSearchPath() { return &x6b0_pathFind; }
void CDrone::BuildNearList(EMaterialTypes includeMat, EMaterialTypes excludeMat,
rstl::reserved_vector<TUniqueId, 1024>& listOut, float radius, CStateManager& mgr) {
rstl::reserved_vector<TUniqueId, kMaxEntities>& listOut, float radius, CStateManager& mgr) {
const zeus::CVector3f pos = GetTranslation();
mgr.BuildNearList(listOut, zeus::CAABox(pos - radius, pos + radius),
CMaterialFilter::MakeIncludeExclude({includeMat}, {excludeMat}), nullptr);