Преглед на файлове

Merge pull request #315 from Areloch/MemleakAndFriends

Various misc. tweaks and fixes targeting memleaks and crashes
Brian Roberts преди 5 години
родител
ревизия
d6ec72de6e
променени са 44 файла, в които са добавени 123 реда и са изтрити 255 реда
  1. 2 1
      Engine/source/T3D/Scene.cpp
  2. 2 0
      Engine/source/T3D/aiPlayer.cpp
  3. 1 1
      Engine/source/T3D/assets/GameObjectAsset.cpp
  4. 1 1
      Engine/source/T3D/assets/MaterialAsset.cpp
  5. 1 1
      Engine/source/T3D/decal/decalManager.cpp
  6. 27 13
      Engine/source/T3D/lighting/reflectionProbe.cpp
  7. 1 0
      Engine/source/T3D/player.cpp
  8. 1 2
      Engine/source/T3D/sfx/sfxEmitter.cpp
  9. 26 24
      Engine/source/T3D/shapeBase.cpp
  10. 6 1
      Engine/source/T3D/vehicles/wheeledVehicle.cpp
  11. 4 4
      Engine/source/app/net/serverQuery.cpp
  12. 1 1
      Engine/source/collision/collision.h
  13. 3 0
      Engine/source/console/console.cpp
  14. 3 1
      Engine/source/console/fieldBrushObject.cpp
  15. 2 2
      Engine/source/environment/VolumetricFog.cpp
  16. 2 0
      Engine/source/gfx/gfxTextureManager.cpp
  17. 2 2
      Engine/source/gfx/sim/cubemapData.cpp
  18. 1 1
      Engine/source/gui/controls/guiMLTextCtrl.h
  19. 2 2
      Engine/source/gui/editor/inspector/variableInspector.cpp
  20. 0 17
      Engine/source/gui/worldEditor/worldEditor.cpp
  21. 0 4
      Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp
  22. 0 4
      Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp
  23. 3 2
      Engine/source/materials/customMaterialDefinition.cpp
  24. 0 35
      Engine/source/materials/materialDefinition.cpp
  25. 0 10
      Engine/source/materials/materialDefinition.h
  26. 1 1
      Engine/source/materials/processedCustomMaterial.cpp
  27. 0 2
      Engine/source/materials/processedMaterial.h
  28. 3 16
      Engine/source/materials/processedShaderMaterial.cpp
  29. 1 1
      Engine/source/materials/processedShaderMaterial.h
  30. 1 1
      Engine/source/math/mPolyhedron.h
  31. 1 1
      Engine/source/module/moduleManager.cpp
  32. 3 1
      Engine/source/renderInstance/renderProbeMgr.cpp
  33. 1 1
      Engine/source/renderInstance/renderTranslucentMgr.cpp
  34. 2 2
      Engine/source/scene/fogStructs.h
  35. 1 1
      Engine/source/scene/sceneObject.cpp
  36. 1 1
      Engine/source/sfx/sfxSound.cpp
  37. 2 0
      Engine/source/shaderGen/customShaderFeature.cpp
  38. 3 82
      Engine/source/shaderGen/shaderGen.cpp
  39. 2 9
      Engine/source/shaderGen/shaderGen.h
  40. 1 1
      Engine/source/sim/netConnection.h
  41. 1 3
      Engine/source/terrain/terrCellMaterial.cpp
  42. 4 2
      Engine/source/ts/collada/colladaUtils.cpp
  43. 2 1
      Engine/source/ts/tsDump.cpp
  44. 2 0
      Engine/source/ts/tsShapeConstruct.cpp

+ 2 - 1
Engine/source/T3D/Scene.cpp

@@ -11,7 +11,8 @@ Scene::Scene() :
    mParentScene(nullptr),
    mSceneId(-1),
    mIsEditing(false),
-   mIsDirty(false)
+   mIsDirty(false),
+   mEditPostFX(0)
 {
    mGameModeName = StringTable->EmptyString();
 }

+ 2 - 0
Engine/source/T3D/aiPlayer.cpp

@@ -120,6 +120,8 @@ AIPlayer::AIPlayer()
 
    for( S32 i = 0; i < MaxTriggerKeys; i ++ )
       mMoveTriggers[ i ] = false;
