mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Various misc. tweaks and fixes based on static code analysis to minimize/fix memleaks, crashes, or other performance impacting code.
This commit is contained in:
parent
d76c73c252
commit
8956559bfd
44 changed files with 124 additions and 258 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
//
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -85,8 +85,6 @@ public:
|
|||
|
||||
MaterialFeatureData mFeatureData;
|
||||
|
||||
Vector<CustomShaderFeatureData*> mCustomShaderFeatureData;
|
||||
|
||||
bool mGlow;
|
||||
|
||||
Material::BlendOp mBlendOp;
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue