mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-07-03 11:45:59 +00:00
CDoorExtra: Tidying up
- Fix wonky formatting - Apply const
This commit is contained in:
parent
0ec31eef71
commit
b559df4e0a
@ -7,18 +7,21 @@ CDoorExtra::CDoorExtra(CScriptObject* pInstance, CScene* pScene, CScriptNode* pP
|
||||
CStructProperty* pProperties = pInstance->Template()->Properties();
|
||||
|
||||
mShieldModelProp = CAssetRef(pInstance->PropertyData(), pProperties->ChildByID(0xB20CC271));
|
||||
if (mShieldModelProp.IsValid()) PropertyModified(mShieldModelProp.Property());
|
||||
if (mShieldModelProp.IsValid())
|
||||
PropertyModified(mShieldModelProp.Property());
|
||||
|
||||
if (mGame >= EGame::Echoes)
|
||||
{
|
||||
mShieldColorProp = CColorRef(pInstance->PropertyData(), pProperties->ChildByID(0x47B4E863));
|
||||
if (mShieldColorProp.IsValid()) PropertyModified(mShieldColorProp.Property());
|
||||
if (mShieldColorProp.IsValid())
|
||||
PropertyModified(mShieldColorProp.Property());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
else if (pProperty == mShieldColorProp)
|
||||
{
|
||||
mShieldColor = mShieldColorProp.Get();
|
||||
}
|
||||
|
||||
else if (pProperty == mDisabledProp)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
if (!mpShieldModel) return;
|
||||
if (rkViewInfo.GameMode && !mpInstance->IsActive()) return;
|
||||
if (!rkViewInfo.GameMode && ((rkViewInfo.ShowFlags & EShowFlag::ObjectGeometry) == 0)) return;
|
||||
if (!mpShieldModel)
|
||||
return;
|
||||
|
||||
if (rkViewInfo.GameMode && !mpInstance->IsActive())
|
||||
return;
|
||||
|
||||
if (!rkViewInfo.GameMode && ((rkViewInfo.ShowFlags & EShowFlag::ObjectGeometry) == 0))
|
||||
return;
|
||||
|
||||
if (mpParent->IsVisible() && rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
|
||||
{
|
||||
@ -75,7 +81,7 @@ void CDoorExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, ERenderCom
|
||||
CGraphics::SetupAmbientColor();
|
||||
CGraphics::UpdateVertexBlock();
|
||||
|
||||
CColor Tint = mpParent->TintColor(rkViewInfo) * mShieldColor;
|
||||
const CColor Tint = mpParent->TintColor(rkViewInfo) * mShieldColor;
|
||||
|
||||
CGraphics::sPixelBlock.TintColor = Tint;
|
||||
CGraphics::sPixelBlock.SetAllTevColors(CColor::White());
|
||||
@ -92,11 +98,14 @@ void CDoorExtra::DrawSelection()
|
||||
|
||||
void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo)
|
||||
{
|
||||
if (!mpShieldModel) return;
|
||||
if (rkViewInfo.GameMode && !mpInstance->IsActive()) return;
|
||||
if (!mpShieldModel)
|
||||
return;
|
||||
|
||||
if (rkViewInfo.GameMode && !mpInstance->IsActive())
|
||||
return;
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
|
||||
const FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
|
||||
|
||||
SRayIntersection Out;
|
||||
Out.pNode = mpParent;
|
||||
Out.ComponentIndex = AssetID;
|
||||
|
||||
CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
|
||||
std::pair<bool,float> Result = mpShieldModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & ERenderOption::EnableBackfaceCull) == 0));
|
||||
const CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
|
||||
const std::pair<bool, float> Result = mpShieldModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & ERenderOption::EnableBackfaceCull) == 0));
|
||||
|
||||
if (Result.first)
|
||||
{
|
||||
Out.Hit = true;
|
||||
CVector3f HitPoint = TransformedRay.PointOnRay(Result.second);
|
||||
CVector3f WorldHitPoint = Transform() * HitPoint;
|
||||
const CVector3f HitPoint = TransformedRay.PointOnRay(Result.second);
|
||||
const CVector3f WorldHitPoint = Transform() * HitPoint;
|
||||
Out.Distance = rkRay.Origin().Distance(WorldHitPoint);
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user