+
+   mAttackRadius = 1;
 }
 
 /**

+ 1 - 1
Engine/source/T3D/assets/GameObjectAsset.cpp

@@ -266,7 +266,7 @@ GuiControl* GuiInspectorTypeGameObjectAssetPtr::constructEditControl()
 
    const char* assetId = getData();
 
-   if (assetId == "")
+   if (dStrEqual(assetId, ""))
    {
       mGameObjectEditButton->setText("Create Game Object");
 

+ 1 - 1
Engine/source/T3D/assets/MaterialAsset.cpp

@@ -280,7 +280,7 @@ bool GuiInspectorTypeMaterialAssetPtr::updateRects()
 
    bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
 
-   if (mMatEdContainer != nullptr)
+   if (mMatEdContainer != nullptr && mMatPreviewButton != nullptr)
    {
       mMatPreviewButton->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
    }

+ 1 - 1
Engine/source/T3D/decal/decalManager.cpp

@@ -783,7 +783,7 @@ U32 DecalManager::_generateConvexHull( const Vector<Point3F> &points, Vector<Poi
    while ( ++i <= maxmin )
    {
       // the lower line joins P[minmin] with P[maxmin]
-      if ( isLeft( points[minmin], points[maxmin], points[i]) >= 0 && i < maxmin )
+      if (i < maxmin && isLeft(points[minmin], points[maxmin], points[i]) >= 0)
          continue;          // ignore P[i] above or on the lower line
 
       while (top > 0)        // there are at least 2 points on the stack

+ 27 - 13
Engine/source/T3D/lighting/reflectionProbe.cpp

@@ -747,14 +747,21 @@ void ReflectionProbe::processStaticCubemap()
 
    if (Platform::isFile(irradFileName))
    {
+      if (mIrridianceMap == nullptr)
+      {
+         Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked irradiance map at %s", irradFileName);
+         return;
+      }
+
       mIrridianceMap->setCubemapFile(FileName(irradFileName));
-      mIrridianceMap->updateFaces();
-   }
 
-   if (mIrridianceMap == nullptr || mIrridianceMap->mCubemap.isNull())
-   {
-      Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked irradiance map at %s", irradFileName);
-      return;
+      if (mIrridianceMap->mCubemap.isNull())
+      {
+         Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked irradiance map at %s", irradFileName);
+         return;
+      }
+
+      mIrridianceMap->updateFaces();
    }
 
    char prefilterFileName[256];
@@ -762,14 +769,21 @@ void ReflectionProbe::processStaticCubemap()
 
    if (Platform::isFile(prefilterFileName))
    {
+      if (mPrefilterMap == nullptr)
+      {
+         Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked prefilter map at %s", prefilterFileName);
+         return;
+      }
+
       mPrefilterMap->setCubemapFile(FileName(prefilterFileName));
-      mPrefilterMap->updateFaces();
-   }
 
-   if (mPrefilterMap == nullptr || mPrefilterMap->mCubemap.isNull())
-   {
-      Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked prefilter map at %s", prefilterFileName);
-      return;
+      if (mPrefilterMap->mCubemap.isNull())
+      {
+         Con::errorf("ReflectionProbe::processStaticCubemap() - Unable to load baked prefilter map at %s", prefilterFileName);
+         return;
+      }
+
+      mPrefilterMap->updateFaces();
    }
 
    if (!Platform::isFile(prefilterFileName) || !Platform::isFile(irradFileName))
@@ -809,7 +823,7 @@ void ReflectionProbe::processStaticCubemap()
       IBLUtilities::SaveCubeMap(prefilterFileName, mPrefilterMap->mCubemap);
    }
 
-   if ((mIrridianceMap != nullptr || !mIrridianceMap->mCubemap.isNull()) && (mPrefilterMap != nullptr || !mPrefilterMap->mCubemap.isNull()))
+   if ((mIrridianceMap != nullptr && !mIrridianceMap->mCubemap.isNull()) && (mPrefilterMap != nullptr && !mPrefilterMap->mCubemap.isNull()))
    {
       mProbeInfo->mPrefilterCubemap = mPrefilterMap->mCubemap;
       mProbeInfo->mIrradianceCubemap = mIrridianceMap->mCubemap;

+ 1 - 0
Engine/source/T3D/player.cpp

@@ -290,6 +290,7 @@ PlayerData::PlayerData()
 
    maxStepHeight = 1.0f;
    runSurfaceAngle = 80.0f;
+   runSurfaceCos = mCos(mDegToRad(runSurfaceAngle));
 
    fallingSpeedThreshold = -10.0f;
 

+ 1 - 2
Engine/source/T3D/sfx/sfxEmitter.cpp

@@ -120,8 +120,7 @@ SFXEmitter::~SFXEmitter()
 {
    mLocalProfile._unregisterSignals();
    
-   if( mSource )
-      SFX_DELETE( mSource );
+   SFX_DELETE( mSource );
 }
 
 //-----------------------------------------------------------------------------

+ 26 - 24
Engine/source/T3D/shapeBase.cpp

@@ -1210,7 +1210,7 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
    }
    ShapeBaseData *prevDB = dynamic_cast<ShapeBaseData*>( mDataBlock );
 
-   bool isInitialDataBlock = ( mDataBlock == 0 );
+   bool isInitialDataBlock = (prevDB == 0);
 
    if ( Parent::onNewDataBlock( dptr, reload ) == false )
       return false;
@@ -1236,13 +1236,14 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
             for (S32 i = 0; i < mDataBlock->txr_tag_remappings.size(); i++)
             {
                ShapeBaseData::TextureTagRemapping* remap = &mDataBlock->txr_tag_remappings[i];
-               Vector<String> & mat_names = (Vector<String>&) mat_list->getMaterialNameList();
-               for (S32 j = 0; j < mat_names.size(); j++) 
+               Vector<String>& mat_names = (Vector<String>&) mat_list->getMaterialNameList();
+               S32 old_tagLen = dStrlen(remap->old_tag);
+               for (S32 j = 0; j < mat_names.size(); j++)
                {
-                  if (mat_names[j].compare(remap->old_tag, dStrlen(remap->old_tag), String::NoCase) == 0)
+                  if (mat_names[j].compare(remap->old_tag, old_tagLen, String::NoCase) == 0)
                   {
                      mat_names[j] = String(remap->new_tag);
-                     mat_names[j].insert(0,'#');
+                     mat_names[j].insert(0, '#');
                      break;
                   }
                }
@@ -1263,14 +1264,15 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
                for (S32 i = 0; i < mDataBlock->txr_tag_remappings.size(); i++)
                {
                   ShapeBaseData::TextureTagRemapping* remap = &mDataBlock->txr_tag_remappings[i];
-                  Vector<String> & mat_names = (Vector<String>&) mat_list->getMaterialNameList();
-                  for (S32 j = 0; j < mat_names.size(); j++) 
+                  Vector<String>& mat_names = (Vector<String>&) mat_list->getMaterialNameList();
+                  S32 new_tagLen = dStrlen(remap->new_tag);
+                  for (S32 j = 0; j < mat_names.size(); j++)
                   {
                      String::SizeType len = mat_names[j].length();
                      if (len > 1)
                      {
-                        String temp_name = mat_names[j].substr(1,len-1);
-                        if (temp_name.compare(remap->new_tag, dStrlen(remap->new_tag)) == 0)
+                        String temp_name = mat_names[j].substr(1, len - 1);
+                        if (temp_name.compare(remap->new_tag, new_tagLen) == 0)
                         {
                            mat_names[j] = String(remap->old_tag);
                            break;
@@ -1286,7 +1288,7 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
       resetWorldBox();
 
       // Set the initial mesh hidden state.
-      mMeshHidden.setSize( mDataBlock->mShape->objects.size() );
+      mMeshHidden.setSize(mDataBlock->mShape->objects.size());
       mMeshHidden.clear();
 
       // Initialize the threads
@@ -1304,37 +1306,37 @@ bool ShapeBase::onNewDataBlock( GameBaseData *dptr, bool reload )
             // initialized either by the constructor or from the server.
             bool reset = st.thread != 0;
             st.thread = 0;
-            
+
             // New datablock/shape may not actually HAVE this sequence.
             // In that case stop playing it.
-            
-            AssertFatal( prevDB != NULL, "ShapeBase::onNewDataBlock - how did you have a sequence playing without a prior datablock?" );
-   
-            const TSShape *prevShape = prevDB->mShape;
-            const TSShape::Sequence &prevSeq = prevShape->sequences[st.sequence];
-            const String &prevSeqName = prevShape->names[prevSeq.nameIndex];
 
-            st.sequence = mDataBlock->mShape->findSequence( prevSeqName );
+            AssertFatal(prevDB != NULL, "ShapeBase::onNewDataBlock - how did you have a sequence playing without a prior datablock?");
 
-            if ( st.sequence != -1 )
+            const TSShape* prevShape = prevDB->mShape;
+            const TSShape::Sequence& prevSeq = prevShape->sequences[st.sequence];
+            const String& prevSeqName = prevShape->names[prevSeq.nameIndex];
+
+            st.sequence = mDataBlock->mShape->findSequence(prevSeqName);
+
+            if (st.sequence != -1)
             {
-               setThreadSequence( i, st.sequence, reset );                              
-            }            
+               setThreadSequence(i, st.sequence, reset);
+            }
          }
       }
 
       if (mDataBlock->damageSequence != -1) {
          mDamageThread = mShapeInstance->addThread();
          mShapeInstance->setSequence(mDamageThread,
-                                     mDataBlock->damageSequence,0);
+            mDataBlock->damageSequence, 0);
       }
       if (mDataBlock->hulkSequence != -1) {
          mHulkThread = mShapeInstance->addThread();
          mShapeInstance->setSequence(mHulkThread,
-                                     mDataBlock->hulkSequence,0);
+            mDataBlock->hulkSequence, 0);
       }
 
-      if( isGhost() )
+      if (isGhost())
       {
          // Reapply the current skin
          mAppliedSkinName = "";

+ 6 - 1
Engine/source/T3D/vehicles/wheeledVehicle.cpp

@@ -339,8 +339,13 @@ bool WheeledVehicleData::preload(bool server, String &errorStr)
    // Resolve objects transmitted from server
    if (!server) {
       for (S32 i = 0; i < MaxSounds; i++)
-         if( !sfxResolve( &sound[ i ], errorStr ) )
+      {
+         if (!sfxResolve(&sound[i], errorStr))
+         {
+            delete si;
             return false;
+         }
+      }
 
       if (tireEmitter)
          Sim::findObject(SimObjectId((uintptr_t)tireEmitter),tireEmitter);

+ 4 - 4
Engine/source/app/net/serverQuery.cpp

@@ -1584,8 +1584,8 @@ static void handleMasterServerListResponse( BitStream* stream, U32 key, U8 /*fla
       {
          if ( i != packetIndex )
          {
-            PacketStatus* p = new PacketStatus( i, gMasterServerPing.key, currentTime );
-            gPacketStatusList.push_back( *p );
+            PacketStatus p = PacketStatus( i, gMasterServerPing.key, currentTime );
+            gPacketStatusList.push_back( p );
          }
       }
 
@@ -1674,8 +1674,8 @@ static void handleExtendedMasterServerListResponse(BitStream* stream, U32 key, U
       {
          if (i != packetIndex)
          {
-            PacketStatus* p = new PacketStatus(i, gMasterServerPing.key, currentTime);
-            gPacketStatusList.push_back(*p);
+            PacketStatus p = PacketStatus(i, gMasterServerPing.key, currentTime);
+            gPacketStatusList.push_back(p);
          }
       }
 

+ 1 - 1
Engine/source/collision/collision.h

@@ -160,7 +160,7 @@ typedef Chunker<BSPNode> BSPTree;
 /// @see Collision
 struct RayInfo : public Collision 
 {
-   RayInfo() : userData( NULL ) {}
+   RayInfo() : t(0), userData( NULL ) {}
 
    // The collision struct has object, point, normal & material.
 

+ 3 - 0
Engine/source/console/console.cpp

@@ -1579,6 +1579,9 @@ ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef ar
    }
    bool result;
    const char* methodRes = CInterface::CallMethod(object, argv[0], argv_str, argc - 2, &result);
+
+   free(argv_str);
+
    if (result)
    {
       return ConsoleValueRef::fromValue(CSTK.pushString(methodRes));

+ 3 - 1
Engine/source/console/fieldBrushObject.cpp

@@ -542,6 +542,8 @@ void FieldBrushObject::pasteFields( SimObject* pSimObject )
     // Force modification of static-fields on target object!
     pSimObject->setModStaticFields( true );
 
+    S32 prefixLength = dStrlen(INTERNAL_FIELD_PREFIX);
+
     // Iterate fields.
     for ( SimFieldDictionaryIterator itr(pFieldDictionary); *itr; ++itr )
     {
@@ -553,7 +555,7 @@ void FieldBrushObject::pasteFields( SimObject* pSimObject )
         if ( pInternalField == fieldEntry->slotName )
         {
             // Yes, so skip the prefix.
-            pInternalField += dStrlen(INTERNAL_FIELD_PREFIX);
+           pInternalField += prefixLength;
 
             // Is this a static-field on the target object?
             // NOTE:-   We're doing this so we don't end-up creating a dynamic-field if it isn't present.

+ 2 - 2
Engine/source/environment/VolumetricFog.cpp

@@ -606,7 +606,7 @@ U32 VolumetricFog::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
 
       if (mShapeAssetId != StringTable->EmptyString())
       {
-         mShape = mShape = mShapeAsset->getShapeResource();
+         mShape = mShapeAsset->getShapeResource();
       }
       else if (mShapeName && mShapeName[0] != '\0')
       {
@@ -1048,7 +1048,7 @@ void VolumetricFog::prepRenderImage(SceneRenderState *state)
       return;
    if (mNumDetailLevels > 1)
    {
-      if ((det_size[mCurDetailLevel].det_size > mPixelSize) && (mCurDetailLevel < mNumDetailLevels - 1))
+      if ((mCurDetailLevel < mNumDetailLevels - 1) && (det_size[mCurDetailLevel].det_size > mPixelSize))
          UpdateBuffers(mCurDetailLevel + 1);
       else if (mCurDetailLevel > 0)
       {

+ 2 - 0
Engine/source/gfx/gfxTextureManager.cpp

@@ -375,6 +375,8 @@ GFXTextureObject *GFXTextureManager::_createTexture(  GBitmap *bmp,
 
    if(!ret)
    {
+      SAFE_DELETE(realBmp);
+
       Con::errorf("GFXTextureManager - failed to create texture (1) for '%s'", (resourceName.isNotEmpty() ? resourceName.c_str() : "unknown"));
       return NULL;
    }

+ 2 - 2
Engine/source/gfx/sim/cubemapData.cpp

@@ -202,7 +202,7 @@ DefineEngineMethod(CubemapData, save, void, (const char* filename, const GFXForm
 	"Returns the script filename of where the CubemapData object was "
 	"defined.  This is used by the material editor.")
 {
-	if (filename == "")
+   if (dStrEqual(filename, ""))
       filename = object->getName();
 
    //add dds extension if needed
@@ -211,4 +211,4 @@ DefineEngineMethod(CubemapData, save, void, (const char* filename, const GFXForm
       finalName += String(".dds");
 
    CubemapSaver::save(object->mCubemap, finalName, format);
-}
+}

+ 1 - 1
Engine/source/gui/controls/guiMLTextCtrl.h

@@ -253,7 +253,7 @@ class GuiMLTextCtrl : public GuiControl
    Resource<GFont> mFont;
 
    // Console settable parameters
-   U32 mLineSpacingPixels;
+   S32 mLineSpacingPixels;
    bool mAllowColorChars;
    bool mUseURLMouseCursor;
 

+ 2 - 2
Engine/source/gui/editor/inspector/variableInspector.cpp

@@ -268,7 +268,7 @@ DefineEngineMethod(GuiVariableInspector, addField, void, (const char* name, cons
    const char* description, const char* defaultValue, const char* dataValues, SimObject* ownerObj),
    ("","","","","", "", nullAsType<SimObject*>()), "addField( fieldName/varName, fieldLabel, fieldTypeName, description, defaultValue, defaultValues, ownerObject )")
 {
-   if (name == "" || typeName == "")
+   if (dStrEqual(name, "") || dStrEqual(typeName, ""))
       return;
 
    object->addField(name, label, typeName, description, defaultValue, dataValues, "", ownerObj);
@@ -278,7 +278,7 @@ DefineEngineMethod(GuiVariableInspector, addCallbackField, void, (const char* na
    const char* description, const char* defaultValue, const char* dataValues, const char* callbackName, SimObject* ownerObj),
    ("", "", "", "", "", "", nullAsType<SimObject*>()), "addField( fieldName/varName, fieldLabel, fieldTypeName, description, defaultValue, defaultValues, callbackName, ownerObject )")
 {
-   if (name == "" || typeName == "")
+   if (dStrEqual(name, "") || dStrEqual(typeName, ""))
       return;
 
    object->addCallbackField(name, label, typeName, description, defaultValue, dataValues, callbackName, ownerObj);

+ 0 - 17
Engine/source/gui/worldEditor/worldEditor.cpp

@@ -4042,23 +4042,6 @@ bool WorldEditor::makeSelectionAMesh(const char *filename)
       return true;
    else
       return false;
-
-   // Allocate TSStatic object and add to level.
-   TSStatic *ts = new TSStatic();
-   ts->setShapeFileName(StringTable->insert(filename));
-   fabMat.inverse();
-   ts->setTransform(fabMat);
-   ts->registerObject();
-   scene->addObject(ts);
-
-   // Select it, mark level as dirty.
-   clearSelection();
-   selectObject(ts);
-   setDirty();
-
-   // Delete original objects and temporary SimGroup.
-   for (S32 i = 0; i < objectList.size(); i++)
-      objectList[i]->deleteObject();
 }
 
 DefineEngineMethod( WorldEditor, makeSelectionPrefab, void, ( const char* filename, bool dontDeleteOriginals ), (false),

+ 0 - 4
Engine/source/lighting/advanced/glsl/advancedLightingFeaturesGLSL.cpp

@@ -114,10 +114,6 @@ void DeferredRTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &component
    meta->addStatement( new GenOp( "   @.y = 1.0 - @.y;\r\n", uvScene, uvScene ) ); // flip the y axis 
    meta->addStatement( new GenOp( "   @ = ( @ * @.zw ) + @.xy;\r\n", uvScene, uvScene, rtParams, rtParams) ); // scale it down and offset it to the rt size
 
-   Var *lightInfoSamp = new Var;
-   lightInfoSamp->setType( "vec4" );
-   lightInfoSamp->setName( "lightInfoSample" );
-
    // create texture var
    Var *lightInfoBuffer = new Var;
    lightInfoBuffer->setType( "sampler2D" );

+ 0 - 4
Engine/source/lighting/advanced/hlsl/advancedLightingFeaturesHLSL.cpp

@@ -115,10 +115,6 @@ void DeferredRTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &component
    meta->addStatement( new GenOp( "   @.y = 1.0 - @.y;\r\n", uvScene, uvScene ) ); // flip the y axis 
    meta->addStatement( new GenOp( "   @ = ( @ * @.zw ) + @.xy;\r\n", uvScene, uvScene, rtParams, rtParams) ); // scale it down and offset it to the rt size
 
-   Var *lightInfoSamp = new Var;
-   lightInfoSamp->setType( "float4" );
-   lightInfoSamp->setName( "lightInfoSample" );
-
    // create texture var
    Var *lightInfoBuffer = new Var;
    lightInfoBuffer->setType( "SamplerState" );

+ 3 - 2
Engine/source/materials/customMaterialDefinition.cpp

@@ -120,6 +120,7 @@ bool CustomMaterial::onAdd()
    }
    
    const char* samplerDecl = "sampler";
+   S32 samplerDeclLen = dStrlen(samplerDecl);
    S32 i = 0;
    for (SimFieldDictionaryIterator itr(getFieldDictionary()); *itr; ++itr)
    {
@@ -132,7 +133,7 @@ bool CustomMaterial::onAdd()
             return false;
          }
          
-         if (dStrlen(entry->slotName) == dStrlen(samplerDecl))
+         if (dStrlen(entry->slotName) == samplerDeclLen)
          {
          	logError("sampler declarations must have a sampler name, e.g. sampler[\"diffuseMap\"]");
             return false;
@@ -140,7 +141,7 @@ bool CustomMaterial::onAdd()
          
          // Assert sampler names are defined on ShaderData
          S32 pos = -1;
-         String samplerName = entry->slotName + dStrlen(samplerDecl);
+         String samplerName = entry->slotName + samplerDeclLen;
          samplerName.insert(0, '$');
          mShaderData->hasSamplerDef(samplerName, pos);
          

+ 0 - 35
Engine/source/materials/materialDefinition.cpp

@@ -502,11 +502,6 @@ void Material::initPersistFields()
 
    endGroup( "Behavioral" );
 
-   addProtectedField("customShaderFeature", TypeRealString, NULL, &protectedSetCustomShaderFeature, &defaultProtectedGetFn,
-	   "Do not modify, for internal use.", AbstractClassRep::FIELD_HideInInspectors);
-   addProtectedField("CustomShaderFeatureUniforms", TypeRealString, NULL, &protectedSetCustomShaderFeatureUniforms, &defaultProtectedGetFn,
-	   "Do not modify, for internal use.", AbstractClassRep::FIELD_HideInInspectors);
-
    Parent::initPersistFields();
 }
 
@@ -524,36 +519,6 @@ bool Material::writeField( StringTableEntry fieldname, const char *value )
    return Parent::writeField( fieldname, value );
 }
 
-bool Material::protectedSetCustomShaderFeature(void *object, const char *index, const char *data)
-{
-	Material *material = static_cast< Material* >(object);
-
-	CustomShaderFeatureData* customFeature;
-	if (!Sim::findObject(data, customFeature))
-		return false;
-
-	material->mCustomShaderFeatures.push_back(customFeature);
-
-	return false;
-}
-
-bool Material::protectedSetCustomShaderFeatureUniforms(void *object, const char *index, const char *data)
-{
-	Material *material = static_cast< Material* >(object);
-
-	if (index != NULL)
-	{
-		char featureName[256] = { 0 };
-		U32 id = 0;
-		dSscanf(index, "%s_%i", featureName, id);
-
-		String uniformName = data;
-	}
-
-	return false;
-}
-
-
 bool Material::onAdd()
 {
    if (Parent::onAdd() == false)

+ 0 - 10
Engine/source/materials/materialDefinition.h

@@ -41,10 +41,6 @@
    #include "console/dynamicTypes.h"
 #endif
 
-#ifndef CUSTOMSHADERFEATURE_H
-#include "shaderGen/customShaderFeature.h"
-#endif
-
 #ifndef IMAGE_ASSET_H
 #include "T3D/assets/ImageAsset.h"
 #endif
@@ -59,7 +55,6 @@ class FeatureSet;
 class FeatureType;
 class MaterialSoundProfile;
 class MaterialPhysicsProfile;
-class CustomShaderFeatureData;
 
 /// The basic material definition.
 class Material : public BaseMaterialDefinition
@@ -356,8 +351,6 @@ public:
    F32 mDirectSoundOcclusion;       ///< Amount of volume occlusion on direct sounds.
    F32 mReverbSoundOcclusion;       ///< Amount of volume occlusion on reverb sounds.
 
-   Vector<CustomShaderFeatureData*> mCustomShaderFeatures;
-
    ///@}
    
    String mMapTo; // map Material to this texture name
@@ -395,9 +388,6 @@ public:
    virtual void inspectPostApply();
    virtual bool writeField( StringTableEntry fieldname, const char *value );
 
-   static bool protectedSetCustomShaderFeature(void *object, const char *index, const char *data);
-   static bool protectedSetCustomShaderFeatureUniforms(void *object, const char *index, const char *data);
-
    //
    // ConsoleObject interface
    //

+ 1 - 1
Engine/source/materials/processedCustomMaterial.cpp

@@ -238,7 +238,7 @@ bool ProcessedCustomMaterial::init( const FeatureSet &features,
       return false;
    }
 
-   rpd->shaderHandles.init( rpd->shader, mCustomMaterial->mCustomShaderFeatures, mCustomMaterial );
+   rpd->shaderHandles.init( rpd->shader, mCustomMaterial );
    _initMaterialParameters();
    mDefaultParameters = allocMaterialParameters();
    setMaterialParameters( mDefaultParameters, 0 );

+ 0 - 2
Engine/source/materials/processedMaterial.h

@@ -85,8 +85,6 @@ public:
 
    MaterialFeatureData mFeatureData;
 
-   Vector<CustomShaderFeatureData*> mCustomShaderFeatureData;
-
    bool mGlow;
 
    Material::BlendOp mBlendOp;

+ 3 - 16
Engine/source/materials/processedShaderMaterial.cpp

@@ -54,7 +54,7 @@
 ///
 /// ShaderConstHandles
 ///
-void ShaderConstHandles::init( GFXShader *shader, Vector<CustomShaderFeatureData*> customFeatureData, CustomMaterial* mat /*=NULL*/)
+void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/)
 {
    mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor");
    mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat);
