From 555610f69f87796faaddae926925ef561bbc8c0d Mon Sep 17 00:00:00 2001 From: Azaezel Date: Wed, 29 Jul 2015 03:03:27 -0500 Subject: [PATCH 1/5] Addresses roughly half of the C4189 errors though the following methodologies: 1) truly unused vars removed 2) vars leading to remmed out code for debugging remmed in turn. left out: vars in macros. --- Engine/source/console/astNodes.cpp | 4 ---- Engine/source/console/compiledEval.cpp | 7 ++++--- Engine/source/gui/3d/guiTSControl.cpp | 2 -- Engine/source/math/mSphere.cpp | 3 +++ Engine/source/navigation/guiNavEditorCtrl.cpp | 1 - Engine/source/terrain/glsl/terrFeatureGLSL.cpp | 2 -- Engine/source/terrain/hlsl/terrFeatureHLSL.cpp | 1 - Engine/source/ts/tsMesh.cpp | 4 ++-- 8 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Engine/source/console/astNodes.cpp b/Engine/source/console/astNodes.cpp index ba47a804a..3fc8c04c9 100644 --- a/Engine/source/console/astNodes.cpp +++ b/Engine/source/console/astNodes.cpp @@ -258,7 +258,6 @@ void IfStmtNode::propagateSwitchExpr(ExprNode *left, bool string) U32 IfStmtNode::compileStmt(CodeStream &codeStream, U32 ip) { - U32 start = ip; U32 endifIp, elseIp; addBreakLine(codeStream); @@ -340,7 +339,6 @@ U32 LoopStmtNode::compileStmt(CodeStream &codeStream, U32 ip) addBreakLine(codeStream); codeStream.pushFixScope(true); - U32 start = ip; if(initExpr) ip = initExpr->compile(codeStream, ip, TypeReqNone); @@ -1565,8 +1563,6 @@ U32 FunctionDeclStmtNode::compileStmt(CodeStream &codeStream, U32 ip) CodeBlock::smInFunction = false; - - U32 start = ip; codeStream.emit(OP_FUNC_DECL); codeStream.emitSTE(fnName); codeStream.emitSTE(nameSpace); diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index 8d9f5dfcd..52dfff1e9 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -435,11 +435,12 @@ static void setFieldComponent( SimObject* object, StringTableEntry field, const ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, ConsoleValueRef *argv, bool noCalls, StringTableEntry packageName, S32 setFrame) { +/* #ifdef TORQUE_DEBUG U32 stackStart = STR.mStartStackSize; U32 consoleStackStart = CSTK.mStackPos; #endif - +*/ //Con::printf("CodeBlock::exec(%s,%u)", functionName ? functionName : "??", ip); static char traceBuffer[1024]; @@ -2244,12 +2245,12 @@ execFinished: } decRefCount(); - +/* #ifdef TORQUE_DEBUG //AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec"); //AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec"); #endif - +*/ return returnValue; } diff --git a/Engine/source/gui/3d/guiTSControl.cpp b/Engine/source/gui/3d/guiTSControl.cpp index 285be625f..63f4d236d 100644 --- a/Engine/source/gui/3d/guiTSControl.cpp +++ b/Engine/source/gui/3d/guiTSControl.cpp @@ -578,14 +578,12 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect) GFXTextureObject *texObject = mStereoGuiTarget->getTexture(0); const FovPort *currentFovPort = GFX->getStereoFovPort(); const MatrixF *eyeTransforms = GFX->getStereoEyeTransforms(); - const MatrixF *worldEyeTransforms = GFX->getInverseStereoEyeTransforms(); const Point3F *eyeOffset = GFX->getStereoEyeOffsets(); for (U32 i=0; i<2; i++) { GFX->activateStereoTarget(i); Frustum gfxFrustum = originalFrustum; - const F32 frustumDepth = gfxFrustum.getNearDist(); MathUtils::makeFovPortFrustum(&gfxFrustum, true, gfxFrustum.getNearDist(), gfxFrustum.getFarDist(), currentFovPort[i], eyeTransforms[i]); GFX->setFrustum(gfxFrustum); diff --git a/Engine/source/math/mSphere.cpp b/Engine/source/math/mSphere.cpp index c1edbd91d..971127fb5 100644 --- a/Engine/source/math/mSphere.cpp +++ b/Engine/source/math/mSphere.cpp @@ -77,8 +77,11 @@ bool SphereF::intersectsRay( const Point3F &start, const Point3F &end ) const // value for getting the exact // intersection point, by interpolating // start to end by t. + + /* F32 t = 0; TORQUE_UNUSED(t); + */ // if t1 is less than zero, the object is in the ray's negative direction // and consequently the ray misses the sphere diff --git a/Engine/source/navigation/guiNavEditorCtrl.cpp b/Engine/source/navigation/guiNavEditorCtrl.cpp index 872afdb45..82981cf0d 100644 --- a/Engine/source/navigation/guiNavEditorCtrl.cpp +++ b/Engine/source/navigation/guiNavEditorCtrl.cpp @@ -308,7 +308,6 @@ void GuiNavEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) U8 keys = Input::getModifierKeys(); bool shift = keys & SI_LSHIFT; bool ctrl = keys & SI_LCTRL; - bool alt = keys & SI_LALT; if(mMode == mLinkMode && !mMesh.isNull()) { diff --git a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp index eba99371a..64a8e7469 100644 --- a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp +++ b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp @@ -812,12 +812,10 @@ void TerrainMacroMapFeatGLSL::processPix( Vector &componentL meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n", detailColor, detailInfo, inDet ) ); - Var *baseColor = (Var*)LangElement::find( "baseColor" ); Var *outColor = (Var*)LangElement::find( "col" ); meta->addStatement( new GenOp( " @ = lerp( @, @ + @, @ );\r\n", outColor, outColor, outColor, detailColor, detailBlend ) ); - //outColor, outColor, baseColor, detailColor, detailBlend ) ); meta->addStatement( new GenOp( " }\r\n" ) ); diff --git a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp index 6292bd32a..0f2e03ebe 100644 --- a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp +++ b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp @@ -542,7 +542,6 @@ void TerrainDetailMapFeatHLSL::processPix( Vector &component meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n", detailColor, detailInfo, inDet ) ); - Var *baseColor = (Var*)LangElement::find( "baseColor" ); Var *outColor = (Var*)LangElement::find( "col" ); meta->addStatement( new GenOp( " @ += @ * @;\r\n", diff --git a/Engine/source/ts/tsMesh.cpp b/Engine/source/ts/tsMesh.cpp index 02eb6e4c7..fa449079a 100644 --- a/Engine/source/ts/tsMesh.cpp +++ b/Engine/source/ts/tsMesh.cpp @@ -223,7 +223,7 @@ void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata, // We need to have a material. if ( draw.matIndex & TSDrawPrimitive::NoMaterial ) continue; - +/* #ifdef TORQUE_DEBUG // for inspection if you happen to be running in a debugger and can't do bit // operations in your head. @@ -238,7 +238,7 @@ void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata, TORQUE_UNUSED(indexed); TORQUE_UNUSED(type); #endif - +*/ const U32 matIndex = draw.matIndex & TSDrawPrimitive::MaterialMask; BaseMatInstance *matInst = materials->getMaterialInst( matIndex ); From 3c1c88d96b0396531cc69aa822db2e5f9f30993f Mon Sep 17 00:00:00 2001 From: Azaezel Date: Wed, 29 Jul 2015 04:46:36 -0500 Subject: [PATCH 2/5] TORQUE_VALIDATE_STACK define for console stack debugging --- Engine/source/console/compiledEval.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Engine/source/console/compiledEval.cpp b/Engine/source/console/compiledEval.cpp index 52dfff1e9..2eddf0873 100644 --- a/Engine/source/console/compiledEval.cpp +++ b/Engine/source/console/compiledEval.cpp @@ -435,12 +435,12 @@ static void setFieldComponent( SimObject* object, StringTableEntry field, const ConsoleValueRef CodeBlock::exec(U32 ip, const char *functionName, Namespace *thisNamespace, U32 argc, ConsoleValueRef *argv, bool noCalls, StringTableEntry packageName, S32 setFrame) { -/* -#ifdef TORQUE_DEBUG + +#ifdef TORQUE_VALIDATE_STACK U32 stackStart = STR.mStartStackSize; U32 consoleStackStart = CSTK.mStackPos; #endif -*/ + //Con::printf("CodeBlock::exec(%s,%u)", functionName ? functionName : "??", ip); static char traceBuffer[1024]; @@ -2245,12 +2245,12 @@ execFinished: } decRefCount(); -/* -#ifdef TORQUE_DEBUG - //AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec"); - //AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec"); + +#ifdef TORQUE_VALIDATE_STACK + AssertFatal(!(STR.mStartStackSize > stackStart), "String stack not popped enough in script exec"); + AssertFatal(!(STR.mStartStackSize < stackStart), "String stack popped too much in script exec"); #endif -*/ + return returnValue; } From 5615b642df2713e75cc3efcd5655e602fb53fcff Mon Sep 17 00:00:00 2001 From: Azaezel Date: Wed, 29 Jul 2015 08:41:36 -0500 Subject: [PATCH 3/5] suggested revision --- Engine/source/ts/tsMesh.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Engine/source/ts/tsMesh.cpp b/Engine/source/ts/tsMesh.cpp index fa449079a..72ee74461 100644 --- a/Engine/source/ts/tsMesh.cpp +++ b/Engine/source/ts/tsMesh.cpp @@ -223,8 +223,8 @@ void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata, // We need to have a material. if ( draw.matIndex & TSDrawPrimitive::NoMaterial ) continue; -/* -#ifdef TORQUE_DEBUG + +#ifdef TORQUE_DEBUG_BREAK_INSPECT // for inspection if you happen to be running in a debugger and can't do bit // operations in your head. S32 triangles = draw.matIndex & TSDrawPrimitive::Triangles; @@ -237,8 +237,9 @@ void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata, TORQUE_UNUSED(fan); TORQUE_UNUSED(indexed); TORQUE_UNUSED(type); + //define TORQUE_DEBUG_BREAK_INSPECT, and insert debug break here to inspect the above elements at runtime #endif -*/ + const U32 matIndex = draw.matIndex & TSDrawPrimitive::MaterialMask; BaseMatInstance *matInst = materials->getMaterialInst( matIndex ); From 240219c42318126613076de28b8aade24b0c7754 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 21 Aug 2015 03:06:47 -0500 Subject: [PATCH 4/5] clarify var-usage via naming --- Engine/source/gui/3d/guiTSControl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Engine/source/gui/3d/guiTSControl.cpp b/Engine/source/gui/3d/guiTSControl.cpp index 63f4d236d..efe553d73 100644 --- a/Engine/source/gui/3d/guiTSControl.cpp +++ b/Engine/source/gui/3d/guiTSControl.cpp @@ -616,11 +616,11 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect) F32 screenBottom = rectHeight * 0.5; const F32 fillConv = 0.0f; - const F32 frustumDepth = gfxFrustum.getNearDist() + 0.012; - verts[0].point.set( screenLeft - fillConv, frustumDepth, screenTop - fillConv ); - verts[1].point.set( screenRight - fillConv, frustumDepth, screenTop - fillConv ); - verts[2].point.set( screenLeft - fillConv, frustumDepth, screenBottom - fillConv ); - verts[3].point.set( screenRight - fillConv, frustumDepth, screenBottom - fillConv ); + const F32 frustumDepthAdjusted = gfxFrustum.getNearDist() + 0.012; + verts[0].point.set( screenLeft - fillConv, frustumDepthAdjusted, screenTop - fillConv ); + verts[1].point.set( screenRight - fillConv, frustumDepthAdjusted, screenTop - fillConv ); + verts[2].point.set( screenLeft - fillConv, frustumDepthAdjusted, screenBottom - fillConv ); + verts[3].point.set( screenRight - fillConv, frustumDepthAdjusted, screenBottom - fillConv ); verts[0].color = verts[1].color = verts[2].color = verts[3].color = ColorI(255,255,255,255); From 8f8c17e997431009600054a8b2b5c8920e88a537 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Fri, 21 Aug 2015 03:07:41 -0500 Subject: [PATCH 5/5] optimization --- Engine/source/gui/3d/guiTSControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/gui/3d/guiTSControl.cpp b/Engine/source/gui/3d/guiTSControl.cpp index efe553d73..cbb520433 100644 --- a/Engine/source/gui/3d/guiTSControl.cpp +++ b/Engine/source/gui/3d/guiTSControl.cpp @@ -579,11 +579,11 @@ void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect) const FovPort *currentFovPort = GFX->getStereoFovPort(); const MatrixF *eyeTransforms = GFX->getStereoEyeTransforms(); const Point3F *eyeOffset = GFX->getStereoEyeOffsets(); + Frustum gfxFrustum = originalFrustum; for (U32 i=0; i<2; i++) { GFX->activateStereoTarget(i); - Frustum gfxFrustum = originalFrustum; MathUtils::makeFovPortFrustum(&gfxFrustum, true, gfxFrustum.getNearDist(), gfxFrustum.getFarDist(), currentFovPort[i], eyeTransforms[i]); GFX->setFrustum(gfxFrustum);