From c7b041f54500a5c579935a032d26ea4b27e65264 Mon Sep 17 00:00:00 2001 From: Areloch Date: Mon, 16 Jan 2017 22:11:32 -0600 Subject: [PATCH] Fixes the debug netevent packing error by keeping the mStart value as it's proper 0-1 range until it gets to the client, using a temporary world-space var for finding strike target objects in the radius. Also add a checker for if there is a texture or not set for the lighting bolt. If it use, set the stateblock description to support it and set the texture, if not, only utilize the color blend. --- Engine/source/T3D/fx/lightning.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index 125c5891d..c7981df47 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -478,11 +478,15 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base desc.setBlend( true, GFXBlendSrcAlpha, GFXBlendOne); desc.setCullMode(GFXCullNone); desc.zWriteEnable = false; - desc.samplersDefined = true; - desc.samplers[0].magFilter = GFXTextureFilterLinear; - desc.samplers[0].minFilter = GFXTextureFilterLinear; - desc.samplers[0].addressModeU = GFXAddressWrap; - desc.samplers[0].addressModeV = GFXAddressWrap; + + if (mDataBlock->strikeTextures[0].isValid()) + { + desc.samplersDefined = true; + desc.samplers[0].magFilter = GFXTextureFilterLinear; + desc.samplers[0].minFilter = GFXTextureFilterLinear; + desc.samplers[0].addressModeU = GFXAddressWrap; + desc.samplers[0].addressModeV = GFXAddressWrap; + } mLightningSB = GFX->createStateBlock(desc); @@ -494,7 +498,8 @@ void Lightning::renderObject(ObjectRenderInst *ri, SceneRenderState *state, Base Strike* walk = mStrikeListHead; while (walk != NULL) { - GFX->setTexture(0, mDataBlock->strikeTextures[0]); + if (mDataBlock->strikeTextures[0].isValid()) + GFX->setTexture(0, mDataBlock->strikeTextures[0]); for( U32 i=0; i<3; i++ ) { @@ -731,18 +736,19 @@ void Lightning::strikeRandomPoint() Point3F strikePoint( gRandGen.randF( 0.0f, 1.0f ), gRandGen.randF( 0.0f, 1.0f ), 0.0f ); // check if an object is within target range + Point3F worldPosStrikePoint = strikePoint; - strikePoint *= mObjScale; - strikePoint += getPosition(); - strikePoint += Point3F( -mObjScale.x * 0.5f, -mObjScale.y * 0.5f, 0.0f ); + worldPosStrikePoint *= mObjScale; + worldPosStrikePoint += getPosition(); + worldPosStrikePoint += Point3F( -mObjScale.x * 0.5f, -mObjScale.y * 0.5f, 0.0f ); Box3F queryBox; F32 boxWidth = strikeRadius * 2.0f; queryBox.minExtents.set( -boxWidth * 0.5f, -boxWidth * 0.5f, -mObjScale.z * 0.5f ); queryBox.maxExtents.set( boxWidth * 0.5f, boxWidth * 0.5f, mObjScale.z * 0.5f ); - queryBox.minExtents += strikePoint; - queryBox.maxExtents += strikePoint; + queryBox.minExtents += worldPosStrikePoint; + queryBox.maxExtents += worldPosStrikePoint; SimpleQueryList sql; getContainer()->findObjects(queryBox, DAMAGEABLE_TYPEMASK,