@@ -125,19 +125,6 @@ void ShaderConstHandles::init( GFXShader *shader, Vector<CustomShaderFeatureData
 
    // Deferred Shading
    mMatInfoFlagsSC = shader->getShaderConstHandle(ShaderGenVars::matInfoFlags);
-
-   //custom features
-   for (U32 f = 0; f < customFeatureData.size(); ++f)
-   {
-	   for (U32 i = 0; i < customFeatureData[f]->mAddedShaderConstants.size(); ++i)
-	   {
-		   customHandleData newSC;
-		   newSC.handle = shader->getShaderConstHandle(String("$") + String(customFeatureData[f]->mAddedShaderConstants[i]));
-		   newSC.handleName = customFeatureData[f]->mAddedShaderConstants[i];
-
-		   mCustomHandles.push_back(newSC);
-      }
-   }
 }
 
 ///
@@ -686,10 +673,10 @@ bool ProcessedShaderMaterial::_addPass( ShaderRenderPassData &rpd,
 
    // Generate shader
    GFXShader::setLogging( true, true );
-   rpd.shader = SHADERGEN->getShader( rpd.mFeatureData, mMaterial->mCustomShaderFeatures, mVertexFormat, &mUserMacros, samplers );
+   rpd.shader = SHADERGEN->getShader( rpd.mFeatureData, mVertexFormat, &mUserMacros, samplers );
    if( !rpd.shader )
       return false;
-   rpd.shaderHandles.init( rpd.shader, mMaterial->mCustomShaderFeatures);
+   rpd.shaderHandles.init( rpd.shader );
 
    // If a pass glows, we glow
    if( rpd.mGlow )

+ 1 - 1
Engine/source/materials/processedShaderMaterial.h

@@ -110,7 +110,7 @@ public:
    };
    Vector<customHandleData> mCustomHandles;
 
