Mass code cleanup

This commit is contained in:
parax0
2016-03-27 13:09:38 -06:00
parent 6b79ef2f3f
commit 82ad4fb5c8
279 changed files with 5702 additions and 7227 deletions

View File

@@ -87,10 +87,10 @@ void CDamageableTriggerExtra::UpdatePlaneTransform()
{
float Scalar = (mRenderSide == eNorth ? 1.f : -1.f);
mPosition = CVector3f(0.f, Extent.y * Scalar, 0.f);
mPosition = CVector3f(0.f, Extent.Y * Scalar, 0.f);
mRotation = CQuaternion::FromEuler(CVector3f(90.f * Scalar, 0.f, 0.f));
mScale = CVector3f(Extent.x, Extent.z, 0.f);
mCoordScale = mPlaneSize.xz();
mScale = CVector3f(Extent.X, Extent.Z, 0.f);
mCoordScale = mPlaneSize.XZ();
break;
}
@@ -99,10 +99,10 @@ void CDamageableTriggerExtra::UpdatePlaneTransform()
{
float Scalar = (mRenderSide == eWest ? 1.f : -1.f);
mPosition = CVector3f(-Extent.x * Scalar, 0.f, 0.f);
mPosition = CVector3f(-Extent.X * Scalar, 0.f, 0.f);
mRotation = CQuaternion::FromEuler(CVector3f(0.f, 90.f * Scalar, 0.f));
mScale = CVector3f(Extent.z, Extent.y, 0.f);
mCoordScale = -mPlaneSize.yz();
mScale = CVector3f(Extent.Z, Extent.Y, 0.f);
mCoordScale = -mPlaneSize.YZ();
break;
}
@@ -112,10 +112,10 @@ void CDamageableTriggerExtra::UpdatePlaneTransform()
float Scalar = (mRenderSide == eUp ? 1.f : -1.f);
float RotAngle = (mRenderSide == eUp ? 180.f : 0.f);
mPosition = CVector3f(0.f, 0.f, Extent.z * Scalar);
mPosition = CVector3f(0.f, 0.f, Extent.Z * Scalar);
mRotation = CQuaternion::FromEuler(CVector3f(0.f, RotAngle, 0.f));
mScale = CVector3f(Extent.x, Extent.y, 0.f);
mCoordScale = -mPlaneSize.xy();
mScale = CVector3f(Extent.X, Extent.Y, 0.f);
mCoordScale = -mPlaneSize.XY();
break;
}
@@ -172,33 +172,33 @@ bool CDamageableTriggerExtra::ShouldDrawNormalAssets()
return (mRenderSide == eNoRender);
}
void CDamageableTriggerExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
void CDamageableTriggerExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
{
if (ViewInfo.GameMode && !mpInstance->IsActive())
if (rkViewInfo.GameMode && !mpInstance->IsActive())
return;
if (!ViewInfo.GameMode && ((ViewInfo.ShowFlags & eShowObjectGeometry) == 0))
if (!rkViewInfo.GameMode && ((rkViewInfo.ShowFlags & eShowObjectGeometry) == 0))
return;
if (mRenderSide != eNoRender)
{
if (ViewInfo.ViewFrustum.BoxInFrustum(AABox()))
if (rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
pRenderer->AddTransparentMesh(this, -1, AABox(), eDrawMesh);
if (mpParent->IsSelected() && !ViewInfo.GameMode)
if (mpParent->IsSelected() && !rkViewInfo.GameMode)
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection);
}
}
void CDamageableTriggerExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, const SViewInfo& ViewInfo)
void CDamageableTriggerExtra::Draw(FRenderOptions Options, int /*ComponentIndex*/, const SViewInfo& rkViewInfo)
{
LoadModelMatrix();
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo);
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(rkViewInfo);
mpMat->SetCurrent(Options);
// Note: The plane the game renders this onto is 5x4.5, which is why we divide the tex coords by this value
CVector2f TexUL(0.f, mCoordScale.y / 4.5f);
CVector2f TexUR(mCoordScale.x / 5.f, mCoordScale.y / 4.5f);
CVector2f TexBR(mCoordScale.x / 5.f, 0.f);
CVector2f TexUL(0.f, mCoordScale.Y / 4.5f);
CVector2f TexUR(mCoordScale.X / 5.f, mCoordScale.Y / 4.5f);
CVector2f TexBR(mCoordScale.X / 5.f, 0.f);
CVector2f TexBL(0.f, 0.f);
CDrawUtil::DrawSquare(TexUL, TexUR, TexBR, TexBL);
}
@@ -213,40 +213,40 @@ void CDamageableTriggerExtra::DrawSelection()
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
void CDamageableTriggerExtra::RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo)
void CDamageableTriggerExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo)
{
if (mRenderSide == eNoRender) return;
if (ViewInfo.GameMode && !mpInstance->IsActive()) return;
if (rkViewInfo.GameMode && !mpInstance->IsActive()) return;
const CRay& Ray = Tester.Ray();
const CRay& rkRay = rTester.Ray();
if (ViewInfo.pRenderer->RenderOptions() & eEnableBackfaceCull)
if (rkViewInfo.pRenderer->RenderOptions() & eEnableBackfaceCull)
{
// We're guaranteed to be axis-aligned, so we can take advantage of that
// to perform a very simple backface check.
switch (mRenderSide)
{
case eNorth: if (Ray.Origin().y > AbsolutePosition().y) return; break;
case eSouth: if (Ray.Origin().y < AbsolutePosition().y) return; break;
case eWest: if (Ray.Origin().x < AbsolutePosition().x) return; break;
case eEast: if (Ray.Origin().x > AbsolutePosition().x) return; break;
case eUp: if (Ray.Origin().z > AbsolutePosition().z) return; break;
case eDown: if (Ray.Origin().z < AbsolutePosition().z) return; break;
case eNorth: if (rkRay.Origin().Y > AbsolutePosition().Y) return; break;
case eSouth: if (rkRay.Origin().Y < AbsolutePosition().Y) return; break;
case eWest: if (rkRay.Origin().X < AbsolutePosition().X) return; break;
case eEast: if (rkRay.Origin().X > AbsolutePosition().X) return; break;
case eUp: if (rkRay.Origin().Z > AbsolutePosition().Z) return; break;
case eDown: if (rkRay.Origin().Z < AbsolutePosition().Z) return; break;
}
}
std::pair<bool,float> Result = AABox().IntersectsRay(Ray);
std::pair<bool,float> Result = AABox().IntersectsRay(rkRay);
if (Result.first)
{
Tester.AddNode(this, -1, Result.second);
rTester.AddNode(this, -1, Result.second);
mCachedRayDistance = Result.second;
}
}
SRayIntersection CDamageableTriggerExtra::RayNodeIntersectTest(const CRay& Ray, u32 /*ComponentIndex*/, const SViewInfo& /*ViewInfo*/)
SRayIntersection CDamageableTriggerExtra::RayNodeIntersectTest(const CRay& rkRay, u32 /*ComponentIndex*/, const SViewInfo& /*rkViewInfo*/)
{
// The bounding box and all other tests already passed in RayAABoxIntersectTest, so we
// already know that we have a positive.
return SRayIntersection(true, mCachedRayDistance, Ray.PointOnRay(mCachedRayDistance), mpParent, -1);
return SRayIntersection(true, mCachedRayDistance, rkRay.PointOnRay(mCachedRayDistance), mpParent, -1);
}

