mirror of https://github.com/AxioDL/metaforce.git
CSnakeWeedSwarm: Mark several member functions as const
These don't alter instance state, so they can be const member functions.
This commit is contained in:
parent
43e0d16c5d
commit
4169e3d91d
|
@ -276,14 +276,14 @@ void CSnakeWeedSwarm::Think(float dt, CStateManager& mgr) {
|
||||||
x140_26_playerTouching = false;
|
x140_26_playerTouching = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::CAABox CSnakeWeedSwarm::GetBoidBox() {
|
zeus::CAABox CSnakeWeedSwarm::GetBoidBox() const {
|
||||||
const auto& scale = xe8_scale * 0.75f;
|
const auto scale = xe8_scale * 0.75f;
|
||||||
return {GetTransform().origin - scale, GetTransform().origin + scale};
|
return {GetTransform().origin - scale, GetTransform().origin + scale};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSnakeWeedSwarm::FindGround(const CStateManager& mgr) {
|
void CSnakeWeedSwarm::FindGround(const CStateManager& mgr) {
|
||||||
const auto& box = GetBoidBox();
|
const auto box = GetBoidBox();
|
||||||
const auto& result =
|
const auto result =
|
||||||
mgr.RayStaticIntersection(box.center(), zeus::skDown, box.max.z() - box.min.z(), skMaterialFilter);
|
mgr.RayStaticIntersection(box.center(), zeus::skDown, box.max.z() - box.min.z(), skMaterialFilter);
|
||||||
if (result.IsValid()) {
|
if (result.IsValid()) {
|
||||||
int ct = GetNumBoidsX() * GetNumBoidsY();
|
int ct = GetNumBoidsX() * GetNumBoidsY();
|
||||||
|
@ -295,13 +295,13 @@ void CSnakeWeedSwarm::FindGround(const CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSnakeWeedSwarm::GetNumBoidsY() {
|
int CSnakeWeedSwarm::GetNumBoidsY() const {
|
||||||
const auto& box = GetBoidBox();
|
const auto box = GetBoidBox();
|
||||||
return static_cast<int>((box.max.y() - box.min.y()) / xf4_boidSpacing) + 1;
|
return static_cast<int>((box.max.y() - box.min.y()) / xf4_boidSpacing) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSnakeWeedSwarm::GetNumBoidsX() {
|
int CSnakeWeedSwarm::GetNumBoidsX() const {
|
||||||
const auto& box = GetBoidBox();
|
const auto box = GetBoidBox();
|
||||||
return static_cast<int>((box.max.x() - box.min.x()) / xf4_boidSpacing) + 1;
|
return static_cast<int>((box.max.x() - box.min.x()) / xf4_boidSpacing) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,17 +330,17 @@ void CSnakeWeedSwarm::CreateBoids(CStateManager& mgr, int num) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::CVector2i CSnakeWeedSwarm::GetBoidIndex(const zeus::CVector3f& pos) {
|
zeus::CVector2i CSnakeWeedSwarm::GetBoidIndex(const zeus::CVector3f& pos) const {
|
||||||
const auto& box = GetBoidBox();
|
const auto box = GetBoidBox();
|
||||||
return {static_cast<int>((pos.x() - box.min.x()) / xf4_boidSpacing),
|
return {static_cast<int>((pos.x() - box.min.x()) / xf4_boidSpacing),
|
||||||
static_cast<int>((pos.y() - box.min.y()) / xf4_boidSpacing)};
|
static_cast<int>((pos.y() - box.min.y()) / xf4_boidSpacing)};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSnakeWeedSwarm::CreateBoid(const zeus::CVector3f& vec, CStateManager& mgr) {
|
bool CSnakeWeedSwarm::CreateBoid(const zeus::CVector3f& vec, CStateManager& mgr) {
|
||||||
const auto& pos = vec + zeus::CVector3f(GetBoidOffsetX(vec), GetBoidOffsetY(vec), xf8_height);
|
const auto pos = vec + zeus::CVector3f(GetBoidOffsetX(vec), GetBoidOffsetY(vec), xf8_height);
|
||||||
const auto& result = mgr.RayStaticIntersection(pos, zeus::skDown, 2.f * xf8_height, skMaterialFilter);
|
const auto result = mgr.RayStaticIntersection(pos, zeus::skDown, 2.f * xf8_height, skMaterialFilter);
|
||||||
if (result.IsValid() && result.GetPlane().normal().dot(zeus::skUp) > x11c_) {
|
if (result.IsValid() && result.GetPlane().normal().dot(zeus::skUp) > x11c_) {
|
||||||
const auto& boidPosition = result.GetPoint() - zeus::CVector3f(0.f, 0.f, x128_distanceBelowGround);
|
const auto boidPosition = result.GetPoint() - zeus::CVector3f(0.f, 0.f, x128_distanceBelowGround);
|
||||||
x134_boids.emplace_back(boidPosition, x110_maxZOffset, x114_speed + x118_speedVariation,
|
x134_boids.emplace_back(boidPosition, x110_maxZOffset, x114_speed + x118_speedVariation,
|
||||||
(x124_scaleMax - x120_scaleMin) * mgr.GetActiveRandom()->Float() + x120_scaleMin);
|
(x124_scaleMax - x120_scaleMin) * mgr.GetActiveRandom()->Float() + x120_scaleMin);
|
||||||
return true;
|
return true;
|
||||||
|
@ -348,13 +348,13 @@ bool CSnakeWeedSwarm::CreateBoid(const zeus::CVector3f& vec, CStateManager& mgr)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CSnakeWeedSwarm::GetBoidOffsetY(const zeus::CVector3f& pos) {
|
float CSnakeWeedSwarm::GetBoidOffsetY(const zeus::CVector3f& pos) const {
|
||||||
float f = 2.4729404f * pos.y() + 0.3478602f * pos.x() * pos.x();
|
const float f = 2.4729404f * pos.y() + 0.3478602f * pos.x() * pos.x();
|
||||||
return xfc_ * (2.f * std::abs(f - std::trunc(f)) - 1.f);
|
return xfc_ * (2.f * std::abs(f - std::trunc(f)) - 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CSnakeWeedSwarm::GetBoidOffsetX(const zeus::CVector3f& pos) {
|
float CSnakeWeedSwarm::GetBoidOffsetX(const zeus::CVector3f& pos) const {
|
||||||
float f = 8.21395f * pos.x() + 0.112869f * pos.y() * pos.y();
|
const float f = 8.21395f * pos.x() + 0.112869f * pos.y() * pos.y();
|
||||||
return xfc_ * (2.f * std::abs(f - std::trunc(f)) - 1.f);
|
return xfc_ * (2.f * std::abs(f - std::trunc(f)) - 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,14 +111,14 @@ private:
|
||||||
void AllocateSkinnedModels(CStateManager& mgr, CModelData::EWhichModel which);
|
void AllocateSkinnedModels(CStateManager& mgr, CModelData::EWhichModel which);
|
||||||
void HandleRadiusDamage(float radius, CStateManager& mgr, const zeus::CVector3f& pos);
|
void HandleRadiusDamage(float radius, CStateManager& mgr, const zeus::CVector3f& pos);
|
||||||
void FindGround(const CStateManager& mgr);
|
void FindGround(const CStateManager& mgr);
|
||||||
zeus::CAABox GetBoidBox();
|
zeus::CAABox GetBoidBox() const;
|
||||||
int GetNumBoidsY();
|
int GetNumBoidsY() const;
|
||||||
int GetNumBoidsX();
|
int GetNumBoidsX() const;
|
||||||
void CreateBoids(CStateManager& mgr, int num);
|
void CreateBoids(CStateManager& mgr, int num);
|
||||||
zeus::CVector2i GetBoidIndex(const zeus::CVector3f& pos);
|
zeus::CVector2i GetBoidIndex(const zeus::CVector3f& pos) const;
|
||||||
bool CreateBoid(const zeus::CVector3f& vec, CStateManager& mgr);
|
bool CreateBoid(const zeus::CVector3f& vec, CStateManager& mgr);
|
||||||
float GetBoidOffsetY(const zeus::CVector3f& pos);
|
float GetBoidOffsetY(const zeus::CVector3f& pos) const;
|
||||||
float GetBoidOffsetX(const zeus::CVector3f& pos);
|
float GetBoidOffsetX(const zeus::CVector3f& pos) const;
|
||||||
void AddBoidPosition(const zeus::CVector3f& pos);
|
void AddBoidPosition(const zeus::CVector3f& pos);
|
||||||
void CalculateTouchBounds();
|
void CalculateTouchBounds();
|
||||||
void EmitParticles1(const zeus::CVector3f& pos);
|
void EmitParticles1(const zeus::CVector3f& pos);
|
||||||
|
|
Loading…
Reference in New Issue