-   void init( GFXShader* shader, Vector<CustomShaderFeatureData*> customFeatureData, CustomMaterial* mat = NULL);
+   void init( GFXShader* shader, CustomMaterial* mat = NULL);
    
 };
 

+ 1 - 1
Engine/source/math/mPolyhedron.h

@@ -98,7 +98,7 @@ struct PolyhedronData
          ///   it defines a *clockwise* orientation for face[ 0 ].  This is important!
          U32 vertex[ 2 ];
 
-         Edge() { std::fill_n(face, 2, 0), std::fill_n(vertex, 0, 0); }
+         Edge() { std::fill_n(face, 2, 0), std::fill_n(vertex, 2, 0); }
          Edge( U32 face1, U32 face2, U32 vertex1, U32 vertex2 )
          {
             face[ 0 ] = face1;

+ 1 - 1
Engine/source/module/moduleManager.cpp

@@ -616,7 +616,7 @@ bool ModuleManager::unloadModuleGroup( const char* pModuleGroup )
             if ( mEchoInfo )
             {
                 Con::printf( "Module Manager: Unloading group '%s' but could not unload module Id '%s' at version Id '%d'.",
-                    moduleGroup, pLoadedEntry->mpModuleDefinition->getModuleId(), pLoadedEntry->mpModuleDefinition->getVersionId() );
+                   moduleGroup, pLoadReadyModuleDefinition->getModuleId(), pLoadReadyModuleDefinition->getVersionId());
             }
             // Skip.
             continue;

