CDoorExtra: Tidying up

- Fix wonky formatting
- Apply const
This commit is contained in:
Lioncash 2020-06-19 02:38:32 -04:00
parent 0ec31eef71
commit b559df4e0a

View File

@ -7,18 +7,21 @@ CDoorExtra::CDoorExtra(CScriptObject* pInstance, CScene* pScene, CScriptNode* pP
CStructProperty* pProperties = pInstance->Template()->Properties(); CStructProperty* pProperties = pInstance->Template()->Properties();
mShieldModelProp = CAssetRef(pInstance->PropertyData(), pProperties->ChildByID(0xB20CC271)); mShieldModelProp = CAssetRef(pInstance->PropertyData(), pProperties->ChildByID(0xB20CC271));
if (mShieldModelProp.IsValid()) PropertyModified(mShieldModelProp.Property()); if (mShieldModelProp.IsValid())
PropertyModified(mShieldModelProp.Property());
if (mGame >= EGame::Echoes) if (mGame >= EGame::Echoes)
{ {
mShieldColorProp = CColorRef(pInstance->PropertyData(), pProperties->ChildByID(0x47B4E863)); mShieldColorProp = CColorRef(pInstance->PropertyData(), pProperties->ChildByID(0x47B4E863));
if (mShieldColorProp.IsValid()) PropertyModified(mShieldColorProp.Property()); if (mShieldColorProp.IsValid())
PropertyModified(mShieldColorProp.Property());
} }
else else
{ {
mDisabledProp = CBoolRef(pInstance->PropertyData(), pProperties->ChildByID(0xDEE730F5)); mDisabledProp = CBoolRef(pInstance->PropertyData(), pProperties->ChildByID(0xDEE730F5));
if (mDisabledProp.IsValid()) PropertyModified(mDisabledProp.Property()); if (mDisabledProp.IsValid())
PropertyModified(mDisabledProp.Property());
} }
} }
@ -35,12 +38,10 @@ void CDoorExtra::PropertyModified(IProperty* pProperty)
MarkTransformChanged(); MarkTransformChanged();
} }
else if (pProperty == mShieldColorProp) else if (pProperty == mShieldColorProp)
{ {
mShieldColor = mShieldColorProp.Get(); mShieldColor = mShieldColorProp.Get();
} }
else if (pProperty == mDisabledProp) else if (pProperty == mDisabledProp)
{ {
// The Echoes demo doesn't have the shield color property. The color is // The Echoes demo doesn't have the shield color property. The color is
@ -54,9 +55,14 @@ void CDoorExtra::PropertyModified(IProperty* pProperty)
void CDoorExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo) void CDoorExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
{ {
if (!mpShieldModel) return; if (!mpShieldModel)
if (rkViewInfo.GameMode && !mpInstance->IsActive()) return; return;
if (!rkViewInfo.GameMode && ((rkViewInfo.ShowFlags & EShowFlag::ObjectGeometry) == 0)) return;
if (rkViewInfo.GameMode && !mpInstance->IsActive())
return;
if (!rkViewInfo.GameMode && ((rkViewInfo.ShowFlags & EShowFlag::ObjectGeometry) == 0))
return;
if (mpParent->IsVisible() && rkViewInfo.ViewFrustum.BoxInFrustum(AABox())) if (mpParent->IsVisible() && rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
{ {
@ -75,7 +81,7 @@ void CDoorExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCom
CGraphics::SetupAmbientColor(); CGraphics::SetupAmbientColor();
CGraphics::UpdateVertexBlock(); CGraphics::UpdateVertexBlock();
CColor Tint = mpParent->TintColor(rkViewInfo) * mShieldColor; const CColor Tint = mpParent->TintColor(rkViewInfo) * mShieldColor;
CGraphics::sPixelBlock.TintColor = Tint; CGraphics::sPixelBlock.TintColor = Tint;
CGraphics::sPixelBlock.SetAllTevColors(CColor::White()); CGraphics::sPixelBlock.SetAllTevColors(CColor::White());
@ -92,11 +98,14 @@ void CDoorExtra::DrawSelection()
void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo) void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo)
{ {
if (!mpShieldModel) return; if (!mpShieldModel)
if (rkViewInfo.GameMode && !mpInstance->IsActive()) return; return;
if (rkViewInfo.GameMode && !mpInstance->IsActive())
return;
const CRay& Ray = rTester.Ray(); const CRay& Ray = rTester.Ray();
std::pair<bool,float> BoxResult = AABox().IntersectsRay(Ray); const std::pair<bool, float> BoxResult = AABox().IntersectsRay(Ray);
if (BoxResult.first) if (BoxResult.first)
rTester.AddNodeModel(this, mpShieldModel); rTester.AddNodeModel(this, mpShieldModel);
@ -104,20 +113,20 @@ void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SView
SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo) SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay& rkRay, uint32 AssetID, const SViewInfo& rkViewInfo)
{ {
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions(); const FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
SRayIntersection Out; SRayIntersection Out;
Out.pNode = mpParent; Out.pNode = mpParent;
Out.ComponentIndex = AssetID; Out.ComponentIndex = AssetID;
CRay TransformedRay = rkRay.Transformed(Transform().Inverse()); const CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
std::pair<bool,float> Result = mpShieldModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & ERenderOption::EnableBackfaceCull) == 0)); const std::pair<bool, float> Result = mpShieldModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & ERenderOption::EnableBackfaceCull) == 0));
if (Result.first) if (Result.first)
{ {
Out.Hit = true; Out.Hit = true;
CVector3f HitPoint = TransformedRay.PointOnRay(Result.second); const CVector3f HitPoint = TransformedRay.PointOnRay(Result.second);
CVector3f WorldHitPoint = Transform() * HitPoint; const CVector3f WorldHitPoint = Transform() * HitPoint;
Out.Distance = rkRay.Origin().Distance(WorldHitPoint); Out.Distance = rkRay.Origin().Distance(WorldHitPoint);
} }
else else