CSnakeWeedSwarm: Fix lighting

This commit is contained in:
Luke Street 2020-03-01 03:05:16 -05:00
parent 17b9813b3e
commit 12393d4c4d
2 changed files with 17 additions and 18 deletions

View File

@ -104,11 +104,11 @@ void CSnakeWeedSwarm::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId id, CS
void CSnakeWeedSwarm::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
if (!frustum.aabbFrustumTest(x144_touchBounds)) {
SetCalculateLighting(true);
xe4_30_outOfFrustum = true;
return;
}
SetCalculateLighting(false);
xe4_30_outOfFrustum = false;
for (const auto& modelData : x1b0_modelData) {
modelData->GetAnimationData()->PreRender();
}
@ -225,16 +225,16 @@ void CSnakeWeedSwarm::Think(float dt, CStateManager& mgr) {
int raisedBoids = 0;
for (auto& boid : x134_boids) {
const zeus::CVector3f& pos = boid.GetPosition();
EBoidState state = boid.GetState();
const EBoidState state = boid.GetState();
if (state == EBoidState::Raised) {
raisedBoids++;
if (x1f4_particleGen2 && emitParticle) {
EmitParticles2(pos);
}
} else if (state == EBoidState::Raising) {
boid.Set_x14(boid.Get_x14() - dt * boid.Get_x18());
if (boid.Get_x14() <= 0.f) {
boid.Set_x14(0.f);
boid.SetYOffset(boid.GetYOffset() - dt * boid.Get_x18());
if (boid.GetYOffset() <= 0.f) {
boid.SetYOffset(0.f);
boid.SetState(EBoidState::Raised);
}
} else if (state == EBoidState::x2) {
@ -245,12 +245,11 @@ void CSnakeWeedSwarm::Think(float dt, CStateManager& mgr) {
EmitParticles1(pos);
}
} else if (state == EBoidState::x3) {
boid.Set_x14(dt * boid.Get_x18() + boid.Get_x14());
float max = x110_ * boid.Get_x20();
if (boid.Get_x14() >= max) {
boid.Set_x14(max);
float random = mgr.GetActiveRandom()->Float();
boid.Set_x10(x10c_ * random + x108_);
boid.SetYOffset(dt * boid.Get_x18() + boid.GetYOffset());
const float max = x110_ * boid.Get_x20();
if (boid.GetYOffset() >= max) {
boid.SetYOffset(max);
boid.Set_x10(x10c_ * mgr.GetActiveRandom()->Float() + x108_);
boid.SetState(EBoidState::x2);
}
}
@ -412,7 +411,7 @@ void CSnakeWeedSwarm::RenderBoid(u32 idx, const CBoid& boid, u32& posesToBuild)
model.Calculate(modelData->GetAnimationData()->GetPose(), useFlags, {}, nullptr);
}
const zeus::CTransform& xf =
zeus::CTransform::Translate(boid.GetPosition() - zeus::CVector3f(0.f, 0.f, boid.Get_x14())) *
zeus::CTransform::Translate(boid.GetPosition() - zeus::CVector3f(0.f, 0.f, boid.GetYOffset())) *
zeus::CTransform::Scale(boid.Get_x20());
CGraphics::SetModelMatrix(xf);
modelData->GetAnimationData()->Render(model, useFlags, {}, nullptr);

View File

@ -28,24 +28,24 @@ public:
zeus::CVector3f x0_pos;
EBoidState xc_state;
float x10_ = 0.f; // some timer
float x14_; // height?
float x14_yOffset;
float x18_;
float x1c_ = 0.f;
float x20_;
public:
constexpr CBoid(const zeus::CVector3f& pos, float f1, float f2, float f3)
: x0_pos(pos), xc_state(EBoidState::Raising), x14_(f1), x18_(f2), x20_(f3) {}
: x0_pos(pos), xc_state(EBoidState::Raising), x14_yOffset(f1), x18_(f2), x20_(f3) {}
constexpr const zeus::CVector3f& GetPosition() const { return x0_pos; }
constexpr EBoidState GetState() const { return xc_state; }
constexpr float Get_x10() const { return x10_; }
constexpr float Get_x14() const { return x14_; }
constexpr float GetYOffset() const { return x14_yOffset; }
constexpr float Get_x18() const { return x18_; }
constexpr float Get_x20() const { return x20_; }
void SetState(EBoidState v) { xc_state = v; fmt::print(fmt("Setting boid state {}"), v); }
constexpr void SetState(EBoidState v) { xc_state = v; }
constexpr void Set_x10(float v) { x10_ = v; }
constexpr void Set_x14(float v) { x14_ = v; }
constexpr void SetYOffset(float v) { x14_yOffset = v; }
constexpr void Set_x18(float v) { x18_ = v; }
};