+ 3 - 1
Engine/source/renderInstance/renderProbeMgr.cpp

@@ -918,7 +918,7 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles)
    Frustum culler;
    culler.set(false,
       query.fov,
-      (F32)resolution / (F32)resolution,
+      1.0f,
       query.nearPlane,
       query.farPlane,
       query.cameraMatrix);
@@ -962,6 +962,8 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe, bool writeFiles)
       IBLUtilities::GenerateIrradianceMap(renderTarget, cubeRefl.getCubemap(), clientProbe->mIrridianceMap->mCubemap);
       IBLUtilities::GeneratePrefilterMap(renderTarget, cubeRefl.getCubemap(), prefilterMipLevels, clientProbe->mPrefilterMap->mCubemap);
 
+      renderTarget->destroySelf();
+
       U32 endMSTime = Platform::getRealMilliseconds();
       F32 diffTime = F32(endMSTime - startMSTime);
       Con::warnf("RenderProbeMgr::bake() - Finished Capture! Took %g milliseconds", diffTime);

+ 1 - 1
Engine/source/renderInstance/renderTranslucentMgr.cpp

@@ -306,7 +306,7 @@ void RenderTranslucentMgr::render( SceneRenderState *state )
                if (passRI->accuTex != lastAccuTex)
                {
                   sgData.accuTex = passRI->accuTex;
-                  lastAccuTex = lastAccuTex;
+                  lastAccuTex = passRI->accuTex;
                   dirty = true;
                }
 

