CParticleGenInfo: Collapse TCastToPtr into conditions

Same behavior, but more compact.
This commit is contained in:
Lioncash 2020-04-05 05:10:25 -04:00
parent 39e8ee9a80
commit 852dd5c6bf
1 changed files with 31 additions and 23 deletions

View File

@ -55,9 +55,11 @@ void CParticleGenInfoGeneric::Render() { x84_system->Render(); }
void CParticleGenInfoGeneric::Update(float dt, CStateManager& stateMgr) {
x84_system->Update(dt);
if (x88_lightId != kInvalidUniqueId) {
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
if (gl)
if (x88_lightId == kInvalidUniqueId) {
return;
}
if (const TCastToPtr<CGameLight> gl = stateMgr.ObjectById(x88_lightId)) {
gl->SetLight(x84_system->GetLight());
}
}
@ -65,9 +67,11 @@ void CParticleGenInfoGeneric::Update(float dt, CStateManager& stateMgr) {
void CParticleGenInfoGeneric::SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) {
x84_system->SetOrientation(xf);
if (x88_lightId != kInvalidUniqueId) {
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
if (gl)
if (x88_lightId == kInvalidUniqueId) {
return;
}
if (const TCastToPtr<CGameLight> gl = stateMgr.ObjectById(x88_lightId)) {
gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f()));
}
}
@ -75,9 +79,11 @@ void CParticleGenInfoGeneric::SetOrientation(const zeus::CTransform& xf, CStateM
void CParticleGenInfoGeneric::SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) {
x84_system->SetTranslation(trans);
if (x88_lightId != kInvalidUniqueId) {
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
if (gl)
if (x88_lightId == kInvalidUniqueId) {
return;
}
if (const TCastToPtr<CGameLight> gl = stateMgr.ObjectById(x88_lightId)) {
gl->SetTranslation(trans);
}
}
@ -85,9 +91,11 @@ void CParticleGenInfoGeneric::SetTranslation(const zeus::CVector3f& trans, CStat
void CParticleGenInfoGeneric::SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) {
x84_system->SetGlobalOrientation(xf);
if (x88_lightId != kInvalidUniqueId) {
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
if (gl)
if (x88_lightId == kInvalidUniqueId) {
return;
}
if (const TCastToPtr<CGameLight> gl = stateMgr.ObjectById(x88_lightId)) {
gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f()));
}
}
@ -95,9 +103,11 @@ void CParticleGenInfoGeneric::SetGlobalOrientation(const zeus::CTransform& xf, C
void CParticleGenInfoGeneric::SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) {
x84_system->SetGlobalTranslation(trans);
if (x88_lightId != kInvalidUniqueId) {
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
if (gl)
if (x88_lightId == kInvalidUniqueId) {
return;
}
if (const TCastToPtr<CGameLight> gl = stateMgr.ObjectById(x88_lightId)) {
gl->SetTranslation(trans);
}
}
@ -107,9 +117,7 @@ void CParticleGenInfoGeneric::SetGlobalScale(const zeus::CVector3f& scale) { x84
void CParticleGenInfoGeneric::SetParticleEmission(bool isActive, CStateManager& stateMgr) {
x84_system->SetParticleEmission(isActive);
TCastToPtr<CGameLight> gl(stateMgr.ObjectById(x88_lightId));
if (gl) {
if (const TCastToPtr<CGameLight> gl = stateMgr.ObjectById(x88_lightId)) {
gl->SetActive(isActive);
}
}