View File

@@ -38,11 +38,11 @@ public:
void OnTransformed();
void PropertyModified(IProperty *pProperty);
bool ShouldDrawNormalAssets();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
void DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay& Ray, u32 ComponentIndex, const SViewInfo& ViewInfo);
void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 ComponentIndex, const SViewInfo& rkViewInfo);
};
#endif // CDAMAGEABLETRIGGEREXTRA_H

View File

@@ -56,33 +56,33 @@ void CDoorExtra::PropertyModified(IProperty *pProperty)
}
}
void CDoorExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
void CDoorExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
{
if (!mpShieldModel) return;
if (ViewInfo.GameMode && !mpInstance->IsActive()) return;
if (!ViewInfo.GameMode && ((ViewInfo.ShowFlags & eShowObjectGeometry) == 0)) return;
if (rkViewInfo.GameMode && !mpInstance->IsActive()) return;
if (!rkViewInfo.GameMode && ((rkViewInfo.ShowFlags & eShowObjectGeometry) == 0)) return;
if (mpParent->IsVisible() && ViewInfo.ViewFrustum.BoxInFrustum(AABox()))
if (mpParent->IsVisible() && rkViewInfo.ViewFrustum.BoxInFrustum(AABox()))
{
if (mpShieldModel->HasTransparency(0))
AddSurfacesToRenderer(pRenderer, mpShieldModel, 0, ViewInfo);
AddSurfacesToRenderer(pRenderer, mpShieldModel, 0, rkViewInfo);
else
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawMesh);
if (mpParent->IsSelected() && !ViewInfo.GameMode)
if (mpParent->IsSelected() && !rkViewInfo.GameMode)
pRenderer->AddOpaqueMesh(this, -1, AABox(), eDrawSelection);
}
}
void CDoorExtra::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo)
void CDoorExtra::Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo)
{
LoadModelMatrix();
mpParent->LoadLights(ViewInfo);
mpParent->LoadLights(rkViewInfo);
CGraphics::SetupAmbientColor();
CGraphics::UpdateVertexBlock();
CColor Tint = mpParent->TintColor(ViewInfo) * mShieldColor;
CColor Tint = mpParent->TintColor(rkViewInfo) * mShieldColor;
CGraphics::sPixelBlock.TintColor = Tint;
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
@@ -101,27 +101,27 @@ void CDoorExtra::DrawSelection()
mpShieldModel->DrawWireframe(eNoRenderOptions, mpParent->WireframeColor());
}
void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo)
void CDoorExtra::RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo)
{
if (!mpShieldModel) return;
if (ViewInfo.GameMode && !mpInstance->IsActive()) return;
if (rkViewInfo.GameMode && !mpInstance->IsActive()) return;
const CRay& Ray = Tester.Ray();
const CRay& Ray = rTester.Ray();
std::pair<bool,float> BoxResult = AABox().IntersectsRay(Ray);
if (BoxResult.first)
Tester.AddNodeModel(this, mpShieldModel);
rTester.AddNodeModel(this, mpShieldModel);
}
SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo)
SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo)
{
FRenderOptions Options = ViewInfo.pRenderer->RenderOptions();
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
SRayIntersection out;
out.pNode = mpParent;
out.ComponentIndex = AssetID;
CRay TransformedRay = Ray.Transformed(Transform().Inverse());
CRay TransformedRay = rkRay.Transformed(Transform().Inverse());
std::pair<bool,float> Result = mpShieldModel->GetSurface(AssetID)->IntersectsRay(TransformedRay, ((Options & eEnableBackfaceCull) == 0));
if (Result.first)
@@ -129,7 +129,7 @@ SRayIntersection CDoorExtra::RayNodeIntersectTest(const CRay &Ray, u32 AssetID,
out.Hit = true;
CVector3f HitPoint = TransformedRay.PointOnRay(Result.second);
CVector3f WorldHitPoint = Transform() * HitPoint;
out.Distance = Ray.Origin().Distance(WorldHitPoint);
out.Distance = rkRay.Origin().Distance(WorldHitPoint);
}
else out.Hit = false;

View File

@@ -15,11 +15,11 @@ class CDoorExtra : public CScriptExtra
public:
explicit CDoorExtra(CScriptObject *pInstance, CScene *pScene, CSceneNode *pParent = 0);
void PropertyModified(IProperty *pProperty);
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
void DrawSelection();
void RayAABoxIntersectTest(CRayCollisionTester& Tester, const SViewInfo& ViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay &Ray, u32 AssetID, const SViewInfo& ViewInfo);
void RayAABoxIntersectTest(CRayCollisionTester& rTester, const SViewInfo& rkViewInfo);
SRayIntersection RayNodeIntersectTest(const CRay& rkRay, u32 AssetID, const SViewInfo& rkViewInfo);
};
#endif // CDOOREXTRA_H