+ 2 - 2
Engine/source/scene/fogStructs.h

@@ -58,10 +58,10 @@ struct WaterFogData
       densityOffset = 0.0f;     
       wetDepth = 0.0f;
       wetDarkening = 0.0f;
-      color.set( 0.5f, 0.5f, 0.5f, 1.0f );
+      color = ColorI(128, 128, 128, 128);
       plane.set( 0.0f, 0.0f, 1.0f, 1e10 ); // Default to global bounds distance
       depthGradMax = 0.0f;
    }
 };
 
-#endif // _FOGSTRUCTS_H_
+#endif // _FOGSTRUCTS_H_

+ 1 - 1
Engine/source/scene/sceneObject.cpp

@@ -1704,7 +1704,7 @@ void SceneObject::updateRenderChangesByParent(){
 		// This is needed by objects that update their own render transform thru interpolate tick
 		// Mostly for stationary objects.
 
-		if (getClassName() == "Player")
+          if (getClassName() == StringTable->insert("Player"))
 			mat.mul(offset,getRenderTransform());  
 		else										
 			mat.mul(offset,getTransform());	 

+ 1 - 1
Engine/source/sfx/sfxSound.cpp

@@ -149,7 +149,7 @@ SFXSound* SFXSound::_create(   SFXDevice* device,
    SFXBuffer* buffer = SFX->_createBuffer( stream, description );
    if( !buffer )
    {
-      source->deleteObject();
+      SAFE_DELETE_OBJECT(source);
 
       Con::errorf( "SFXSound::_create() - Could not create device buffer!" );
       return NULL;

+ 2 - 0
Engine/source/shaderGen/customShaderFeature.cpp

@@ -185,6 +185,8 @@ bool CustomShaderFeatureData::hasFeature(String name)
    if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
       return mFeatureGLSL->hasFeature(name);
 #endif
+
+   return false;
 }
 
 void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValueRef* argv)

+ 3 - 82
Engine/source/shaderGen/shaderGen.cpp

@@ -141,16 +141,13 @@ void ShaderGen::generateShader( const MaterialFeatureData &featureData,
                                 F32 *pixVersion,
                                 const GFXVertexFormat *vertexFormat,
                                 const char* cacheName,
-                                Vector<GFXShaderMacro> &macros,
-								Vector<CustomShaderFeatureData*> &customFeatureData)
+                                Vector<GFXShaderMacro> &macros)
 {
    PROFILE_SCOPE( ShaderGen_GenerateShader );
 
    mFeatureData = featureData;
    mVertexFormat = vertexFormat;
 
-   mCustomFeaturesData = customFeatureData;
-
    _uninit();
    _init();
 
@@ -290,44 +287,6 @@ void ShaderGen::_processVertFeatures( Vector<GFXShaderMacro> &macros, bool macro
       }
    }
 
-   //Handle if we have any custom features
-   if (!mCustomFeaturesData.empty())
-   {
-	   for (U32 i = 0; i < mCustomFeaturesData.size(); ++i)
-	   {
-#ifdef TORQUE_D3D11
-         if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
-         {
-            mCustomFeaturesData[i]->mFeatureHLSL->processVert(mComponents, mFeatureData);
-
-            String line = String::ToString("   // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
-            mOutput->addStatement(new GenOp(line));
-
-            if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
-               mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
-
-            mCustomFeaturesData[i]->mFeatureHLSL->reset();
-            mOutput->addStatement(new GenOp("   \r\n"));
-         }
-#endif
-#ifdef TORQUE_OPENGL
-         if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
-         {
-            mCustomFeaturesData[i]->mFeatureGLSL->processVert(mComponents, mFeatureData);
-
-            String line = String::ToString("   // %s\r\n", mCustomFeaturesData[i]->mFeatureGLSL->getName().c_str());
-            mOutput->addStatement(new GenOp(line));
-
-            if (mCustomFeaturesData[i]->mFeatureGLSL->getOutput())
-               mOutput->addStatement(mCustomFeaturesData[i]->mFeatureGLSL->getOutput());
-
-            mCustomFeaturesData[i]->mFeatureGLSL->reset();
-            mOutput->addStatement(new GenOp("   \r\n"));
-         }
-#endif
-	   }
-   }
-
    ShaderConnector *connect = dynamic_cast<ShaderConnector *>( mComponents[C_CONNECTOR] );
    connect->sortVars();
 }
@@ -367,44 +326,6 @@ void ShaderGen::_processPixFeatures( Vector<GFXShaderMacro> &macros, bool macros
          mOutput->addStatement( new GenOp( "   \r\n" ) );
       }
    }
-
-   //Handle if we have any custom features
-   if (!mCustomFeaturesData.empty())
-   {
-	   for (U32 i = 0; i < mCustomFeaturesData.size(); ++i)
-	   {
-#ifdef TORQUE_D3D11
-         if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
-         {
-            mCustomFeaturesData[i]->mFeatureHLSL->processPix(mComponents, mFeatureData);
-
-            String line = String::ToString("   // %s\r\n", mCustomFeaturesData[i]->mFeatureHLSL->getName().c_str());
-            mOutput->addStatement(new GenOp(line));
-
-            if (mCustomFeaturesData[i]->mFeatureHLSL->getOutput())
-               mOutput->addStatement(mCustomFeaturesData[i]->mFeatureHLSL->getOutput());
-
-            mCustomFeaturesData[i]->mFeatureHLSL->reset();
-            mOutput->addStatement(new GenOp("   \r\n"));
-         }
-#endif
-#ifdef TORQUE_OPENGL
-         if (GFX->getAdapterType() == GFXAdapterType::OpenGL)
-         {
-            mCustomFeaturesData[i]->mFeatureGLSL->processPix(mComponents, mFeatureData);
-
-            String line = String::ToString("   // %s\r\n", mCustomFeaturesData[i]->mFeatureGLSL->getName().c_str());
-            mOutput->addStatement(new GenOp(line));
-
-            if (mCustomFeaturesData[i]->mFeatureGLSL->getOutput())
-               mOutput->addStatement(mCustomFeaturesData[i]->mFeatureGLSL->getOutput());
-
-            mCustomFeaturesData[i]->mFeatureGLSL->reset();
-            mOutput->addStatement(new GenOp("   \r\n"));
-         }
-#endif
-	   }
-   }
    
    ShaderConnector *connect = dynamic_cast<ShaderConnector *>( mComponents[C_CONNECTOR] );
    connect->sortVars();
@@ -528,7 +449,7 @@ void ShaderGen::_printPixShader( Stream &stream )
    mPrinter->printPixelShaderCloser(stream);
 }
 