View File

@@ -11,7 +11,7 @@
CScriptExtra* CScriptExtra::CreateExtra(CScriptNode *pNode)
{
CScriptExtra *pExtra = nullptr;
CScriptObject *pObj = pNode->Object();
CScriptObject *pObj = pNode->Instance();
if (pObj)
{

View File

@@ -32,7 +32,7 @@ public:
// Default implementations for CSceneNode
virtual ENodeType NodeType() { return eScriptExtraNode; }
virtual SRayIntersection RayNodeIntersectTest(const CRay& /*Ray*/, u32 /*AssetID*/, const SViewInfo& /*ViewInfo*/)
virtual SRayIntersection RayNodeIntersectTest(const CRay& /*rkRay*/, u32 /*AssetID*/, const SViewInfo& /*rkViewInfo*/)
{
SRayIntersection out;
out.Hit = false;

View File

@@ -55,7 +55,7 @@ void CSplinePathExtra::AddWaypoints()
{
CScriptNode *pNode = mpScene->NodeForInstanceID(pLink->ReceiverID());
if (pNode && pNode->Object()->ObjectTypeID() == 0x57415950) // Waypoint
if (pNode && pNode->Instance()->ObjectTypeID() == 0x57415950) // Waypoint
{
CWaypointExtra *pWaypoint = static_cast<CWaypointExtra*>(pNode->Extra());
FindAttachedWaypoints(CheckedWaypoints, pWaypoint);

View File

@@ -46,7 +46,7 @@ void CWaypointExtra::CheckColor()
mColor = CColor::skCyan;
}
mColor.a = 0;
mColor.A = 0;
}
void CWaypointExtra::AddToSplinePath(CSplinePathExtra *pPath)
@@ -120,7 +120,7 @@ bool CWaypointExtra::IsPathLink(CLink *pLink)
CScriptNode *pNode = mpScene->NodeForInstanceID(pLink->ReceiverID());
if (pNode)
return pNode->Object()->ObjectTypeID() == mpInstance->ObjectTypeID();
return pNode->Instance()->ObjectTypeID() == mpInstance->ObjectTypeID();
}
return false;
@@ -154,25 +154,25 @@ void CWaypointExtra::LinksModified()
BuildLinks();
}
void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo)
void CWaypointExtra::AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo)
{
// This call is necessary because if we try to build links in the constructor, it
// won't work properly because we haven't finished loading the scene yet.
if (!mLinksBuilt) BuildLinks();
if (!ViewInfo.GameMode && (ViewInfo.ShowFlags & eShowObjectGeometry) && mpParent->IsVisible() && !mpParent->IsSelected())
if (!rkViewInfo.GameMode && (rkViewInfo.ShowFlags & eShowObjectGeometry) && mpParent->IsVisible() && !mpParent->IsSelected())
{
for (u32 iLink = 0; iLink < mLinks.size(); iLink++)
{
CScriptNode *pNode = mLinks[iLink].pWaypoint;
if (pNode->IsVisible() && !pNode->IsSelected() && ViewInfo.ViewFrustum.BoxInFrustum(mLinks[iLink].LineAABB))
if (pNode->IsVisible() && !pNode->IsSelected() && rkViewInfo.ViewFrustum.BoxInFrustum(mLinks[iLink].LineAABB))
pRenderer->AddOpaqueMesh(this, iLink, mLinks[iLink].LineAABB, eDrawMesh);
}
}
}
void CWaypointExtra::Draw(FRenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*ViewInfo*/)
void CWaypointExtra::Draw(FRenderOptions /*Options*/, int ComponentIndex, const SViewInfo& /*rkViewInfo*/)
{
glBlendFunc(GL_ONE, GL_ZERO);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

View File

@@ -31,8 +31,8 @@ public:
void OnTransformed();
void LinksModified();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& rkViewInfo);
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& rkViewInfo);
CColor TevColor();
};