-GFXShader* ShaderGen::getShader( const MaterialFeatureData &featureData, Vector<CustomShaderFeatureData*> &customFeatureData, const GFXVertexFormat *vertexFormat, const Vector<GFXShaderMacro> *macros, const Vector<String> &samplers )
+GFXShader* ShaderGen::getShader( const MaterialFeatureData &featureData, const GFXVertexFormat *vertexFormat, const Vector<GFXShaderMacro> *macros, const Vector<String> &samplers )
 {
    PROFILE_SCOPE( ShaderGen_GetShader );
 
@@ -568,7 +489,7 @@ GFXShader* ShaderGen::getShader( const MaterialFeatureData &featureData, Vector<
    shaderMacros.push_back( GFXShaderMacro( "TORQUE_SHADERGEN" ) );
    if ( macros )
       shaderMacros.merge( *macros );
-   generateShader( featureData, vertFile, pixFile, &pixVersion, vertexFormat, cacheKey, shaderMacros, customFeatureData );
+   generateShader( featureData, vertFile, pixFile, &pixVersion, vertexFormat, cacheKey, shaderMacros );
 
    GFXShader *shader = GFX->createShader();
    if (!shader->init(vertFile, pixFile, pixVersion, shaderMacros, samplers, &mInstancingFormat))

+ 2 - 9
Engine/source/shaderGen/shaderGen.h

@@ -47,10 +47,6 @@
 #include "materials/materialFeatureData.h"
 #endif
 
-#ifndef CUSTOMSHADERFEATURE_H
-#include "shadergen/customShaderFeature.h"
-#endif
-
 /// Base class used by shaderGen to be API agnostic.  Subclasses implement the various methods
 /// in an API specific way.
 class ShaderGenPrinter
@@ -155,11 +151,10 @@ public:
                         F32 *pixVersion,
                         const GFXVertexFormat *vertexFormat,
                         const char* cacheName,
-                        Vector<GFXShaderMacro> &macros,
-						Vector<CustomShaderFeatureData*> &customFeatureData);
+                        Vector<GFXShaderMacro> &macros);
 
    // Returns a shader that implements the features listed by dat.
-   GFXShader* getShader( const MaterialFeatureData &dat, Vector<CustomShaderFeatureData*> &customFeatureData, const GFXVertexFormat *vertexFormat, const Vector<GFXShaderMacro> *macros, const Vector<String> &samplers );
+   GFXShader* getShader( const MaterialFeatureData &dat, const GFXVertexFormat *vertexFormat, const Vector<GFXShaderMacro> *macros, const Vector<String> &samplers );
 
    // This will delete all of the procedural shaders that we have.  Used to regenerate shaders when
    // the ShaderFeatures have changed (due to lighting system change, or new plugin)
@@ -181,8 +176,6 @@ protected:
    
    Vector< ShaderComponent *> mComponents;
 
-   Vector< CustomShaderFeatureData* > mCustomFeaturesData;
-
    AutoPtr<ShaderGenPrinter> mPrinter;
    AutoPtr<ShaderGenComponentFactory> mComponentFactory;
 

+ 1 - 1
Engine/source/sim/netConnection.h

@@ -863,7 +863,7 @@ public:
    void setScopeObject(NetObject *object);
 
    /// Get the object around which we are currently scoping network traffic.
-   NetObject* getScopeObject() {};
+   NetObject* getScopeObject() { return nullptr; };
 
    /// Add an object to scope.
    void objectInScope(NetObject *object);

+ 1 - 3
Engine/source/terrain/terrCellMaterial.cpp

@@ -482,8 +482,6 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
       featureData.features = features;
       featureData.materialFeatures = features;
 
-	  Vector<CustomShaderFeatureData*> customFeatures;
-
       // Check to see how many vertex shader output 
       // registers we're gonna need.
       U32 numTex = 0;
@@ -526,7 +524,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
          const bool logErrors = true;// matCount == 1;
          GFXShader::setLogging( logErrors, true );
 
-         pass->shader = SHADERGEN->getShader( featureData, customFeatures, getGFXVertexFormat<TerrVertex>(), NULL, mSamplerNames );
+         pass->shader = SHADERGEN->getShader( featureData, getGFXVertexFormat<TerrVertex>(), NULL, mSamplerNames );
       }
 
       // If we got a shader then we can continue.

+ 4 - 2
Engine/source/ts/collada/colladaUtils.cpp

@@ -770,6 +770,8 @@ static void conditioner_createDefaultClip(domCOLLADA* root)
 
 static void conditioner_fixupAnimation(domAnimation* anim)
 {
+   S32 visibilityLen = dStrlen("/visibility");
+
    for (S32 iChannel = 0; iChannel < anim->getChannel_array().getCount(); iChannel++) {
 
       // Get the animation elements: <channel>, <sampler>
@@ -815,7 +817,7 @@ static void conditioner_fixupAnimation(domAnimation* anim)
 
             // Get parent SID string
             char *parentSID = dStrdup(channel->getTarget());
-            parentSID[dStrlen(parentSID) - dStrlen("/visibility")] = '\0';
+            parentSID[dStrlen(parentSID) - visibilityLen] = '\0';
 
             // Find the parent element (should be a <node>)
             daeSIDResolver parentResolver(channel, parentSID);
@@ -3039,4 +3041,4 @@ void ColladaUtils::ExportData::processData()
          }
       }
    }
-}
+}

+ 2 - 1
Engine/source/ts/tsDump.cpp

@@ -64,6 +64,7 @@ void TSShapeInstance::dumpNode(Stream & stream ,S32 level, S32 nodeIndex, Vector
    if (objectList.size() == 0)
       dumpLine("\r\n");
 
+   S32 nodeNameLen = dStrlen(nodeName);
    S32 spaceCount = -1;
    for (S32 j=0;j<objectList.size(); j++)
    {
@@ -101,7 +102,7 @@ void TSShapeInstance::dumpNode(Stream & stream ,S32 level, S32 nodeIndex, Vector
 
       // how many spaces should we prepend if we have another object on this node
       if (spaceCount<0)
-         spaceCount = (S32)(dStrlen(space) + dStrlen(nodeName));
+         spaceCount = (S32)(dStrlen(space) + nodeNameLen);
 
       if(spaceCount > 2000)
          spaceCount = 2000;

+ 2 - 0
Engine/source/ts/tsShapeConstruct.cpp

@@ -424,6 +424,8 @@ bool TSShapeConstructor::onAdd()
       group = new SimGroup();
       if ( !group->registerObject("TSShapeConstructorGroup") )
       {
+         SAFE_DELETE(group);
+
          Con::errorf("TSShapeConstructor::onAdd failed: Could not register "
             "TSShapeConstructorGroup");
          return false;