diff --git a/Engine/source/T3D/assets/ImageAsset.cpp b/Engine/source/T3D/assets/ImageAsset.cpp index 046d98b4c..bc3875bc6 100644 --- a/Engine/source/T3D/assets/ImageAsset.cpp +++ b/Engine/source/T3D/assets/ImageAsset.cpp @@ -103,7 +103,7 @@ EndImplementEnumType; //----------------------------------------------------------------------------- -ImageAsset::ImageAsset() : AssetBase(), mImage(nullptr), mUseMips(true), mIsHDRImage(false), mIsValidImage(false) +ImageAsset::ImageAsset() : AssetBase(), mImage(nullptr), mUseMips(true), mIsHDRImage(false), mIsValidImage(false), mImageType(Albedo) { mImageFileName = StringTable->EmptyString(); } @@ -239,6 +239,50 @@ const char* ImageAsset::getImageInfo() return ""; } +const char* ImageAsset::getImageTypeNameFromType(ImageAsset::ImageTypes type) +{ + // must match ImageTypes order + static const char* _names[] = { + "Albedo" + "Normal" + "Composite" + "GUI" + "Roughness" + "AO" + "Metalness" + "Glow" + "Particle" + "Decal" + "Cubemap" + }; + + if (type < 0 || type >= ImageTypeCount) + { + Con::errorf("ImageAsset::getAdapterNameFromType - Invalid ImageType, defaulting to Albedo"); + return _names[Albedo]; + } + + return _names[type]; +} + +ImageAsset::ImageTypes ImageAsset::getImageTypeFromName(const char* name) +{ + S32 ret = -1; + for (S32 i = 0; i < ImageTypeCount; i++) + { + if (!dStricmp(getImageTypeNameFromType((ImageTypes)i), name)) + ret = i; + } + + if (ret == -1) + { + Con::errorf("ImageAsset::getImageTypeFromName - Invalid ImageType name, defaulting to Albedo"); + ret = Albedo; + } + + return (ImageTypes)ret; +} + DefineEngineMethod(ImageAsset, getImageFilename, const char*, (), , "Creates an instance of the given GameObject given the asset definition.\n" "@return The GameObject entity created from the asset.") diff --git a/Engine/source/T3D/assets/ImageAsset.h b/Engine/source/T3D/assets/ImageAsset.h index a053c80b2..332020478 100644 --- a/Engine/source/T3D/assets/ImageAsset.h +++ b/Engine/source/T3D/assets/ImageAsset.h @@ -65,6 +65,7 @@ public: Particle = 8, Decal = 9, Cubemap = 10, + ImageTypeCount = 11 }; protected: @@ -100,6 +101,11 @@ public: const char* getImageInfo(); + static const char* getImageTypeNameFromType(ImageTypes type); + static ImageTypes getImageTypeFromName(const char* name); + + void setImageType(ImageTypes type) { mImageType = type; } + protected: virtual void initializeAsset(void); virtual void onAssetRefresh(void); diff --git a/Engine/source/T3D/assets/ShapeAsset.cpp b/Engine/source/T3D/assets/ShapeAsset.cpp index c51be0860..ef6abd354 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -44,6 +44,7 @@ // Debug Profiling. #include "platform/profiler.h" +#include "T3D/assets/assetImporter.h" //----------------------------------------------------------------------------- @@ -329,19 +330,21 @@ bool ShapeAsset::getAssetByFilename(StringTableEntry fileName, AssetPtrinsert(Con::getVariable("$importedLooseFileAsset")); + autoAssetImporter = new AssetImporter(); + autoAssetImporter->registerObject("autoAssetImporter"); + } - if (resultingAssetId != StringTable->EmptyString()) - { - shapeAsset->setAssetId(resultingAssetId); + StringTableEntry resultingAssetId = autoAssetImporter->autoImportFile(fileName); - if (!shapeAsset->isNull()) - return true; - } + if (resultingAssetId != StringTable->EmptyString()) + { + shapeAsset->setAssetId(resultingAssetId); + + if (!shapeAsset->isNull()) + return true; } //Didn't work, so have us fall back to a placeholder asset @@ -375,17 +378,19 @@ StringTableEntry ShapeAsset::getAssetIdByFilename(StringTableEntry fileName) Con::warnf("ShapeAsset::getAssetByFilename - Attempted to in-place import a shapefile(%s) that had no associated asset", fileName); #endif - ConsoleValueRef result = Con::executef("importLooseFile", fileName, true); - - if (result.getBoolValue()) + AssetImporter* autoAssetImporter; + if (!Sim::findObject("autoAssetImporter", autoAssetImporter)) { - StringTableEntry resultingAssetId = StringTable->insert(Con::getVariable("$importedLooseFileAsset")); + autoAssetImporter = new AssetImporter(); + autoAssetImporter->registerObject("autoAssetImporter"); + } - if (resultingAssetId != StringTable->EmptyString()) - { - shapeAssetId = resultingAssetId; - return shapeAssetId; - } + StringTableEntry resultingAssetId = autoAssetImporter->autoImportFile(fileName); + + if (resultingAssetId != StringTable->EmptyString()) + { + shapeAssetId = resultingAssetId; + return shapeAssetId; } //Didn't work, so have us fall back to a placeholder asset diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp new file mode 100644 index 000000000..b8ca4194d --- /dev/null +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -0,0 +1,2093 @@ +#include "assetImporter.h" +#include "assetImporter_ScriptBinding.h" +#include "core/strings/findMatch.h" +#include "ImageAsset.h" +#include "ShapeAsset.h" +#include "SoundAsset.h" +#include "MaterialAsset.h" +#include "ShapeAnimationAsset.h" + +#include "ts/collada/colladaUtils.h" +#include "ts/collada/colladaAppNode.h" +#include "ts/collada/colladaShapeLoader.h" + +#include "ts/assimp/assimpShapeLoader.h" +#include "ts/tsShapeConstruct.h" + + +ConsoleDocClass(AssetImportConfig, + "@brief Defines properties for an AssetImprotConfig object.\n" + "@AssetImportConfig is a SimObject derived object intended to act as a container for all the necessary configuration data when running the Asset Importer.\n" + "@It dictates if and how any given asset type will be processed when running an import action. This is because the Asset Importer utilizes a lot of informed logic\n" + "@to try and automate as much of the import process as possible. In theory, you would run the import on a given file, and based on your config the importer will do\n" + "@everything from importing the designated file, as well as finding and importing any associated files such as images or materials, and prepping the objects at time\n" + "@of import to avoid as much manual post-processing as possible.\n\n" + "@ingroup Assets\n" +); + +IMPLEMENT_CONOBJECT(AssetImportConfig); + +AssetImportConfig::AssetImportConfig() : + DuplicatAutoResolution("AutoRename"), + WarningsAsErrors(false), + PreventImportWithErrors(true), + AutomaticallyPromptMissingFiles(false), + ImportMesh(true), + DoUpAxisOverride(false), + UpAxisOverride("Z_AXIS"), + DoScaleOverride(false), + ScaleOverride(false), + IgnoreNodeScale(false), + AdjustCenter(false), + AdjustFloor(false), + CollapseSubmeshes(false), + LODType("TrailingNumber"), + ImportedNodes(""), + IgnoreNodes(""), + ImportMeshes(""), + IgnoreMeshes(""), + convertLeftHanded(false), + calcTangentSpace(false), + removeRedundantMats(false), + genUVCoords(false), + TransformUVs(false), + flipUVCoords(false), + findInstances(false), + limitBoneWeights(false), + JoinIdenticalVerts(false), + reverseWindingOrder(false), + invertNormals(false), + ImportMaterials(true), + CreatePBRConfig(true), + UseDiffuseSuffixOnOriginImage(false), + UseExistingMaterials(false), + IgnoreMaterials(""), + PopulateMaterialMaps(false), + ImportAnimations(true), + SeparateAnimations(false), + SeparateAnimationPrefix(""), + animTiming("FrameCount"), + animFPS(false), + GenerateCollisions(false), + GenCollisionType(""), + CollisionMeshPrefix(""), + GenerateLOSCollisions(false), + GenLOSCollisionType(""), + LOSCollisionMeshPrefix(""), + importImages(true), + ImageType("GUI"), + DiffuseTypeSuffixes("_ALBEDO,_DIFFUSE,_ALB,_DIF,_COLOR,_COL,_A,_C,-ALBEDO,-DIFFUSE,-ALB,-DIF,-COLOR,-COL,-A,-C"), + NormalTypeSuffixes("_NORMAL,_NORM,_N,-NORMAL,-NORM,-N"), + MetalnessTypeSuffixes("_METAL,_MET,_METALNESS,_METALLIC,_M,-METAL, -MET, -METALNESS, -METALLIC, -M"), + RoughnessTypeSuffixes("_ROUGH,_ROUGHNESS,_R,-ROUGH,-ROUGHNESS,-R"), + SmoothnessTypeSuffixes("_SMOOTH,_SMOOTHNESS,_S,-SMOOTH,-SMOOTHNESS,-S"), + AOTypeSuffixes("_AO,_AMBIENT,_AMBIENTOCCLUSION,-AO,-AMBIENT,-AMBIENTOCCLUSION"), + PBRTypeSuffixes("_COMP,_COMPOSITE,_PBR,-COMP,-COMPOSITE,-PBR"), + TextureFilteringMode("Bilinear"), + UseMips(true), + IsHDR(false), + Scaling(false), + ImagesCompressed(false), + GenerateMaterialOnImport(true), + importSounds(true), + VolumeAdjust(false), + PitchAdjust(false), + SoundsCompressed(false) +{ +} + +AssetImportConfig::~AssetImportConfig() +{ + +} + +/// Engine. +void AssetImportConfig::initPersistFields() +{ + Parent::initPersistFields(); + + addGroup("General"); + addField("DuplicatAutoResolution", TypeString, Offset(DuplicatAutoResolution, AssetImportConfig), "Duplicate Asset Auto-Resolution Action. Options are None, AutoPrune, AutoRename"); + addField("WarningsAsErrors", TypeBool, Offset(WarningsAsErrors, AssetImportConfig), "Indicates if warnings should be treated as errors"); + addField("PreventImportWithErrors", TypeBool, Offset(PreventImportWithErrors, AssetImportConfig), "Indicates if importing should be prevented from completing if any errors are detected at all"); + addField("AutomaticallyPromptMissingFiles", TypeBool, Offset(AutomaticallyPromptMissingFiles, AssetImportConfig), "Should the importer automatically prompt to find missing files if they are not detected automatically by the importer"); + endGroup("General"); + + addGroup("Meshes"); + addField("ImportMesh", TypeBool, Offset(ImportMesh, AssetImportConfig), "Indicates if this config supports importing meshes"); + addField("DoUpAxisOverride", TypeBool, Offset(DoUpAxisOverride, AssetImportConfig), "Indicates if the up axis in the model file should be overridden "); + addField("UpAxisOverride", TypeString, Offset(UpAxisOverride, AssetImportConfig), "If overriding, what axis should be used as up. Options are X_AXIS, Y_AXIS, Z_AXIS"); + addField("DoScaleOverride", TypeBool, Offset(DoScaleOverride, AssetImportConfig), "Indicates if the scale in the model file should be overridden"); + addField("ScaleOverride", TypeF32, Offset(ScaleOverride, AssetImportConfig), "If overriding, what scale should be used"); + addField("IgnoreNodeScale", TypeBool, Offset(IgnoreNodeScale, AssetImportConfig), "Indicates if scale of nodes should be ignored"); + addField("AdjustCenter", TypeBool, Offset(AdjustCenter, AssetImportConfig), "Indicates if the center of the model file should be automatically recentered"); + addField("AdjustFloor", TypeBool, Offset(AdjustFloor, AssetImportConfig), "Indicates if the floor height of the model file should be automatically zero'd"); + addField("CollapseSubmeshes", TypeBool, Offset(CollapseSubmeshes, AssetImportConfig), "Indicates if submeshes should be collapsed down into a single main mesh"); + addField("LODType", TypeString, Offset(LODType, AssetImportConfig), "Indicates what LOD mode the model file should utilize to process out LODs. Options are TrailingNumber, DetectDTS, SingleSize"); + addField("ImportedNodes", TypeString, Offset(ImportedNodes, AssetImportConfig), " A list of what nodes should be guaranteed to be imported if found in the model file. Separated by either , or ;"); + addField("IgnoreNodes", TypeString, Offset(IgnoreNodes, AssetImportConfig), "A list of what nodes should be guaranteed to not be imported if found in the model file. Separated by either , or ;"); + addField("ImportMeshes", TypeString, Offset(ImportMeshes, AssetImportConfig), "A list of what mesh objects should be guaranteed to be imported if found in the model file. Separated by either , or ;"); + addField("IgnoreMeshes", TypeString, Offset(IgnoreMeshes, AssetImportConfig), "A list of what mesh objects should be guaranteed to not be imported if found in the model file. Separated by either , or ;"); + addField("convertLeftHanded", TypeBool, Offset(convertLeftHanded, AssetImportConfig), "Flag to indicate the shape loader should convert to a left-handed coordinate system"); + addField("calcTangentSpace", TypeBool, Offset(calcTangentSpace, AssetImportConfig), "Should the shape loader calculate tangent space values"); + addField("removeRedundantMats", TypeBool, Offset(removeRedundantMats, AssetImportConfig), "Should the shape loader automatically prune redundant/duplicate materials"); + addField("genUVCoords", TypeBool, Offset(genUVCoords, AssetImportConfig), "Should the shape loader auto-generate UV Coordinates for the mesh."); + addField("TransformUVs", TypeBool, Offset(TransformUVs, AssetImportConfig), "Should the UV coordinates be transformed"); + addField("flipUVCoords", TypeBool, Offset(flipUVCoords, AssetImportConfig), "Should the UV coordinates be flipped"); + addField("findInstances", TypeBool, Offset(findInstances, AssetImportConfig), "Should the shape loader automatically look for instanced submeshes in the model file"); + addField("limitBoneWeights", TypeBool, Offset(limitBoneWeights, AssetImportConfig), "Should the shape loader limit the bone weights"); + addField("JoinIdenticalVerts", TypeBool, Offset(JoinIdenticalVerts, AssetImportConfig), "Should the shape loader automatically merge identical/duplicate verts"); + addField("reverseWindingOrder", TypeBool, Offset(reverseWindingOrder, AssetImportConfig), "Should the shape loader reverse the winding order of the mesh's face indicies"); + addField("invertNormals", TypeBool, Offset(invertNormals, AssetImportConfig), "Should the normals on the model be inverted"); + endGroup("Meshes"); + + addGroup("Materials"); + addField("DuplicatAutoResolution", TypeString, Offset(DuplicatAutoResolution, AssetImportConfig), "Duplicate Asset Auto-Resolution Action. Options are None, AutoPrune, AutoRename"); + addField("ImportMaterials", TypeBool, Offset(ImportMaterials, AssetImportConfig), "Does this config allow for importing of materials"); + addField("CreatePBRConfig", TypeBool, Offset(PreventImportWithErrors, AssetImportConfig), "When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map"); + addField("UseDiffuseSuffixOnOriginImage", TypeBool, Offset(UseDiffuseSuffixOnOriginImage, AssetImportConfig), "When generating a material off of an importing image, should the importer force appending a diffusemap suffix onto the end to avoid potential naming confusion.\n e.g. MyCoolStuff.png is imported, generating MyCoolStuff material asset and MyCoolStuff_Diffuse image asset"); + addField("UseExistingMaterials", TypeBool, Offset(UseExistingMaterials, AssetImportConfig), "Should the importer try and use existing material assets in the game directory if at all possible. (Not currently utilized)"); + addField("IgnoreMaterials", TypeString, Offset(IgnoreMaterials, AssetImportConfig), "A list of material names that should not be imported. Separated by either , or ;"); + addField("PopulateMaterialMaps", TypeBool, Offset(PopulateMaterialMaps, AssetImportConfig), "When processing a material asset, should the importer attempt to populate the various material maps on it by looking up common naming conventions for potentially relevent image files.\n e.g. If MyCoolStuff_Diffuse.png is imported, generating MyCoolStuff material, it would also find MyCoolStuff_Normal and MyCoolStuff_PBR images and map them to the normal and PBRConfig maps respectively automatically"); + endGroup("Materials"); + + addGroup("Meshes"); + addField("ImportAnimations", TypeBool, Offset(ImportAnimations, AssetImportConfig), "Does this config allow for importing Shape Animations"); + addField("SeparateAnimations", TypeBool, Offset(SeparateAnimations, AssetImportConfig), "When importing a shape file, should the animations within be separated out into unique files"); + addField("SeparateAnimationPrefix", TypeString, Offset(SeparateAnimationPrefix, AssetImportConfig), "If separating animations out from a source file, what prefix should be added to the names for grouping association"); + addField("animTiming", TypeString, Offset(animTiming, AssetImportConfig), "Defines the animation timing for the given animation sequence. Options are FrameTime, Seconds, Milliseconds"); + addField("animFPS", TypeBool, Offset(animFPS, AssetImportConfig), "The FPS of the animation sequence"); + endGroup("General"); + + addGroup("Collision"); + addField("GenerateCollisions", TypeBool, Offset(GenerateCollisions, AssetImportConfig), "Does this configuration generate collision geometry when importing. (Not currently enabled)"); + addField("GenCollisionType", TypeString, Offset(GenCollisionType, AssetImportConfig), "What sort of collision geometry is generated. (Not currently enabled)"); + addField("CollisionMeshPrefix", TypeString, Offset(CollisionMeshPrefix, AssetImportConfig), "What prefix is added to the collision geometry generated. (Not currently enabled)"); + addField("GenerateLOSCollisions", TypeBool, Offset(GenerateLOSCollisions, AssetImportConfig), "Does this configuration generate Line of Sight collision geometry. (Not currently enabled)"); + addField("GenLOSCollisionType", TypeString, Offset(GenLOSCollisionType, AssetImportConfig), "What sort of Line of Sight collision geometry is generated. (Not currently enabled)"); + addField("LOSCollisionMeshPrefix", TypeString, Offset(LOSCollisionMeshPrefix, AssetImportConfig), "What prefix is added to the Line of Sight collision geometry generated. (Not currently enabled)"); + endGroup("Collision"); + + addGroup("Images"); + addField("importImages", TypeBool, Offset(importImages, AssetImportConfig), "Does this configuration support importing images."); + addField("ImageType", TypeString, Offset(ImageType, AssetImportConfig), "What is the default ImageType images are imported as. Options are: N/A, Diffuse, Normal, Metalness, Roughness, AO, PBRConfig, GUI, Cubemap"); + addField("DiffuseTypeSuffixes", TypeString, Offset(DiffuseTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a diffuse map. \n e.g. _Albedo or _Color"); + addField("NormalTypeSuffixes", TypeString, Offset(NormalTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a normal map. \n e.g. _Normal or _Norm"); + addField("MetalnessTypeSuffixes", TypeString, Offset(MetalnessTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a metalness map. \n e.g. _Metalness or _Metal"); + addField("RoughnessTypeSuffixes", TypeString, Offset(RoughnessTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a roughness map.\n e.g. _roughness or _rough"); + addField("SmoothnessTypeSuffixes", TypeString, Offset(SmoothnessTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a smoothness map. \n e.g. _smoothness or _smooth"); + addField("AOTypeSuffixes", TypeString, Offset(AOTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a ambient occlusion map. \n e.g. _ambient or _ao"); + addField("PBRTypeSuffixes", TypeString, Offset(PBRTypeSuffixes, AssetImportConfig), "What type of suffixes are scanned to detect if an importing image is a PBRConfig map.\n e.g. _Composite or _PBR"); + addField("TextureFilteringMode", TypeString, Offset(TextureFilteringMode, AssetImportConfig), "Indicates what filter mode images imported with this configuration utilizes. Options are Linear, Bilinear, Trilinear"); + addField("UseMips", TypeBool, Offset(UseMips, AssetImportConfig), "Indicates if images imported with this configuration utilize mipmaps"); + + addField("IsHDR", TypeBool, Offset(IsHDR, AssetImportConfig), "Indicates if images imported with this configuration are in an HDR format"); + addField("Scaling", TypeF32, Offset(Scaling, AssetImportConfig), "Indicates what amount of scaling images imported with this configuration use"); + addField("ImagesCompressed", TypeBool, Offset(ImagesCompressed, AssetImportConfig), "Indicates if images imported with this configuration are compressed"); + addField("GenerateMaterialOnImport", TypeBool, Offset(GenerateMaterialOnImport, AssetImportConfig), "Indicates if images imported with this configuration generate a parent material for it as well"); + endGroup("Images"); + + addGroup("Sounds"); + addField("importSounds", TypeBool, Offset(importSounds, AssetImportConfig), "Indicates if sounds are imported with this configuration"); + addField("VolumeAdjust", TypeF32, Offset(VolumeAdjust, AssetImportConfig), "Indicates what amount the volume is adjusted on sounds imported with this configuration"); + addField("PitchAdjust", TypeF32, Offset(PitchAdjust, AssetImportConfig), "Indicates what amount the pitch is adjusted on sounds imported with this configuration"); + addField("SoundsCompressed", TypeBool, Offset(SoundsCompressed, AssetImportConfig), "Indicates if sounds imported with this configuration are compressed"); + endGroup("Sounds"); +} + +void AssetImportConfig::loadImportConfig(Settings* configSettings, String configName) +{ + //General + DuplicatAutoResolution = configSettings->value(String(configName + "/General/DuplicatAutoResolution").c_str()); + WarningsAsErrors = dAtob(configSettings->value(String(configName + "/General/WarningsAsErrors").c_str())); + PreventImportWithErrors = dAtob(configSettings->value(String(configName + "/General/PreventImportWithErrors").c_str())); + AutomaticallyPromptMissingFiles = dAtob(configSettings->value(String(configName + "/General/AutomaticallyPromptMissingFiles").c_str())); + + //Meshes + ImportMesh = dAtob(configSettings->value(String(configName + "/Meshes/ImportMesh").c_str())); + DoUpAxisOverride = dAtob(configSettings->value(String(configName + "/Meshes/DoUpAxisOverride").c_str())); + UpAxisOverride = configSettings->value(String(configName + "/Meshes/UpAxisOverride").c_str()); + DoScaleOverride = dAtob(configSettings->value(String(configName + "/Meshes/DoScaleOverride").c_str())); + ScaleOverride = dAtof(configSettings->value(String(configName + "/Meshes/ScaleOverride").c_str())); + IgnoreNodeScale = dAtob(configSettings->value(String(configName + "/Meshes/IgnoreNodeScale").c_str())); + AdjustCenter = dAtob(configSettings->value(String(configName + "/Meshes/AdjustCenter").c_str())); + AdjustFloor = dAtob(configSettings->value(String(configName + "/Meshes/AdjustFloor").c_str())); + CollapseSubmeshes = dAtob(configSettings->value(String(configName + "/Meshes/CollapseSubmeshes").c_str())); + LODType = configSettings->value(String(configName + "/Meshes/LODType").c_str()); + ImportedNodes = configSettings->value(String(configName + "/Meshes/ImportedNodes").c_str()); + IgnoreNodes = configSettings->value(String(configName + "/Meshes/IgnoreNodes").c_str()); + ImportMeshes = configSettings->value(String(configName + "/Meshes/ImportMeshes").c_str()); + IgnoreMeshes = configSettings->value(String(configName + "/Meshes/IgnoreMeshes").c_str()); + + //Assimp/Collada + convertLeftHanded = dAtob(configSettings->value(String(configName + "/Meshes/convertLeftHanded").c_str())); + calcTangentSpace = dAtob(configSettings->value(String(configName + "/Meshes/calcTangentSpace").c_str())); + removeRedundantMats = dAtob(configSettings->value(String(configName + "/Meshes/removeRedundantMats").c_str())); + genUVCoords = dAtob(configSettings->value(String(configName + "/Meshes/genUVCoords").c_str())); + TransformUVs = dAtob(configSettings->value(String(configName + "/Meshes/TransformUVs").c_str())); + flipUVCoords = dAtob(configSettings->value(String(configName + "/Meshes/flipUVCoords").c_str())); + findInstances = dAtob(configSettings->value(String(configName + "/Meshes/findInstances").c_str())); + limitBoneWeights = dAtob(configSettings->value(String(configName + "/Meshes/limitBoneWeights").c_str())); + JoinIdenticalVerts = dAtob(configSettings->value(String(configName + "/Meshes/JoinIdenticalVerts").c_str())); + reverseWindingOrder = dAtob(configSettings->value(String(configName + "/Meshes/reverseWindingOrder").c_str())); + invertNormals = dAtob(configSettings->value(String(configName + "/Meshes/invertNormals").c_str())); + + //Materials + ImportMaterials = dAtob(configSettings->value(String(configName + "/Materials/ImportMaterials").c_str())); + CreatePBRConfig = dAtob(configSettings->value(String(configName + "/Materials/CreatePBRConfig").c_str())); + UseDiffuseSuffixOnOriginImage = dAtob(configSettings->value(String(configName + "/Materials/UseDiffuseSuffixOnOriginImage").c_str())); + UseExistingMaterials = dAtob(configSettings->value(String(configName + "/Materials/UseExistingMaterials").c_str())); + IgnoreMaterials = configSettings->value(String(configName + "/Materials/IgnoreMaterials").c_str()); + PopulateMaterialMaps = dAtob(configSettings->value(String(configName + "/Materials/invertPopulateMaterialMapsNormals").c_str())); + + //Animations + ImportAnimations = dAtob(configSettings->value(String(configName + "/Animations/ImportAnimations").c_str())); + SeparateAnimations = dAtob(configSettings->value(String(configName + "/Animations/SeparateAnimations").c_str())); + SeparateAnimationPrefix = configSettings->value(String(configName + "/Animations/SeparateAnimationPrefix").c_str()); + animTiming = configSettings->value(String(configName + "/Animations/animTiming").c_str()); + animFPS = dAtof(configSettings->value(String(configName + "/Animations/animFPS").c_str())); + + //Collisions + GenerateCollisions = dAtob(configSettings->value(String(configName + "/Collision/GenerateCollisions").c_str())); + GenCollisionType = configSettings->value(String(configName + "/Collision/GenCollisionType").c_str()); + CollisionMeshPrefix = configSettings->value(String(configName + "/Collision/CollisionMeshPrefix").c_str()); + GenerateLOSCollisions = dAtob(configSettings->value(String(configName + "/Collision/GenerateLOSCollisions").c_str())); + GenLOSCollisionType = configSettings->value(String(configName + "/Collision/GenLOSCollisionType").c_str()); + LOSCollisionMeshPrefix = configSettings->value(String(configName + "/Collision/LOSCollisionMeshPrefix").c_str()); + + //Images + importImages = dAtob(configSettings->value(String(configName + "/Images/importImages").c_str())); + ImageType = configSettings->value(String(configName + "/Images/ImageType").c_str()); + DiffuseTypeSuffixes = configSettings->value(String(configName + "/Images/DiffuseTypeSuffixes").c_str()); + NormalTypeSuffixes = configSettings->value(String(configName + "/Images/NormalTypeSuffixes").c_str()); + MetalnessTypeSuffixes = configSettings->value(String(configName + "/Images/MetalnessTypeSuffixes").c_str()); + RoughnessTypeSuffixes = configSettings->value(String(configName + "/Images/RoughnessTypeSuffixes").c_str()); + SmoothnessTypeSuffixes = configSettings->value(String(configName + "/Images/SmoothnessTypeSuffixes").c_str()); + AOTypeSuffixes = configSettings->value(String(configName + "/Images/AOTypeSuffixes").c_str()); + PBRTypeSuffixes = configSettings->value(String(configName + "/Images/PBRTypeSuffixes").c_str()); + TextureFilteringMode = configSettings->value(String(configName + "/Images/TextureFilteringMode").c_str()); + UseMips = dAtob(configSettings->value(String(configName + "/Images/UseMips").c_str())); + IsHDR = dAtob(configSettings->value(String(configName + "/Images/IsHDR").c_str())); + Scaling = dAtof(configSettings->value(String(configName + "/Images/Scaling").c_str())); + ImagesCompressed = dAtob(configSettings->value(String(configName + "/Images/Compressed").c_str())); + GenerateMaterialOnImport = dAtob(configSettings->value(String(configName + "/Images/GenerateMaterialOnImport").c_str())); + + //Sounds + VolumeAdjust = dAtof(configSettings->value(String(configName + "/Sounds/VolumeAdjust").c_str())); + PitchAdjust = dAtof(configSettings->value(String(configName + "/Sounds/PitchAdjust").c_str())); + SoundsCompressed = dAtob(configSettings->value(String(configName + "/Sounds/Compressed").c_str())); +} + +ConsoleDocClass(AssetImportObject, + "@brief Defines properties for an AssetImportObject object.\n" + "@AssetImportObject is a SimObject derived object intended to act as a stand-in for the to-be imported objects.\n" + "@It contains important info such as dependencies, if it's been processed, any error/status issues and the originating file\n" + "@or if it's been programmatically generated as part of the import process.\n\n" + "@ingroup Assets\n" +); + +IMPLEMENT_CONOBJECT(AssetImportObject); + +AssetImportObject::AssetImportObject() : + dirty(false), + skip(false), + processed(false), + generatedAsset(false), + parentAssetItem(nullptr), + tamlFilePath(""), + imageSuffixType(""), + shapeInfo(nullptr) +{ + +} + +AssetImportObject::~AssetImportObject() +{ + +} + +void AssetImportObject::initPersistFields() +{ + Parent::initPersistFields(); + + addField("assetType", TypeString, Offset(assetType, AssetImportObject), "What type is the importing asset"); + addField("filePath", TypeFilename, Offset(filePath, AssetImportObject), "What is the source file path of the importing asset"); + addField("assetName", TypeString, Offset(assetName, AssetImportObject), "What is the asset's name"); + addField("cleanAssetName", TypeString, Offset(cleanAssetName, AssetImportObject), "What is the original, unmodified by processing, asset name"); + addField("status", TypeString, Offset(status, AssetImportObject), "What is the current status of this asset item in it's import process"); + addField("statusType", TypeString, Offset(statusType, AssetImportObject), "If there is a warning or error status, what type is the condition for this asset item"); + addField("statusInfo", TypeString, Offset(statusInfo, AssetImportObject), "What is the articulated information of the status of the asset. Contains the error or warning log data"); + + addField("dirty", TypeBool, Offset(dirty, AssetImportObject), "Is the asset item currently flagged as dirty"); + addField("skip", TypeBool, Offset(skip, AssetImportObject), "Is this asset item marked to be skipped. If it is, it's usually due to being marked as deleted"); + addField("processed", TypeBool, Offset(processed, AssetImportObject), "Has the asset item been processed"); + addField("generatedAsset", TypeBool, Offset(generatedAsset, AssetImportObject), "Is this specific asset item generated as part of the import process of another item"); + + addField("tamlFilePath", TypeString, Offset(tamlFilePath, AssetImportObject), "What is the ultimate asset taml file path for this import item"); + + addField("imageSuffixType", TypeString, Offset(imageSuffixType, AssetImportObject), "Specific to ImageAsset type. What is the image asset's suffix type. Options are: Albedo, Normal, Roughness, AO, Metalness, PBRConfig"); + + addField("shapeInfo", TYPEID< GuiTreeViewCtrl >(), Offset(shapeInfo, AssetImportObject), "Specific to ShapeAsset type. Processed information about the shape file. Contains numbers and lists of meshes, materials and animations"); +} + +ConsoleDocClass(AssetImporter, + "@brief Defines properties for an AssetImportObject object.\n" + "@AssetImportObject is a SimObject derived object intended to act as a stand-in for the to-be imported objects.\n" + "@It contains important info such as dependencies, if it's been processed, any error/status issues and the originating file\n" + "@or if it's been programmatically generated as part of the import process.\n\n" + "@ingroup Assets\n" +); + +IMPLEMENT_CONOBJECT(AssetImporter); + +AssetImporter::AssetImporter() : + importIssues(false), + isReimport(false), + assetHeirarchyChanged(false), + importLogBuffer("") +{ +} + +AssetImporter::~AssetImporter() +{ + +} + +void AssetImporter::initPersistFields() +{ + Parent::initPersistFields(); +} + +// +// Utility Functions +// + +AssetImportObject* AssetImporter::addImportingFile(Torque::Path filePath) +{ + String assetType = getAssetTypeByFile(filePath); + + if (assetType.isEmpty()) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Unable to import file %s because it is of an unrecognized/unsupported type.", filePath.getFullPath().c_str()); + activityLog.push_back(importLogBuffer); + return nullptr; + } + + AssetImportObject* newAssetItem = addImportingAsset(assetType, filePath, nullptr, ""); + + originalImportingFiles.push_back(filePath); + + return newAssetItem; +} + +AssetImportObject* AssetImporter::addImportingAsset(String assetType, Torque::Path filePath, AssetImportObject* parentItem, String assetNameOverride) +{ + String assetName; + + //In some cases(usually generated assets on import, like materials) we'll want to specifically define the asset name instead of peeled from the filePath + if (assetNameOverride.isNotEmpty()) + assetName = assetNameOverride; + else + assetName = filePath.getFileName(); + + AssetImportObject* assetImportObj = new AssetImportObject(); + assetImportObj->registerObject(); + + assetImportObj->assetType = assetType; + assetImportObj->filePath = filePath; + assetImportObj->assetName = assetName; + assetImportObj->cleanAssetName = assetName; + assetImportObj->moduleName = targetModuleId; + assetImportObj->status = ""; + assetImportObj->statusType = ""; + assetImportObj->statusInfo = ""; + + assetImportObj->dirty = false; + assetImportObj->skip = false; + assetImportObj->processed = false; + assetImportObj->generatedAsset = false; + + if (parentItem != nullptr) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Added Child Importing Asset to %s", parentItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + parentItem->childAssetItems.push_back(assetImportObj); + assetImportObj->parentAssetItem = parentItem; + } + else + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Added Importing Asset"); + activityLog.push_back(importLogBuffer); + } + + dSprintf(importLogBuffer, sizeof(importLogBuffer), " Asset Info: Name: %s | Type: %s", assetImportObj->assetName.c_str(), assetImportObj->assetType.c_str()); + activityLog.push_back(importLogBuffer); + + if (!filePath.isEmpty()) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), " File: %s", filePath.getFullPath().c_str()); + activityLog.push_back(importLogBuffer); + } + + return assetImportObj; +} + +void AssetImporter::deleteImportingAsset(AssetImportObject* assetItem) +{ + assetItem->skip = true; + + //log it + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Deleting Importing Asset %s and all it's child items", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); +} + +AssetImportObject* AssetImporter::findImportingAssetByName(String assetName, AssetImportObject* assetItem) +{ + if (assetItem == nullptr) + { + for (U32 i = 0; i < importingAssets.size(); i++) + { + if (importingAssets[i]->cleanAssetName == assetName) + { + return importingAssets[i]; + } + + //If it wasn't a match, try recusing on the children(if any) + AssetImportObject* retItem = findImportingAssetByName(assetName, importingAssets[i]); + if (retItem != nullptr) + return retItem; + } + } + else + { + //this is the child recursing section + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + if (assetItem->childAssetItems[i]->cleanAssetName == assetName) + { + return assetItem->childAssetItems[i]; + } + + //If it wasn't a match, try recusing on the children(if any) + AssetImportObject* retItem = findImportingAssetByName(assetName, assetItem->childAssetItems[i]); + if (retItem != nullptr) + return retItem; + } + } + + return nullptr; +} + +ModuleDefinition* AssetImporter::getModuleFromPath(Torque::Path filePath) +{ + U32 folderCount = StringUnit::getUnitCount(filePath.getPath().c_str(), "/"); + + for (U32 i = 0; i < folderCount; i++) + { + String folderName = StringUnit::getUnit(filePath.getPath().c_str(), i, "/"); + + ModuleDefinition* moduleDef = ModuleDatabase.findModule(folderName.c_str(), 1); + if (moduleDef != nullptr) + return moduleDef; + } + + return nullptr; +} + +String AssetImporter::parseImageSuffixes(String assetName, String* suffixType) +{ + //Here, we loop over our different suffix lists progressively. + //This lets us walk through a list of suffixes in the Import Config, such as DiffuseTypeSuffixes + //And then iterate over the delinated list of items within it to look for a match. + //If we don't find a match, we then increment our list switch index and scan through the next list. + U32 suffixTypeIdx = 0; + while (suffixTypeIdx < 6) + { + String suffixList; + switch (suffixTypeIdx) + { + case 0: + suffixList = activeImportConfig.DiffuseTypeSuffixes; + suffixType->insert(0, "Albedo", 10); + break; + case 1: + suffixList = activeImportConfig.NormalTypeSuffixes; + suffixType->insert(0, "Normal", 10); + break; + case 2: + suffixList = activeImportConfig.RoughnessTypeSuffixes; + suffixType->insert(0, "Roughness", 10); + break; + case 3: + suffixList = activeImportConfig.AOTypeSuffixes; + suffixType->insert(0, "AO", 10); + break; + case 4: + suffixList = activeImportConfig.MetalnessTypeSuffixes; + suffixType->insert(0, "Metalness", 10); + break; + case 5: + suffixList = activeImportConfig.PBRTypeSuffixes; + suffixType->insert(0, "PBRConfig", 10); + break; + default: + suffixList = ""; + } + + suffixTypeIdx++; + + U32 suffixCount = StringUnit::getUnitCount(suffixList, ",;"); + for (U32 i = 0; i < suffixCount; i++) + { + String suffix = StringUnit::getUnit(suffixList, i, ",;"); + String searchSuffix = String("*") + suffix; + if (FindMatch::isMatch(searchSuffix.c_str(), assetName.c_str(), false)) + { + //We have a match, so indicate as such + return suffix; + } + } + } + + return ""; +} + +String AssetImporter::getAssetTypeByFile(Torque::Path filePath) +{ + String fileExt = filePath.getExtension(); + + if (fileExt == String("png") || fileExt == String("jpg") || fileExt == String("jpeg") || fileExt == String("dds")) + return "ImageAsset"; + else if (fileExt == String("dae") || fileExt == String("fbx") || fileExt == String("blend") || fileExt == String("obj") || fileExt == String("dts") || fileExt == String("gltf") || fileExt == String("gltb")) + return "ShapeAsset"; + else if (fileExt == String("dsq")) + return "ShapeAnimationAsset"; + else if (fileExt == String("ogg") || fileExt == String("wav") || fileExt == String("mp3")) + return "SoundAsset"; + else if (fileExt == String("zip")) + return "Zip"; + else if (fileExt.isEmpty()) + return "Folder"; + + return ""; +} + +void AssetImporter::resetImportSession() +{ + importingAssets.clear(); + activityLog.clear(); + + for (U32 i = 0; i < originalImportingFiles.size(); i++) + { + addImportingFile(originalImportingFiles[i]); + } +} + +S32 AssetImporter::getActivityLogLineCount() +{ + return activityLog.size(); +} + +String AssetImporter::getActivityLogLine(U32 line) +{ + if (line >= activityLog.size()) + return ""; + + return activityLog[line]; +} + +void AssetImporter::dumpActivityLog() +{ + for (U32 i = 0; i < activityLog.size(); i++) + { + Con::printf(activityLog[i].c_str()); + } +} + +S32 AssetImporter::getAssetItemCount() +{ + return importingAssets.size(); +} + +AssetImportObject* AssetImporter::getAssetItem(U32 index) +{ + if (index >= importingAssets.size()) + return nullptr; + + return importingAssets[index]; +} + +S32 AssetImporter::getAssetItemChildCount(AssetImportObject* assetItem) +{ + return assetItem->childAssetItems.size(); +} + +AssetImportObject* AssetImporter::getAssetItemChild(AssetImportObject* assetItem, U32 index) +{ + if (index >= assetItem->childAssetItems.size()) + return nullptr; + + return assetItem->childAssetItems[index]; +} +// +// Processing +// +// Helper struct for counting nodes, meshes and polygons down through the scene +// hierarchy +struct SceneStats +{ + S32 numNodes; + S32 numMeshes; + S32 numPolygons; + S32 numMaterials; + S32 numLights; + S32 numClips; + + SceneStats() : numNodes(0), numMeshes(0), numPolygons(0), numMaterials(0), numLights(0), numClips(0) { } +}; + +// Recurse through the adding nodes and geometry to the GuiTreeView control +static void processNode(GuiTreeViewCtrl* tree, domNode* node, S32 parentID, SceneStats& stats) +{ + stats.numNodes++; + S32 nodeID = tree->insertItem(parentID, _GetNameOrId(node), "node", "", 0, 0); + + // Update mesh and poly counts + for (S32 i = 0; i < node->getContents().getCount(); i++) + { + domGeometry* geom = 0; + const char* elemName = ""; + + daeElement* child = node->getContents()[i]; + switch (child->getElementType()) + { + case COLLADA_TYPE::INSTANCE_GEOMETRY: + { + domInstance_geometry* instgeom = daeSafeCast(child); + if (instgeom) + { + geom = daeSafeCast(instgeom->getUrl().getElement()); + elemName = _GetNameOrId(geom); + } + break; + } + + case COLLADA_TYPE::INSTANCE_CONTROLLER: + { + domInstance_controller* instctrl = daeSafeCast(child); + if (instctrl) + { + domController* ctrl = daeSafeCast(instctrl->getUrl().getElement()); + elemName = _GetNameOrId(ctrl); + if (ctrl && ctrl->getSkin()) + geom = daeSafeCast(ctrl->getSkin()->getSource().getElement()); + else if (ctrl && ctrl->getMorph()) + geom = daeSafeCast(ctrl->getMorph()->getSource().getElement()); + } + break; + } + + case COLLADA_TYPE::INSTANCE_LIGHT: + stats.numLights++; + tree->insertItem(nodeID, _GetNameOrId(node), "light", "", 0, 0); + break; + } + + if (geom && geom->getMesh()) + { + const char* name = _GetNameOrId(node); + if (dStrEqual(name, "null") || dStrEndsWith(name, "PIVOT")) + name = _GetNameOrId(daeSafeCast(node->getParent())); + + stats.numMeshes++; + tree->insertItem(nodeID, name, "mesh", "", 0, 0); + + for (S32 j = 0; j < geom->getMesh()->getTriangles_array().getCount(); j++) + stats.numPolygons += geom->getMesh()->getTriangles_array()[j]->getCount(); + for (S32 j = 0; j < geom->getMesh()->getTristrips_array().getCount(); j++) + stats.numPolygons += geom->getMesh()->getTristrips_array()[j]->getCount(); + for (S32 j = 0; j < geom->getMesh()->getTrifans_array().getCount(); j++) + stats.numPolygons += geom->getMesh()->getTrifans_array()[j]->getCount(); + for (S32 j = 0; j < geom->getMesh()->getPolygons_array().getCount(); j++) + stats.numPolygons += geom->getMesh()->getPolygons_array()[j]->getCount(); + for (S32 j = 0; j < geom->getMesh()->getPolylist_array().getCount(); j++) + stats.numPolygons += geom->getMesh()->getPolylist_array()[j]->getCount(); + } + } + + // Recurse into child nodes + for (S32 i = 0; i < node->getNode_array().getCount(); i++) + processNode(tree, node->getNode_array()[i], nodeID, stats); + + for (S32 i = 0; i < node->getInstance_node_array().getCount(); i++) + { + domInstance_node* instnode = node->getInstance_node_array()[i]; + domNode* dNode = daeSafeCast(instnode->getUrl().getElement()); + if (dNode) + processNode(tree, dNode, nodeID, stats); + } +} + +static bool enumColladaForImport(const char* shapePath, GuiTreeViewCtrl* tree, bool loadCachedDts) +{ + // Check if a cached DTS is available => no need to import the collada file + // if we can load the DTS instead + Torque::Path path(shapePath); + if (loadCachedDts && ColladaShapeLoader::canLoadCachedDTS(path)) + return false; + + // Check if this is a Sketchup file (.kmz) and if so, mount the zip filesystem + // and get the path to the DAE file. + String mountPoint; + Torque::Path daePath; + bool isSketchup = ColladaShapeLoader::checkAndMountSketchup(path, mountPoint, daePath); + + // Load the Collada file into memory + domCOLLADA* root = ColladaShapeLoader::getDomCOLLADA(daePath); + if (!root) + { + TSShapeLoader::updateProgress(TSShapeLoader::Load_Complete, "Load complete"); + return false; + } + + if (isSketchup) + { + // Unmount the zip if we mounted it + Torque::FS::Unmount(mountPoint); + } + + // Initialize tree + tree->removeItem(0); + S32 nodesID = tree->insertItem(0, "Shape", "", "", 0, 0); + S32 matsID = tree->insertItem(0, "Materials", "", "", 0, 0); + S32 animsID = tree->insertItem(0, "Animations", "", "", 0, 0); + + SceneStats stats; + + // Query DOM for shape summary details + for (S32 i = 0; i < root->getLibrary_visual_scenes_array().getCount(); i++) + { + const domLibrary_visual_scenes* libScenes = root->getLibrary_visual_scenes_array()[i]; + for (S32 j = 0; j < libScenes->getVisual_scene_array().getCount(); j++) + { + const domVisual_scene* visualScene = libScenes->getVisual_scene_array()[j]; + for (S32 k = 0; k < visualScene->getNode_array().getCount(); k++) + processNode(tree, visualScene->getNode_array()[k], nodesID, stats); + } + } + + // Get material count + for (S32 i = 0; i < root->getLibrary_materials_array().getCount(); i++) + { + const domLibrary_materials* libraryMats = root->getLibrary_materials_array()[i]; + stats.numMaterials += libraryMats->getMaterial_array().getCount(); + for (S32 j = 0; j < libraryMats->getMaterial_array().getCount(); j++) + { + domMaterial* mat = libraryMats->getMaterial_array()[j]; + tree->insertItem(matsID, _GetNameOrId(mat), "", "", 0, 0); + } + } + + // Get images count + for (S32 i = 0; i < root->getLibrary_images_array().getCount(); i++) + { + const domLibrary_images* libraryImages = root->getLibrary_images_array()[i]; + + for (S32 j = 0; j < libraryImages->getImage_array().getCount(); j++) + { + domImage* img = libraryImages->getImage_array()[j]; + + S32 materialID = tree->findItemByName(_GetNameOrId(img)); + + if (materialID == 0) + continue; + + tree->setItemValue(materialID, img->getInit_from()->getValue().str().c_str()); + } + } + + // Get animation count + for (S32 i = 0; i < root->getLibrary_animation_clips_array().getCount(); i++) + { + const domLibrary_animation_clips* libraryClips = root->getLibrary_animation_clips_array()[i]; + stats.numClips += libraryClips->getAnimation_clip_array().getCount(); + for (S32 j = 0; j < libraryClips->getAnimation_clip_array().getCount(); j++) + { + domAnimation_clip* clip = libraryClips->getAnimation_clip_array()[j]; + tree->insertItem(animsID, _GetNameOrId(clip), "animation", "", 0, 0); + } + } + if (stats.numClips == 0) + { + // No clips => check if there are any animations (these will be added to a default clip) + for (S32 i = 0; i < root->getLibrary_animations_array().getCount(); i++) + { + const domLibrary_animations* libraryAnims = root->getLibrary_animations_array()[i]; + if (libraryAnims->getAnimation_array().getCount()) + { + stats.numClips = 1; + tree->insertItem(animsID, "ambient", "animation", "", 0, 0); + break; + } + } + } + + // Extract the global scale and up_axis from the top level element, + F32 unit = 1.0f; + domUpAxisType upAxis = UPAXISTYPE_Z_UP; + if (root->getAsset()) { + if (root->getAsset()->getUnit()) + unit = root->getAsset()->getUnit()->getMeter(); + if (root->getAsset()->getUp_axis()) + upAxis = root->getAsset()->getUp_axis()->getValue(); + } + + TSShapeLoader::updateProgress(TSShapeLoader::Load_Complete, "Load complete"); + + // Store shape information in the tree control + tree->setDataField(StringTable->insert("_nodeCount"), 0, avar("%d", stats.numNodes)); + tree->setDataField(StringTable->insert("_meshCount"), 0, avar("%d", stats.numMeshes)); + tree->setDataField(StringTable->insert("_polygonCount"), 0, avar("%d", stats.numPolygons)); + tree->setDataField(StringTable->insert("_materialCount"), 0, avar("%d", stats.numMaterials)); + tree->setDataField(StringTable->insert("_lightCount"), 0, avar("%d", stats.numLights)); + tree->setDataField(StringTable->insert("_animCount"), 0, avar("%d", stats.numClips)); + tree->setDataField(StringTable->insert("_unit"), 0, avar("%g", unit)); + + if (upAxis == UPAXISTYPE_X_UP) + tree->setDataField(StringTable->insert("_upAxis"), 0, "X_AXIS"); + else if (upAxis == UPAXISTYPE_Y_UP) + tree->setDataField(StringTable->insert("_upAxis"), 0, "Y_AXIS"); + else + tree->setDataField(StringTable->insert("_upAxis"), 0, "Z_AXIS"); + + char shapesStr[16]; + dSprintf(shapesStr, 16, "%i", stats.numMeshes); + char materialsStr[16]; + dSprintf(materialsStr, 16, "%i", stats.numMaterials); + char animationsStr[16]; + dSprintf(animationsStr, 16, "%i", stats.numClips); + + tree->setItemValue(nodesID, StringTable->insert(shapesStr)); + tree->setItemValue(matsID, StringTable->insert(materialsStr)); + tree->setItemValue(animsID, StringTable->insert(animationsStr)); + + return true; +} + +void AssetImporter::processImportAssets(AssetImportObject* assetItem) +{ + if (assetItem == nullptr) + { + assetHeirarchyChanged = false; + + for (U32 i = 0; i < importingAssets.size(); i++) + { + AssetImportObject* item = importingAssets[i]; + if (item->skip) + continue; + + if (!item->processed) + { + //Sanitize before modifying our asset name(suffix additions, etc) + if (item->assetName != item->cleanAssetName) + item->assetName = item->cleanAssetName; + + //handle special pre-processing here for any types that need it + + //process the asset items + if (item->assetType == String("ImageAsset")) + processImageAsset(item); + else if (item->assetType == String("ShapeAsset")) + processShapeAsset(item); + /*else if (item->assetType == String("SoundAsset")) + SoundAsset::prepareAssetForImport(this, item);*/ + else if (item->assetType == String("MaterialAsset")) + processMaterialAsset(item); + /*else if (item->assetType == String("ShapeAnimationAsset")) + ShapeAnimationAsset::prepareAssetForImport(this, item);*/ + + item->processed = true; + } + + //try recusing on the children(if any) + processImportAssets(item); + } + } + else + { + //this is the child recursing section + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + AssetImportObject* childItem = assetItem->childAssetItems[i]; + + if (childItem->skip) + continue; + + if (!childItem->processed) + { + //Sanitize before modifying our asset name(suffix additions, etc) + if (childItem->assetName != childItem->cleanAssetName) + childItem->assetName = childItem->cleanAssetName; + + //handle special pre-processing here for any types that need it + + //process the asset items + if (childItem->assetType == String("ImageAsset")) + processImageAsset(childItem); + else if (childItem->assetType == String("ShapeAsset")) + processShapeAsset(childItem); + /*else if (childItem->assetType == String("SoundAsset")) + SoundAsset::prepareAssetForImport(this, childItem);*/ + else if (childItem->assetType == String("MaterialAsset")) + processMaterialAsset(childItem); + /*else if (childItem->assetType == String("ShapeAnimationAsset")) + ShapeAnimationAsset::prepareAssetForImport(this, childItem);*/ + + childItem->processed = true; + } + + //try recusing on the children(if any) + processImportAssets(childItem); + } + } + + //If our hierarchy changed, it's because we did so during processing + //so we'll loop back through again until everything has been processed + if (assetHeirarchyChanged) + processImportAssets(); +} + +void AssetImporter::processImageAsset(AssetImportObject* assetItem) +{ + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Preparing Image for Import: %s", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + if ((activeImportConfig.GenerateMaterialOnImport && assetItem->parentAssetItem == nullptr) || assetItem->parentAssetItem != nullptr) + { + //find our suffix match, if any + String noSuffixName = assetItem->assetName; + String suffixType; + String suffix = parseImageSuffixes(assetItem->assetName, &suffixType); + if (suffix.isNotEmpty()) + { + assetItem->imageSuffixType = suffixType; + S32 suffixPos =assetItem->assetName.find(suffix, 0, String::NoCase|String::Left); + noSuffixName = assetItem->assetName.substr(0, suffixPos); + } + + //We try to automatically populate materials under the naming convention: materialName: Rock, image maps: Rock_Albedo, Rock_Normal, etc + + AssetImportObject* materialAsset = findImportingAssetByName(noSuffixName); + if (materialAsset != nullptr && materialAsset->assetType != String("MaterialAsset")) + { + //We may have a situation where an asset matches the no-suffix name, but it's not a material asset. Ignore this + //asset item for now + materialAsset = nullptr; + } + + //If we didn't find a matching material asset in our current items, we'll make one now + if (materialAsset == nullptr) + { + if (!assetItem->filePath.isEmpty()) + { + materialAsset = addImportingAsset("MaterialAsset", "", nullptr, noSuffixName); + //Add the material into the primary list of importing assets + importingAssets.push_back(materialAsset); + } + } + + //Not that, one way or another, we have the generated material asset, lets move on to associating our image with it + if (materialAsset != nullptr && materialAsset != assetItem->parentAssetItem) + { + if (assetItem->parentAssetItem != nullptr) + { + //If the image had an existing parent, it gets removed from that parent's child item list + assetItem->parentAssetItem->childAssetItems.remove(assetItem); + } + else + { + //If it didn't have one, we're going to pull it from the importingAssets list + importingAssets.remove(assetItem); + } + + //Now we can add it to the correct material asset + materialAsset->childAssetItems.push_back(assetItem); + assetItem->parentAssetItem = materialAsset; + + assetHeirarchyChanged = true; + } + + //Now to do some cleverness. If we're generating a material, we can parse like assets being imported(similar filenames) but different suffixes + //If we find these, we'll just populate into the original's material + + //if we need to append the diffuse suffix and indeed didn't find a suffix on the name, do that here + if (suffixType.isEmpty()) + { + if (activeImportConfig.UseDiffuseSuffixOnOriginImage) + { + String diffuseToken = StringUnit::getUnit(activeImportConfig.DiffuseTypeSuffixes, 0, ",;"); + assetItem->assetName = assetItem->assetName + diffuseToken; + } + else + { + //We need to ensure that our image asset doesn't match the same name as the material asset, so if we're not trying to force the diffuse suffix + //we'll give it a generic one + if (materialAsset->assetName.compare(assetItem->assetName) == 0) + { + assetItem->assetName = assetItem->assetName + "_image"; + } + } + + suffixType = "Albedo"; + } + + if (suffixType.isNotEmpty()) + { + assetItem->imageSuffixType = suffixType; + + //otherwise, if we have some sort of suffix, we'll want to figure out if we've already got an existing material, and should append to it + if (activeImportConfig.PopulateMaterialMaps) + { + + } + } + } + + assetItem->processed = true; +} + +void AssetImporter::processMaterialAsset(AssetImportObject* assetItem) +{ + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Preparing Material for Import: %s", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + String filePath = assetItem->filePath.getFullPath(); + String fileName = assetItem->filePath.getFileName(); + String fileExt = assetItem->filePath.getExtension(); + const char* assetName = assetItem->assetName.c_str(); + + assetItem->generatedAsset = true; + + if (activeImportConfig.IgnoreMaterials.isNotEmpty()) + { + U32 ignoredMatNameCount = StringUnit::getUnitCount(activeImportConfig.IgnoreMaterials, ".;"); + for (U32 i = 0; i < ignoredMatNameCount; i++) + { + String ignoredName = StringUnit::getUnit(activeImportConfig.IgnoreMaterials, i, ".;"); + if (FindMatch::isMatch(ignoredName.c_str(), assetName, false)) + { + assetItem->skip = true; + + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Material %s has been ignored due to it's name being listed in the IgnoreMaterials list in the Import Config.", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + return; + } + } + } + + if (activeImportConfig.PopulateMaterialMaps) + { + //If we're trying to populate the rest of our material maps, we need to go looking + } + + assetItem->processed = true; +} + +void AssetImporter::processShapeAsset(AssetImportObject* assetItem) +{ + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Preparing Shape for Import: %s", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + String filePath = assetItem->filePath.getFullPath(); + String fileName = assetItem->filePath.getFileName(); + String fileExt = assetItem->filePath.getExtension(); + const char* assetName = assetItem->assetName.c_str(); + + if (assetItem->shapeInfo == nullptr) + { + GuiTreeViewCtrl* shapeInfo = new GuiTreeViewCtrl(); + shapeInfo->registerObject(); + + if (fileExt.compare("dae") == 0) + { + enumColladaForImport(filePath, shapeInfo, false); + } + else + { + // Check if a cached DTS is available => no need to import the source file + // if we can load the DTS instead + + AssimpShapeLoader loader; + loader.fillGuiTreeView(filePath.c_str(), shapeInfo); + } + + assetItem->shapeInfo = shapeInfo; + } + + S32 meshCount = dAtoi(assetItem->shapeInfo->getDataField(StringTable->insert("_meshCount"), nullptr)); + S32 shapeItem = assetItem->shapeInfo->findItemByName("Meshes"); + + S32 animCount = dAtoi(assetItem->shapeInfo->getDataField(StringTable->insert("_animCount"), nullptr)); + S32 animItem = assetItem->shapeInfo->findItemByName("Animations"); + + S32 materialCount = dAtoi(assetItem->shapeInfo->getDataField(StringTable->insert("_materialCount"), nullptr)); + S32 matItem = assetItem->shapeInfo->findItemByName("Materials"); + + dSprintf(importLogBuffer, sizeof(importLogBuffer), " Shape Info: Mesh Count: %i | Material Count: %i | Anim Count: %i", meshCount, animCount, materialCount); + activityLog.push_back(importLogBuffer); + + if (activeImportConfig.ImportMesh && meshCount > 0) + { + + } + + if (activeImportConfig.ImportAnimations && animCount > 0) + { + //If we have animations but no meshes, then this is a pure animation file so we can swap the asset type here + if (meshCount == 0) + { + //assetItem->assetType = "ShapeAnimation"; + } + } + + if (activeImportConfig.ImportMaterials && materialCount > 0) + { + S32 materialId = assetItem->shapeInfo->getChildItem(matItem); + processShapeMaterialInfo(assetItem, materialId); + + materialId = assetItem->shapeInfo->getNextSiblingItem(materialId); + while (materialId != 0) + { + processShapeMaterialInfo(assetItem, materialId); + materialId = assetItem->shapeInfo->getNextSiblingItem(materialId); + } + } + + assetItem->processed = true; +} + +void AssetImporter::processShapeMaterialInfo(AssetImportObject* assetItem, S32 materialItemId) +{ + String matName = assetItem->shapeInfo->getItemText(materialItemId); + + Torque::Path filePath = assetItem->shapeInfo->getItemValue(materialItemId); + if (filePath.getFullFileName().isNotEmpty()) + { + if (!Platform::isFile(filePath.getFullFileName())) + { + //could be a stale path reference, such as if it was downloaded elsewhere. Trim to just the filename and see + //if we can find it there + String shapePathBase = assetItem->filePath.getPath(); + + String matFilePath = filePath.getFileName() + "." + filePath.getExtension(); + //trim (not found) if needbe + /* + %suffixPos = strpos(strlwr(%filename), " (not found)", 0); + %filename = getSubStr(%filename, 0, %suffixPos); + */ + + String testFileName = shapePathBase + "/" + matFilePath; + if (Platform::isFile(testFileName)) + { + filePath = testFileName; + } + } + + AssetImportObject* matAssetItem = addImportingAsset("MaterialAsset", "", assetItem, matName); + addImportingAsset("ImageAsset", filePath, matAssetItem, ""); + } + else + { + /* + //check to see if it's actually just a flat color + if(getWordCount(%filePath) == 4 && getWord(%filePath, 0) $= "Color:") + { + AssetBrowser.addImportingAsset("MaterialAsset", %matName, %assetItem); + } + else + { + //we need to try and find our material, since the shapeInfo wasn't able to find it automatically + %filePath = findImageFile(filePath(%assetItem.filePath), %matName); + if(%filePath !$= "" && isFile(%filePath)) + AssetBrowser.addImportingAsset("MaterialAsset", %filePath, %assetItem); + else + AssetBrowser.addImportingAsset("MaterialAsset", filePath(%assetItem.filePath) @ "/" @ %matName, %assetItem); + } + */ + } +} + +// +// Validation +// + +bool AssetImporter::validateAssets() +{ + importIssues = false; + + resetAssetValidationStatus(); + + for (U32 i = 0; i < importingAssets.size(); i++) + { + validateAsset(importingAssets[i]); + resolveAssetItemIssues(importingAssets[i]); + } + + return importIssues; +} + +void AssetImporter::validateAsset(AssetImportObject* assetItem) +{ + if (assetItem->skip) + return; + + bool hasCollision = checkAssetForCollision(assetItem); + + if (hasCollision) + { + importIssues = true; + return; + } + + if (!isReimport) + { + AssetQuery aQuery; + U32 numAssetsFound = AssetDatabase.findAllAssets(&aQuery); + + bool hasCollision = false; + for (U32 i = 0; i < numAssetsFound; i++) + { + StringTableEntry assetId = aQuery.mAssetList[i]; + + ModuleDefinition* moduleDef = AssetDatabase.getAssetModuleDefinition(assetId); + + if (moduleDef->getModuleId() != StringTable->insert(targetModuleId.c_str())) + continue; + + StringTableEntry assetName = AssetDatabase.getAssetName(assetId); + + if (assetName == StringTable->insert(assetItem->assetName.c_str())) + { + hasCollision = true; + assetItem->status = "Error"; + assetItem->statusType = "DuplicateAsset"; + assetItem->statusInfo = "Duplicate asset names found within the target module!\nAsset \"" + assetItem->assetName + "\" of type \"" + assetItem->assetType + "\" has a matching name.\nPlease rename it and try again!"; + + //log it + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Asset %s has an identically named asset in the target module.", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + break; + } + } + } + + if (!assetItem->filePath.isEmpty() && !assetItem->generatedAsset && !Platform::isFile(assetItem->filePath.getFullPath().c_str())) + { + assetItem->status = "Error"; + assetItem->statusType = "MissingFile"; + assetItem->statusInfo = "Unable to find file to be imported with provided path: " + assetItem->filePath + "\n Please select a valid file."; + + //log it + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Asset %s's file at %s was not found.", assetItem->assetName.c_str(), assetItem->filePath.getFullPath().c_str()); + activityLog.push_back(importLogBuffer); + } + + if (assetItem->status == String("Warning")) + { + if (activeImportConfig.WarningsAsErrors) + { + assetItem->status = "Error"; + + //log it + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Import configuration has treated an import warning as an error.", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + } + } + + if (assetItem->status == String("Error")) + importIssues = true; + + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + validateAsset(assetItem->childAssetItems[i]); + resolveAssetItemIssues(assetItem->childAssetItems[i]); + } + + return; +} + +void AssetImporter::resetAssetValidationStatus(AssetImportObject* assetItem) +{ + if (assetItem == nullptr) + { + for (U32 i = 0; i < importingAssets.size(); i++) + { + if (importingAssets[i]->skip) + continue; + + importingAssets[i]->status = ""; + importingAssets[i]->statusType = ""; + importingAssets[i]->statusInfo = ""; + + //If it wasn't a match, try recusing on the children(if any) + resetAssetValidationStatus(importingAssets[i]); + } + } + else + { + //this is the child recursing section + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + if (assetItem->childAssetItems[i]->skip) + continue; + + assetItem->childAssetItems[i]->status = ""; + assetItem->childAssetItems[i]->statusType = ""; + assetItem->childAssetItems[i]->statusInfo = ""; + + //If it wasn't a match, try recusing on the children(if any) + resetAssetValidationStatus(assetItem->childAssetItems[i]); + } + } +} + +bool AssetImporter::checkAssetForCollision(AssetImportObject* assetItemToCheck, AssetImportObject* assetItem) +{ + bool results = false; + + if (assetItem == nullptr) + { + for (U32 i = 0; i < importingAssets.size(); i++) + { + if (importingAssets[i]->skip) + continue; + + if ((assetItemToCheck->assetName.compare(importingAssets[i]->assetName) == 0) && (assetItemToCheck->getId() != importingAssets[i]->getId())) + { + //we do have a collision, note the collsion and bail out + assetItemToCheck->status = "Warning"; + assetItemToCheck->statusType = "DuplicateImportAsset"; + assetItemToCheck->statusInfo = "Duplicate asset names found with importing assets!\nAsset \"" + importingAssets[i]->assetName + "\" of the type \"" + importingAssets[i]->assetType + "\" and \"" + + assetItemToCheck->assetName + "\" of the type \"" + assetItemToCheck->assetType + "\" have matching names.\nPlease rename one of them."; + + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Warning! Asset %s, type %s has a naming collision with another importing asset: %s, type %s", + assetItemToCheck->assetName.c_str(), assetItemToCheck->assetType.c_str(), + importingAssets[i]->assetName.c_str(), importingAssets[i]->assetType.c_str()); + activityLog.push_back(importLogBuffer); + + return true; + } + + //If it wasn't a match, try recusing on the children(if any) + results = checkAssetForCollision(assetItemToCheck, importingAssets[i]); + if (results) + return results; + } + } + else + { + //this is the child recursing section + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + if (assetItem->childAssetItems[i]->skip) + continue; + + if ((assetItemToCheck->assetName.compare(assetItem->childAssetItems[i]->assetName) == 0) && (assetItemToCheck->getId() != assetItem->childAssetItems[i]->getId())) + { + //we do have a collision, note the collsion and bail out + assetItemToCheck->status = "Warning"; + assetItemToCheck->statusType = "DuplicateImportAsset"; + assetItemToCheck->statusInfo = "Duplicate asset names found with importing assets!\nAsset \"" + assetItem->assetName + "\" of the type \"" + assetItem->assetType + "\" and \"" + + assetItemToCheck->assetName + "\" of the type \"" + assetItemToCheck->assetType + "\" have matching names.\nPlease rename one of them."; + + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Warning! Asset %s, type %s has a naming collision with another importing asset: %s, type %s", + assetItemToCheck->assetName.c_str(), assetItemToCheck->assetType.c_str(), + importingAssets[i]->assetName.c_str(), importingAssets[i]->assetType.c_str()); + activityLog.push_back(importLogBuffer); + + return true; + } + + //If it wasn't a match, try recusing on the children(if any) + results = checkAssetForCollision(assetItemToCheck, assetItem->childAssetItems[i]); + if (results) + return results; + } + } + + return results; +} + +void AssetImporter::resolveAssetItemIssues(AssetImportObject* assetItem) +{ + if (assetItem->statusType == String("DuplicateImportAsset") || assetItem->statusType == String("DuplicateAsset")) + { + String humanReadableReason = assetItem->statusType == String("DuplicateImportAsset") ? "Importing asset was duplicate of another importing asset" : "Importing asset was duplicate of an existing asset"; + + //get the config value for duplicateAutoResolution + if (activeImportConfig.DuplicatAutoResolution == String("AutoPrune")) + { + //delete the item + deleteImportingAsset(assetItem); + + //log it's deletion + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Asset %s was autoprined due to %s as part of the Import Configuration", assetItem->assetName.c_str(), humanReadableReason.c_str()); + activityLog.push_back(importLogBuffer); + + importIssues = false; + } + else if (activeImportConfig.DuplicatAutoResolution == String("AutoRename")) + { + //Set trailing number + String renamedAssetName = assetItem->assetName; + renamedAssetName = Sim::getUniqueName(renamedAssetName.c_str()); + + //Log it's renaming + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Asset %s was renamed due to %s as part of the Import Configuration", assetItem->assetName.c_str(), humanReadableReason.c_str()); + activityLog.push_back(importLogBuffer); + + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Asset %s was renamed to %s", assetItem->assetName.c_str(), renamedAssetName.c_str()); + activityLog.push_back(importLogBuffer); + + assetItem->assetName = renamedAssetName; + + //Whatever status we had prior is no longer relevent, so reset the status + resetAssetValidationStatus(assetItem); + importIssues = false; + } + } + else if (assetItem->statusType == String("MissingFile")) + { + //Trigger callback to look? + } +} + +// +// Importing +// +StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath) +{ + String assetType = getAssetTypeByFile(filePath); + + if (assetType == String("Folder") || assetType == String("Zip")) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Unable to import file %s because it is a folder or zip.", filePath.getFullPath().c_str()); + activityLog.push_back(importLogBuffer); + return StringTable->EmptyString(); + } + + if (assetType.isEmpty()) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Unable to import file %s because it is of an unrecognized/unsupported type.", filePath.getFullPath().c_str()); + activityLog.push_back(importLogBuffer); + return StringTable->EmptyString(); + } + + //Find out if the filepath has an associated module to it. If we're importing in-place, it needs to be within a module's directory + ModuleDefinition* targetModuleDef = getModuleFromPath(filePath); + + if (targetModuleDef == nullptr) + { + //log it + return StringTable->EmptyString(); + } + else + { + targetModuleId = targetModuleDef->getModuleId(); + } + + //set our path + targetPath = filePath.getPath(); + + //use a default import config + activeImportConfig = AssetImportConfig(); + + AssetImportObject* assetItem = addImportingAsset(assetType, filePath, nullptr, ""); + + importingAssets.push_back(assetItem); + + processImportAssets(); + + bool hasIssues = validateAssets(); + + if (hasIssues) + { + //log it + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Import process has failed due to issues discovered during validation!"); + activityLog.push_back(importLogBuffer); + } + else + { + importAssets(); + } + +#if TORQUE_DEBUG + for (U32 i = 0; i < activityLog.size(); i++) + { + Con::printf(activityLog[i].c_str()); + } +#endif + + if (hasIssues) + { + return StringTable->EmptyString(); + } + else + { + String assetId = targetModuleId + ":" + assetItem->assetName; + return StringTable->insert(assetId.c_str()); + } +} + +void AssetImporter::importAssets(AssetImportObject* assetItem) +{ + ModuleDefinition* moduleDef = ModuleDatabase.findModule(targetModuleId.c_str(), 1); + + if (moduleDef == nullptr) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Unable to find moduleId %s", targetModuleId.c_str()); + activityLog.push_back(importLogBuffer); + return; + } + + if (assetItem == nullptr) + { + for (U32 i = 0; i < importingAssets.size(); i++) + { + if (importingAssets[i]->skip) + continue; + + Torque::Path assetPath; + if (importingAssets[i]->assetType == String("ImageAsset")) + assetPath = importImageAsset(importingAssets[i]); + else if (importingAssets[i]->assetType == String("ShapeAsset")) + assetPath = importShapeAsset(importingAssets[i]); + /*else if (importingAssets[i]->assetType == String("SoundAsset")) + assetPath = SoundAsset::importAsset(importingAssets[i]);*/ + else if (importingAssets[i]->assetType == String("MaterialAsset")) + assetPath = importMaterialAsset(importingAssets[i]); + /*else if (importingAssets[i]->assetType == String("ShapeAnimationAsset")) + assetPath = ShapeAnimationAsset::importAsset(importingAssets[i]);*/ + + if (assetPath.isEmpty()) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Import attempt of %s failed, so skipping asset.", importingAssets[i]->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + continue; + } + + //If we got a valid filepath back from the import action, then we know we're good to go and we can go ahead and register the asset! + if (!isReimport) + { + bool registerSuccess = AssetDatabase.addDeclaredAsset(moduleDef, assetPath.getFullPath().c_str()); + + if (!registerSuccess) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Failed to successfully register new asset at path %s to moduleId %s", assetPath.getFullPath().c_str(), targetModuleId.c_str()); + activityLog.push_back(importLogBuffer); + } + } + else + { + String assetId = importingAssets[i]->moduleName + ":" + importingAssets[i]->assetName; + bool refreshSuccess = AssetDatabase.refreshAsset(assetId.c_str()); + + if (!refreshSuccess) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Failed to refresh reimporting asset %s.", importingAssets[i]->assetName.c_str()); + activityLog.push_back(importLogBuffer); + } + } + + //recurse if needed + importAssets(importingAssets[i]); + } + } + else + { + //this is the child recursing section + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + AssetImportObject* childItem = assetItem->childAssetItems[i]; + + if (childItem->skip) + continue; + + Torque::Path assetPath; + if (childItem->assetType == String("ImageAsset")) + assetPath = importImageAsset(childItem); + else if (childItem->assetType == String("ShapeAsset")) + assetPath = importShapeAsset(childItem); + /*else if (childItem->assetType == String("SoundAsset")) + assetPath = SoundAsset::importAsset(childItem);*/ + else if (childItem->assetType == String("MaterialAsset")) + assetPath = importMaterialAsset(childItem); + /*else if (childItem->assetType == String("ShapeAnimationAsset")) + assetPath = ShapeAnimationAsset::importAsset(childItem);*/ + + if (assetPath.isEmpty()) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Import attempt of %s failed, so skipping asset.", childItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + continue; + } + + //If we got a valid filepath back from the import action, then we know we're good to go and we can go ahead and register the asset! + if (!isReimport) + { + bool registerSuccess = AssetDatabase.addDeclaredAsset(moduleDef, assetPath.getFullPath().c_str()); + + if (!registerSuccess) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Failed to successfully register new asset at path %s to moduleId %s", assetPath.getFullPath().c_str(), targetModuleId.c_str()); + activityLog.push_back(importLogBuffer); + } + } + else + { + String assetId = childItem->moduleName + ":" + childItem->assetName; + bool refreshSuccess = AssetDatabase.refreshAsset(assetId.c_str()); + + if (!refreshSuccess) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "AssetImporter::importAssets - Failed to refresh reimporting asset %s.", childItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + } + } + + //recurse if needed + importAssets(childItem); + } + } +} + +// +// Type-specific import logic +// + +Torque::Path AssetImporter::importImageAsset(AssetImportObject* assetItem) +{ + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning importing of Image Asset: %s", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + ImageAsset* newAsset = new ImageAsset(); + newAsset->registerObject(); + + StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str()); + + String imageFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension(); + String assetPath = targetPath + "/" + imageFileName; + String tamlPath = targetPath + "/" + assetName + ".asset.taml"; + String originalPath = assetItem->filePath.getFullPath().c_str(); + + char qualifiedFromFile[2048]; + char qualifiedToFile[2048]; + + Platform::makeFullPathName(originalPath.c_str(), qualifiedFromFile, sizeof(qualifiedFromFile)); + Platform::makeFullPathName(assetPath.c_str(), qualifiedToFile, sizeof(qualifiedToFile)); + + newAsset->setAssetName(assetName); + newAsset->setImageFileName(imageFileName.c_str()); + newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile); + + ImageAsset::ImageTypes imageType = ImageAsset::getImageTypeFromName(assetItem->imageSuffixType.c_str()); + newAsset->setImageType(imageType); + + Taml tamlWriter; + bool importSuccessful = tamlWriter.write(newAsset, tamlPath.c_str()); + + if (!importSuccessful) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to write asset taml file %s", tamlPath.c_str()); + activityLog.push_back(importLogBuffer); + return ""; + } + + if (!isReimport) + { + bool isInPlace = !dStrcmp(qualifiedFromFile, qualifiedToFile); + + if (!isInPlace && !dPathCopy(qualifiedFromFile, qualifiedToFile, !isReimport)) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", assetItem->filePath.getFullPath().c_str()); + activityLog.push_back(importLogBuffer); + return ""; + } + } + + return tamlPath; +} + +Torque::Path AssetImporter::importMaterialAsset(AssetImportObject* assetItem) +{ + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning importing of Material Asset: %s", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + MaterialAsset* newAsset = new MaterialAsset(); + newAsset->registerObject(); + + StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str()); + + String tamlPath = targetPath + "/" + assetName + ".asset.taml"; + String scriptName = assetItem->assetName + ".cs"; + String scriptPath = targetPath + "/" + scriptName; + String originalPath = assetItem->filePath.getFullPath().c_str(); + + char qualifiedFromFile[2048]; + + Platform::makeFullPathName(originalPath.c_str(), qualifiedFromFile, sizeof(qualifiedFromFile)); + + newAsset->setAssetName(assetName); + newAsset->setScriptFile(scriptName.c_str()); + newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile); + + //iterate through and write out the material maps dependencies + S32 dependencySlotId = 0; + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + AssetImportObject* childItem = assetItem->childAssetItems[i]; + + if (childItem->skip || !childItem->processed || childItem->assetType.compare("ImageAsset") != 0) + continue; + + char dependencyFieldName[64]; + dSprintf(dependencyFieldName, 64, "imageMap%i", dependencySlotId); + + char dependencyFieldDef[512]; + dSprintf(dependencyFieldDef, 512, "@Asset=%s:%s", targetModuleId.c_str(), childItem->assetName.c_str()); + + newAsset->setDataField(StringTable->insert(dependencyFieldName), nullptr, dependencyFieldDef); + + dependencySlotId++; + } + + Taml tamlWriter; + bool importSuccessful = tamlWriter.write(newAsset, tamlPath.c_str()); + + if (!importSuccessful) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to write asset taml file %s", tamlPath.c_str()); + activityLog.push_back(importLogBuffer); + return ""; + } + + //build the PBRConfig file if we're flagged to and have valid image maps + if (activeImportConfig.CreatePBRConfig) + { + AssetImportObject* pbrConfigMap = nullptr; + AssetImportObject* roughnessMap = nullptr; + AssetImportObject* metalnessMap = nullptr; + AssetImportObject* aoMap = nullptr; + + //We need to find any/all respective image maps for the given channels + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + AssetImportObject* childItem = assetItem->childAssetItems[i]; + + if (childItem->skip || childItem->assetType.compare("ImageAsset") != 0) + continue; + + if (childItem->imageSuffixType.compare("PBRConfig") == 0) + pbrConfigMap = childItem; + else if(childItem->imageSuffixType.compare("Roughness") == 0) + roughnessMap = childItem; + else if (childItem->imageSuffixType.compare("Metalness") == 0) + metalnessMap = childItem; + else if (childItem->imageSuffixType.compare("AO") == 0) + aoMap = childItem; + } + + if (pbrConfigMap != nullptr && pbrConfigMap->generatedAsset) + { + if (roughnessMap != nullptr || metalnessMap != nullptr || aoMap != nullptr) + { + U32 channelKey[4] = { 0,1,2,3 }; + + GFX->getTextureManager()->saveCompositeTexture(aoMap->filePath.getFullPath(), roughnessMap->filePath.getFullPath(), metalnessMap->filePath.getFullPath(), "", + channelKey, pbrConfigMap->filePath.getFullPath(), &GFXTexturePersistentProfile); + } + } + } + + FileObject* file = new FileObject(); + file->registerObject(); + + //Now write the script file containing our material out + if (file->openForWrite(scriptPath.c_str())) + { + file->writeLine((U8*)"//--- OBJECT WRITE BEGIN ---"); + + char lineBuffer[1024]; + dSprintf(lineBuffer, 1024, "singleton Material(%s) {", assetName); + file->writeLine((U8*)lineBuffer); + + dSprintf(lineBuffer, 1024, " mapTo=\"%s\";", assetName); + file->writeLine((U8*)lineBuffer); + + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + AssetImportObject* childItem = assetItem->childAssetItems[i]; + + if (childItem->skip || !childItem->processed || childItem->assetType.compare("ImageAsset") != 0) + continue; + + String mapFieldName = ""; + + if (childItem->imageSuffixType.compare("Albedo") == 0) + { + mapFieldName = "DiffuseMap"; + } + + String path = childItem->filePath.getFullFileName(); + dSprintf(lineBuffer, 1024, " %s[0] = \"%s\";", mapFieldName.c_str(), path.c_str()); + file->writeLine((U8*)lineBuffer); + + dSprintf(lineBuffer, 1024, " %sAsset[0] = \"%s:%s\";", mapFieldName.c_str(), targetModuleId.c_str(), childItem->assetName.c_str()); + file->writeLine((U8*)lineBuffer); + } + + file->writeLine((U8*)"};"); + file->writeLine((U8*)"//--- OBJECT WRITE END ---"); + + file->close(); + } + else + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to write asset script file %s", scriptPath.c_str()); + activityLog.push_back(importLogBuffer); + return ""; + } + + return tamlPath; +} + +Torque::Path AssetImporter::importShapeAsset(AssetImportObject* assetItem) +{ + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning importing of Shape Asset: %s", assetItem->assetName.c_str()); + activityLog.push_back(importLogBuffer); + + ShapeAsset* newAsset = new ShapeAsset(); + newAsset->registerObject(); + + StringTableEntry assetName = StringTable->insert(assetItem->assetName.c_str()); + + String shapeFileName = assetItem->filePath.getFileName() + "." + assetItem->filePath.getExtension(); + String assetPath = targetPath + "/" + shapeFileName; + String constructorPath = targetPath + "/" + assetItem->filePath.getFileName() + ".cs"; + String tamlPath = targetPath + "/" + assetName + ".asset.taml"; + String originalPath = assetItem->filePath.getFullPath().c_str(); + String originalConstructorPath = assetItem->filePath.getPath() + assetItem->filePath.getFileName() + ".cs"; + + char qualifiedFromFile[2048]; + char qualifiedToFile[2048]; + char qualifiedFromCSFile[2048]; + char qualifiedToCSFile[2048]; + + Platform::makeFullPathName(originalPath.c_str(), qualifiedFromFile, sizeof(qualifiedFromFile)); + Platform::makeFullPathName(assetPath.c_str(), qualifiedToFile, sizeof(qualifiedToFile)); + + Platform::makeFullPathName(originalConstructorPath.c_str(), qualifiedFromCSFile, sizeof(qualifiedFromCSFile)); + Platform::makeFullPathName(constructorPath.c_str(), qualifiedToCSFile, sizeof(qualifiedToCSFile)); + + newAsset->setAssetName(assetName); + newAsset->setShapeFile(shapeFileName.c_str()); + newAsset->setDataField(StringTable->insert("originalFilePath"), nullptr, qualifiedFromFile); + + //iterate through and write out the material maps dependencies + S32 dependencySlotId = 0; + for (U32 i = 0; i < assetItem->childAssetItems.size(); i++) + { + AssetImportObject* childItem = assetItem->childAssetItems[i]; + + if (childItem->skip || !childItem->processed) + continue; + + if (childItem->assetType.compare("MaterialAsset") == 0) + { + char dependencyFieldName[64]; + dSprintf(dependencyFieldName, 64, "materialSlot%i", dependencySlotId); + + char dependencyFieldDef[512]; + dSprintf(dependencyFieldDef, 512, "@Asset=%s:%s", targetModuleId.c_str(), childItem->assetName.c_str()); + + newAsset->setDataField(StringTable->insert(dependencyFieldName), nullptr, dependencyFieldDef); + + dependencySlotId++; + } + else if (childItem->assetType.compare("ShapeAnimationAsset") == 0) + { + char dependencyFieldName[64]; + dSprintf(dependencyFieldName, 64, "animationSequence%i", dependencySlotId); + + char dependencyFieldDef[512]; + dSprintf(dependencyFieldDef, 512, "@Asset=%s:%s", targetModuleId.c_str(), childItem->assetName.c_str()); + + newAsset->setDataField(StringTable->insert(dependencyFieldName), nullptr, dependencyFieldDef); + + dependencySlotId++; + } + } + + Taml tamlWriter; + bool importSuccessful = tamlWriter.write(newAsset, tamlPath.c_str()); + + if (!importSuccessful) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to write asset taml file %s", tamlPath.c_str()); + activityLog.push_back(importLogBuffer); + return ""; + } + + bool makeNewConstructor = true; + if (!isReimport) + { + bool isInPlace = !dStrcmp(qualifiedFromFile, qualifiedToFile); + + if (!isInPlace && !dPathCopy(qualifiedFromFile, qualifiedToFile, !isReimport)) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromFile); + activityLog.push_back(importLogBuffer); + return ""; + } + + if (!isInPlace && Platform::isFile(qualifiedFromCSFile)) + { + if(!dPathCopy(qualifiedFromCSFile, qualifiedToCSFile, !isReimport)) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Unable to copy file %s", qualifiedFromCSFile); + activityLog.push_back(importLogBuffer); + } + else + { + //We successfully copied the original constructor file, so no extra work required + makeNewConstructor = false; + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Successfully copied original TSShape Constructor file %s", qualifiedFromCSFile); + activityLog.push_back(importLogBuffer); + } + } + } + + if (makeNewConstructor) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Beginning creation of new TSShapeConstructor file: %s", qualifiedToCSFile); + activityLog.push_back(importLogBuffer); + + //find/create shape constructor + TSShapeConstructor* constructor = TSShapeConstructor::findShapeConstructor(Torque::Path(qualifiedToFile).getFullPath()); + if (constructor == nullptr) + { + constructor = new TSShapeConstructor(qualifiedToFile); + + String constructorName = assetItem->filePath.getFileName() + "_" + assetItem->filePath.getExtension().substr(0, 3); + constructorName.replace("-", "_"); + constructorName.replace(".", "_"); + constructorName = Sim::getUniqueName(constructorName.c_str()); + constructor->registerObject(constructorName.c_str()); + } + + + //now we write the import config logic into the constructor itself to ensure we load like we wanted it to + String neverImportMats; + + if (activeImportConfig.IgnoreMaterials.isNotEmpty()) + { + U32 ignoredMatNamesCount = StringUnit::getUnitCount(activeImportConfig.IgnoreMaterials, ",;"); + for (U32 i = 0; i < ignoredMatNamesCount; i++) + { + if (i == 0) + neverImportMats = StringUnit::getUnit(activeImportConfig.IgnoreMaterials, i, ",;"); + else + neverImportMats += String("\t") + StringUnit::getUnit(activeImportConfig.IgnoreMaterials, i, ",;"); + } + } + + if (activeImportConfig.DoUpAxisOverride) + { + S32 upAxis; + if (activeImportConfig.UpAxisOverride.compare("X_AXIS") == 0) + { + upAxis = domUpAxisType::UPAXISTYPE_X_UP; + } + else if (activeImportConfig.UpAxisOverride.compare("Y_AXIS") == 0) + { + upAxis = domUpAxisType::UPAXISTYPE_Y_UP; + } + else if (activeImportConfig.UpAxisOverride.compare("Z_AXIS") == 0) + { + upAxis = domUpAxisType::UPAXISTYPE_Z_UP; + } + constructor->mOptions.upAxis = (domUpAxisType)upAxis; + } + + if (activeImportConfig.DoScaleOverride) + constructor->mOptions.unit = activeImportConfig.ScaleOverride; + else + constructor->mOptions.unit = -1; + + enum eAnimTimingType + { + FrameCount = 0, + Seconds = 1, + Milliseconds = 1000 + }; + + S32 lodType; + if (activeImportConfig.LODType.compare("TrailingNumber") == 0) + lodType = ColladaUtils::ImportOptions::eLodType::TrailingNumber; + else if (activeImportConfig.LODType.compare("SingleSize") == 0) + lodType = ColladaUtils::ImportOptions::eLodType::SingleSize; + else if (activeImportConfig.LODType.compare("DetectDTS") == 0) + lodType = ColladaUtils::ImportOptions::eLodType::DetectDTS; + constructor->mOptions.lodType = (ColladaUtils::ImportOptions::eLodType)lodType; + + constructor->mOptions.singleDetailSize = activeImportConfig.convertLeftHanded; + constructor->mOptions.alwaysImport = activeImportConfig.ImportedNodes; + constructor->mOptions.neverImport = activeImportConfig.IgnoreNodes; + constructor->mOptions.alwaysImportMesh = activeImportConfig.ImportMeshes; + constructor->mOptions.neverImportMesh = activeImportConfig.IgnoreMeshes; + constructor->mOptions.ignoreNodeScale = activeImportConfig.IgnoreNodeScale; + constructor->mOptions.adjustCenter = activeImportConfig.AdjustCenter; + constructor->mOptions.adjustFloor = activeImportConfig.AdjustFloor; + + constructor->mOptions.convertLeftHanded = activeImportConfig.convertLeftHanded; + constructor->mOptions.calcTangentSpace = activeImportConfig.calcTangentSpace; + constructor->mOptions.genUVCoords = activeImportConfig.genUVCoords; + constructor->mOptions.flipUVCoords = activeImportConfig.flipUVCoords; + constructor->mOptions.findInstances = activeImportConfig.findInstances; + constructor->mOptions.limitBoneWeights = activeImportConfig.limitBoneWeights; + constructor->mOptions.joinIdenticalVerts = activeImportConfig.JoinIdenticalVerts; + constructor->mOptions.reverseWindingOrder = activeImportConfig.reverseWindingOrder; + constructor->mOptions.invertNormals = activeImportConfig.invertNormals; + constructor->mOptions.removeRedundantMats = activeImportConfig.removeRedundantMats; + + S32 animTimingType; + if (activeImportConfig.animTiming.compare("FrameCount") == 0) + animTimingType = ColladaUtils::ImportOptions::eAnimTimingType::FrameCount; + else if (activeImportConfig.animTiming.compare("Seconds") == 0) + animTimingType = ColladaUtils::ImportOptions::eAnimTimingType::Seconds; + else// (activeImportConfig.animTiming.compare("Milliseconds") == 0) + animTimingType = ColladaUtils::ImportOptions::eAnimTimingType::Milliseconds; + + constructor->mOptions.animTiming = (ColladaUtils::ImportOptions::eAnimTimingType)animTimingType; + + constructor->mOptions.animFPS = activeImportConfig.animFPS; + + constructor->mOptions.neverImportMat = neverImportMats; + + if (!constructor->save(constructorPath.c_str())) + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Error! Failed to save shape constructor file to %s", constructorPath.c_str()); + activityLog.push_back(importLogBuffer); + } + else + { + dSprintf(importLogBuffer, sizeof(importLogBuffer), "Finished creating shape constructor file to %s", constructorPath.c_str()); + activityLog.push_back(importLogBuffer); + } + } + + return tamlPath; +} diff --git a/Engine/source/T3D/assets/assetImporter.h b/Engine/source/T3D/assets/assetImporter.h new file mode 100644 index 000000000..9a04d21c8 --- /dev/null +++ b/Engine/source/T3D/assets/assetImporter.h @@ -0,0 +1,777 @@ +#pragma once + +#include "assets/assetPtr.h" +#include "assets/assetManager.h" +#include "module/moduleManager.h" +#include "util/settings.h" +#include "gui/controls/guiTreeViewCtrl.h" + +/// +/// AssetImportConfig is a SimObject derived object intended to act as a container for all the necessary configuration data when running the Asset Importer. +/// It dictates if and how any given asset type will be processed when running an import action. This is because the Asset Importer utilizes a lot of informed logic +/// to try and automate as much of the import process as possible. In theory, you would run the import on a given file, and based on your config the importer will do +/// everything from importing the designated file, as well as finding and importing any associated files such as images or materials, and prepping the objects at time +/// of import to avoid as much manual post-processing as possible. +/// +class AssetImportConfig : public SimObject +{ + //General Settings +public: + /// + /// Duplicate Asset Auto-Resolution Action. Options are None, AutoPrune, AutoRename + /// + String DuplicatAutoResolution; + + /// + /// Indicates if warnings should be treated as errors. + /// + bool WarningsAsErrors; + + /// + /// Indicates if importing should be prevented from completing if any errors are detected at all + /// + bool PreventImportWithErrors; + + /// + /// Should the importer automatically prompt to find missing files if they are not detected automatically by the importer + /// + bool AutomaticallyPromptMissingFiles; + // + + // + //Mesh Settings + /// + /// Indicates if this config supports importing meshes + /// + bool ImportMesh; + + /// + /// Indicates if the up axis in the model file should be overridden + /// + bool DoUpAxisOverride; + + /// + /// If overriding, what axis should be used as up. Options are X_AXIS, Y_AXIS, Z_AXIS + /// + String UpAxisOverride; + + /// + /// Indicates if the scale in the model file should be overridden + /// + bool DoScaleOverride; + + /// + /// If overriding, what scale should be used + /// + F32 ScaleOverride; + + /// + /// Indicates if scale of nodes should be ignored + /// + bool IgnoreNodeScale; + + /// + /// Indicates if the center of the model file should be automatically recentered + /// + bool AdjustCenter; + + /// + /// Indicates if the floor height of the model file should be automatically zero'd + /// + bool AdjustFloor; + + /// + /// Indicates if submeshes should be collapsed down into a single main mesh + /// + bool CollapseSubmeshes; + + /// + /// Indicates what LOD mode the model file should utilize to process out LODs. Options are TrailingNumber, DetectDTS, SingleSize + /// + String LODType; + + //ImportAssetConfigSettingsList.addNewConfigSetting("TrailingNumber", "Trailing Number", "float", "", "2", "", "Mesh"); + /// + /// A list of what nodes should be guaranteed to be imported if found in the model file. Separated by either , or ; + /// + String ImportedNodes; + + /// + /// A list of what nodes should be guaranteed to not be imported if found in the model file. Separated by either , or ; + /// + String IgnoreNodes; + + /// + /// A list of what mesh objects should be guaranteed to be imported if found in the model file. Separated by either , or ; + /// + String ImportMeshes; + + /// + /// A list of what mesh objects should be guaranteed to not be imported if found in the model file. Separated by either , or ; + /// + String IgnoreMeshes; + + //Assimp/Collada params + /// + /// Flag to indicate the shape loader should convert to a left-handed coordinate system + /// + bool convertLeftHanded; + + /// + /// Should the shape loader calculate tangent space values + /// + bool calcTangentSpace; + + /// + /// Should the shape loader automatically prune redundant/duplicate materials + /// + bool removeRedundantMats; + + /// + /// Should the shape loader auto-generate UV Coordinates for the mesh. + /// + bool genUVCoords; + + /// + /// Should the UV coordinates be transformed. + /// + bool TransformUVs; + + /// + /// Should the UV coordinates be flipped + /// + bool flipUVCoords; + + /// + /// Should the shape loader automatically look for instanced submeshes in the model file + /// + bool findInstances; + + /// + /// Should the shape loader limit the bone weights + /// + bool limitBoneWeights; + + /// + /// Should the shape loader automatically merge identical/duplicate verts + /// + bool JoinIdenticalVerts; + + /// + /// Should the shape loader reverse the winding order of the mesh's face indicies + /// + bool reverseWindingOrder; + + /// + /// Should the normals on the model be inverted + /// + bool invertNormals; + // + + // + //Materials + /// + /// Does this config allow for importing of materials + /// + bool ImportMaterials; + + /// + /// When importing a material, should it automatically attempt to merge Roughness, AO and Metalness maps into a single, composited PBR Configuration map + /// + bool CreatePBRConfig; + + /// + /// When generating a material off of an importing image, should the importer force appending a diffusemap suffix onto the end to avoid potential naming confusion. + /// e.g. MyCoolStuff.png is imported, generating MyCoolStuff material asset and MyCoolStuff_Diffuse image asset + /// + bool UseDiffuseSuffixOnOriginImage; + + /// + /// Should the importer try and use existing material assets in the game directory if at all possible. (Not currently utilized) + /// + bool UseExistingMaterials; + + /// + /// A list of material names that should not be imported. Separated by either , or ; + /// + String IgnoreMaterials; + + /// + /// When processing a material asset, should the importer attempt to populate the various material maps on it by looking up common naming conventions for potentially relevent image files + /// e.g. If MyCoolStuff_Diffuse.png is imported, generating MyCoolStuff material, it would also find MyCoolStuff_Normal and MyCoolStuff_PBR images and map them to the normal and PBRConfig maps respectively automatically + /// + bool PopulateMaterialMaps; + + // + //Animations + /// + /// Does this config allow for importing Shape Animations + /// + bool ImportAnimations; + + /// + /// When importing a shape file, should the animations within be separated out into unique files + /// + bool SeparateAnimations; + + /// + /// If separating animations out from a source file, what prefix should be added to the names for grouping association + /// + String SeparateAnimationPrefix; + + /// + /// Defines the animation timing for the given animation sequence. Options are FrameTime, Seconds, Milliseconds + /// + String animTiming; + + /// + /// The FPS of the animation sequence + /// + F32 animFPS; + + // + //Collision + /// + /// Does this configuration generate collision geometry when importing. (Not currently enabled) + /// + bool GenerateCollisions; + + /// + /// What sort of collision geometry is generated. (Not currently enabled) + /// + String GenCollisionType; + + /// + /// What prefix is added to the collision geometry generated. (Not currently enabled) + /// + String CollisionMeshPrefix; + + /// + /// Does this configuration generate Line of Sight collision geometry. (Not currently enabled) + /// + bool GenerateLOSCollisions; + + /// + /// What sort of Line of Sight collision geometry is generated. (Not currently enabled) + /// + String GenLOSCollisionType; + + /// + /// What prefix is added to the Line of Sight collision geometry generated. (Not currently enabled) + /// + String LOSCollisionMeshPrefix; + + // + //Images + /// + /// Does this configuration support importing images. + /// + bool importImages; + + /// + /// What is the default ImageType images are imported as. Options are: N/A, Diffuse, Normal, Metalness, Roughness, AO, PBRConfig, GUI, Cubemap + /// + String ImageType; + + /// + /// What type of suffixes are scanned to detect if an importing image is a diffuse map. + /// e.g. _Albedo or _Color + /// + String DiffuseTypeSuffixes; + + /// + /// What type of suffixes are scanned to detect if an importing image is a normal map. + /// e.g. _Normal or _Norm + /// + String NormalTypeSuffixes; + + /// + /// What type of suffixes are scanned to detect if an importing image is a metalness map. + /// e.g. _Metalness or _Metal + /// + String MetalnessTypeSuffixes; + + /// + /// What type of suffixes are scanned to detect if an importing image is a roughness map. + /// e.g. _roughness or _rough + /// + String RoughnessTypeSuffixes; + + /// + /// What type of suffixes are scanned to detect if an importing image is a smoothness map. + /// e.g. _smoothness or _smooth + /// + String SmoothnessTypeSuffixes; + + /// + /// What type of suffixes are scanned to detect if an importing image is a ambient occlusion map. + /// e.g. _ambient or _ao + /// + String AOTypeSuffixes; + + /// + /// What type of suffixes are scanned to detect if an importing image is a PBRConfig map. + /// e.g. _Composite or _PBR + /// + String PBRTypeSuffixes; + + /// + /// Indicates what filter mode images imported with this configuration utilizes. Options are Linear, Bilinear, Trilinear + /// + String TextureFilteringMode; + + /// + /// Indicates if images imported with this configuration utilize mipmaps + /// + bool UseMips; + + /// + /// Indicates if images imported with this configuration are in an HDR format + /// + bool IsHDR; + + /// + /// Indicates what amount of scaling images imported with this configuration use + /// + F32 Scaling; + + /// + /// Indicates if images imported with this configuration are compressed + /// + bool ImagesCompressed; + + /// + /// Indicates if images imported with this configuration generate a parent material for it as well + /// + bool GenerateMaterialOnImport; + + // + //Sounds + /// + /// Indicates if sounds are imported with this configuration + /// + bool importSounds; + + /// + /// Indicates what amount the volume is adjusted on sounds imported with this configuration + /// + F32 VolumeAdjust; + + /// + /// Indicates what amount the pitch is adjusted on sounds imported with this configuration + /// + F32 PitchAdjust; + + /// + /// Indicates if sounds imported with this configuration are compressed + /// + bool SoundsCompressed; + +public: + AssetImportConfig(); + virtual ~AssetImportConfig(); + + /// Engine. + static void initPersistFields(); + + /// + /// Loads a configuration from a Settings object + /// @param configSettings, The Settings object to load from + /// @param configName, The name of the configuration setting to load from the setting object + /// + void loadImportConfig(Settings* configSettings, String configName); + + /// Declare Console Object. + DECLARE_CONOBJECT(AssetImportConfig); +}; + +/// +/// AssetImportConfig is a SimObject derived object that represents and holds information for an importing asset. They are generated and processed by the AssetImporter +/// +class AssetImportObject : public SimObject +{ + typedef SimObject Parent; + +public: + /// + /// What type is the importing asset + /// + String assetType; + + /// + /// What is the source file path of the importing asset + /// + Torque::Path filePath; + + /// + /// What is the asset's name + /// + String assetName; + + /// + /// What is the original, unmodified by processing, asset name + /// + String cleanAssetName; + + /// + /// What is the name of the module this asset will be importing into + /// + String moduleName; + + /// + /// What is the current status of this asset item in it's import process + /// + String status; + + /// + /// If there is a warning or error status, what type is the condition for this asset item + /// + String statusType; + + /// + /// What is the articulated information of the status of the asset. Contains the error or warning log data. + /// + String statusInfo; + + /// + /// Is the asset item currently flagged as dirty + /// + bool dirty; + + /// + /// Is this asset item marked to be skipped. If it is, it's usually due to being marked as deleted + /// + bool skip; + + /// + /// Has the asset item been processed + /// + bool processed; + + /// + /// Is this specific asset item generated as part of the import process of another item + /// + bool generatedAsset; + + /// + /// What, if any, importing asset item is this item's parent + /// + AssetImportObject* parentAssetItem; + + /// + /// What, if any, importing asset item are children of this item + /// + Vector< AssetImportObject*> childAssetItems; + + /// + /// What is the ultimate asset taml file path for this import item + /// + String tamlFilePath; + + // + /// + /// Specific to ImageAsset type + /// What is the image asset's suffix type. Options are: Albedo, Normal, Roughness, AO, Metalness, PBRConfig + /// + String imageSuffixType; + + // + /// + /// Specific to ShapeAsset type + /// Processed information about the shape file. Contains numbers and lists of meshes, materials and animations + /// + GuiTreeViewCtrl* shapeInfo; + +public: + AssetImportObject(); + virtual ~AssetImportObject(); + + /// Engine. + static void initPersistFields(); + + /// Declare Console Object. + DECLARE_CONOBJECT(AssetImportObject); +}; + +/// +/// AssetImporter is a SimObject derived object that processed and imports files and turns them into assets if they are of valid types. +/// Utilizes an AssetImportConfig to inform the importing process's behavior. +/// +class AssetImporter : public SimObject +{ + typedef SimObject Parent; + + /// + /// The import configuration that is currently being utilized + /// + AssetImportConfig activeImportConfig; + + /// + /// A log of all the actions that have been performed by the importer + /// + Vector activityLog; + + /// + /// A list of AssetImportObjects that are to be imported + /// + Vector importingAssets; + + /// + /// A list of file paths that are to be imported. These are only used for resetting purposes; + /// + Vector originalImportingFiles; + + /// + /// The Id of the module the assets are to be imported into + /// + String targetModuleId; + + /// + /// The path any imported assets are placed in as their destination + /// + String targetPath; + + /// + /// Are there any issues with any of the current import asset items + /// + bool importIssues; + + /// + /// Is this import action a reimport of an existing asset + /// + bool isReimport; + + /// + /// Has the heirarchy of asset import items changed due to processing + /// + bool assetHeirarchyChanged; + + /// + /// A string used for writing into the importLog + /// + char importLogBuffer[1024]; + +public: + AssetImporter(); + virtual ~AssetImporter(); + + /// Engine. + static void initPersistFields(); + + /// Declare Console Object. + DECLARE_CONOBJECT(AssetImporter); + + /// + /// Sets the target path for the assets being imported to be deposited into + /// @param pTargetPath, The filePath of the destination point assets are imported into + /// + void setTargetPath(Torque::Path pTargetPath) { targetPath = pTargetPath; } + + /// + /// Processes a file into an AssetImportObject and adds it to the session for importing + /// @param filePath, The filePath of the file to be imported in as an asset + /// @return AssetImportObject that was created + /// + AssetImportObject* addImportingFile(Torque::Path filePath); + + /// + /// Adds an importing asset to the current session + /// @param assetType, Type of the asset being imported + /// @param filePath, path of the file to be imported + /// @param parentItem, AssetImportObject that the new item is a child of. null if no parent + /// @param assetNameOverride, If not blank, will be the new item's assetName instead of being created off of the filePath + /// @return AssetImportObject that was created + /// + AssetImportObject* addImportingAsset(String assetType, Torque::Path filePath, AssetImportObject* parentItem, String assetNameOverride); + + /// + /// Deletes the asset item from the import session. Affects the item's children as well + /// @param assetItem, asset item to be marked as deleted + /// + void deleteImportingAsset(AssetImportObject* assetItem); + + /// + /// Finds an asset item in the session if it exists, by name + /// @param assetName, Asset name to find + /// @param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children + /// @return AssetImportObject that was found + /// + AssetImportObject* findImportingAssetByName(String assetName, AssetImportObject* assetItem = nullptr); + + /// + /// Finds the module associated with a given file path + /// @param filePath, File path to parse the the module from + /// @return ModuleDefinition that was found + /// + ModuleDefinition* getModuleFromPath(Torque::Path filePath); + + /// + /// Parses an asset's name to try and find if any of the import config's suffix lists match to it + /// @param assetName, Asset name to parse any image suffix out of + /// @param suffixType, output, The suffix type that was matched to the asset name + /// @return suffix that matched to the asset name + /// + String parseImageSuffixes(String assetName, String* suffixType); + + /// + /// Parses a file path to determine its asset type + /// @param filePath, File path to parse + /// @return The asset type as a string + /// + String getAssetTypeByFile(Torque::Path filePath); + + /// + /// Resets the import session to a clean slate. This will clear all existing AssetImportObjects and the activity log + /// and then re-process the original filePaths again. + /// + void resetImportSession(); + + /// + /// Get the number of lines in the activity log + /// @return Line count as S32 + /// + S32 getActivityLogLineCount(); + + /// + /// Gets the log line at a given index + /// @param line, line in the log to get + /// @return The log line as a string + /// + String getActivityLogLine(U32 line); + + /// + /// Dumps the entire current activity log to the console. + /// + void dumpActivityLog(); + + /// + /// Gets the number of top-level asset items in the current import session(doesn't count children) + /// @return Number of children + /// + S32 getAssetItemCount(); + + /// + /// Get the top-level asset item in the current import session at the requested index + /// @param index, The index of the item array to get + /// @return The AssetImportObject at the index + /// + AssetImportObject* getAssetItem(U32 index); + + /// + /// Gets the number of child asset items of a given AssetImportObject + /// @param assetItem, The AssetImportObject to get the number of child items for + /// @return Number of children + /// + S32 getAssetItemChildCount(AssetImportObject* assetItem); + + /// + /// Get the child asset item of a specific AssetImportObject at the requested index + /// @param assetItem, The AssetImportObject to get the number of child items for + /// @param index, The index of the child item array to get + /// @return The AssetImportObject at the index + /// + AssetImportObject* getAssetItemChild(AssetImportObject* assetItem, U32 index); + + /// + /// Process AssetImportObject's to prepare them for importing. + /// @param assetItem, If null, will loop over the top-level asset items list, if a specific item is provided, will process it's children + /// + void processImportAssets(AssetImportObject* assetItem = nullptr); + + /// + /// Process a specific AssetImportObject that is an ImageAsset type to prepare it for importing + /// @param assetItem, The AssetImportObject to process + /// + void processImageAsset(AssetImportObject* assetItem); + + /// + /// Process a specific AssetImportObject that is an MaterialAsset type to prepare it for importing + /// @param assetItem, The AssetImportObject to process + /// + void processMaterialAsset(AssetImportObject* assetItem); + + /// + /// Process a specific AssetImportObject that is an ShapeAsset type to prepare it for importing + /// @param assetItem, The AssetImportObject to process + /// + void processShapeAsset(AssetImportObject* assetItem); + + /// + /// Process a specific ShapeAsset AssetImportObject with a material id in order to parse and handle the materials listed in the shape file + /// @param assetItem, The AssetImportObject to process + /// @param materialItemId, The materialItemId in the shapeInfo to process + /// + void processShapeMaterialInfo(AssetImportObject* assetItem, S32 materialItemId); + + /// + /// Run through and validate assets for issues, such as name collisions + /// + bool validateAssets(); + + /// + /// Validate a specific asset item + /// @param assetItem, The AssetImportObject to validate + /// + void validateAsset(AssetImportObject* assetItem); + + /// + /// Reset the validation status of asset items + /// @param assetItem, If null, will loop over the top-level asset items list, if a specific item is provided, will reset it's children + /// + void resetAssetValidationStatus(AssetImportObject* assetItem = nullptr); + + /// + /// Checks asset items for any collisions in the current import session + /// @param assetItemToCheckFor, The asset to check for collisions with + /// @param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children + /// @return If a collision was detected + /// + bool checkAssetForCollision(AssetImportObject* assetItemToCheckFor, AssetImportObject* assetItem = nullptr); + + /// + /// Attempts to automatically resolve import issues according to the import config settings + /// @param assetItem, The AssetImportObject to resolve + /// + void resolveAssetItemIssues(AssetImportObject* assetItem); + + /// + /// Runs the import process on a single file in-place. Intended primarily for autoimporting a loose file that's in the game directory. + /// @param filePath, The filePath of the file to be imported in as an asset + /// @return AssetId of the asset that was imported. If import failed, it will be empty. + /// + StringTableEntry autoImportFile(Torque::Path filePath); + + /// + /// Runs the import process in the current session + /// @param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children + /// + void importAssets(AssetImportObject* assetItem = nullptr); + + /// + /// Runs the import processing on a specific ImageAsset item + /// @param assetItem, The asset item to import + /// @return AssetId of the asset that was imported. If import failed, it will be empty. + /// + Torque::Path importImageAsset(AssetImportObject* assetItem); + + /// + /// Runs the import processing on a specific MaterialAsset item + /// @param assetItem, The asset item to import + /// @return AssetId of the asset that was imported. If import failed, it will be empty. + /// + Torque::Path importMaterialAsset(AssetImportObject* assetItem); + + /// + /// Runs the import processing on a specific ShapeAsset item + /// @param assetItem, The asset item to import + /// @return AssetId of the asset that was imported. If import failed, it will be empty. + /// + Torque::Path importShapeAsset(AssetImportObject* assetItem); + + // + /// + /// Gets the currently active import configuration + /// @return Current AssetImportConfig the importer is using + /// + AssetImportConfig* getImportConfig() { return &activeImportConfig; } +}; diff --git a/Engine/source/T3D/assets/assetImporter_ScriptBinding.h b/Engine/source/T3D/assets/assetImporter_ScriptBinding.h new file mode 100644 index 000000000..6c3d9fedb --- /dev/null +++ b/Engine/source/T3D/assets/assetImporter_ScriptBinding.h @@ -0,0 +1,140 @@ +#pragma once + +#include "console/engineAPI.h" +#include "assetImporter.h" + +//Console Functions + +DefineEngineMethod(AssetImportConfig, loadImportConfig, void, (Settings* configSettings, String configName), (nullAsType(), ""), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->loadImportConfig(configSettings, configName); +} + +DefineEngineMethod(AssetImporter, setTargetPath, void, (String path), (""), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->setTargetPath(path); +} + +DefineEngineMethod(AssetImporter, resetImportSession, void, (), , + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->resetImportSession(); +} + +DefineEngineMethod(AssetImporter, dumpActivityLog, void, (), , + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->dumpActivityLog(); +} + +DefineEngineMethod(AssetImporter, getActivityLogLineCount, S32, (),, + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->getActivityLogLineCount(); +} + +DefineEngineMethod(AssetImporter, getActivityLogLine, String, (S32 i), (0), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->getActivityLogLine(0); +} + +DefineEngineMethod(AssetImporter, autoImportFile, String, (String path), (""), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->autoImportFile(path); +} + +DefineEngineMethod(AssetImporter, addImportingFile, AssetImportObject*, (String path), (""), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->addImportingFile(path); +} + +DefineEngineMethod(AssetImporter, processImportingAssets, void, (), , + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->processImportAssets(); +} + +DefineEngineMethod(AssetImporter, validateImportingAssets, bool, (), , + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->validateAssets(); +} + +DefineEngineMethod(AssetImporter, resolveAssetItemIssues, void, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + object->resolveAssetItemIssues(assetItem); +} + +DefineEngineMethod(AssetImporter, importAssets, void, (),, + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->importAssets(); +} + +DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),, + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->getAssetItemCount(); +} + +DefineEngineMethod(AssetImporter, getAssetItem, AssetImportObject*, (S32 index), (0), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + return object->getAssetItem(index); +} + +DefineEngineMethod(AssetImporter, getAssetItemChildCount, S32, (AssetImportObject* assetItem), (nullAsType< AssetImportObject*>()), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + if (assetItem == nullptr) + return 0; + + return object->getAssetItemChildCount(assetItem); +} + +DefineEngineMethod(AssetImporter, getAssetItemChild, AssetImportObject*, (AssetImportObject* assetItem, S32 index), (nullAsType< AssetImportObject*>(), 0), + "Creates a new script asset using the targetFilePath.\n" + "@return The bool result of calling exec") +{ + if (assetItem == nullptr) + return nullptr; + + return object->getAssetItemChild(assetItem, index); +} + + +/*DefineEngineFunction(enumColladaForImport, bool, (const char* shapePath, const char* ctrl, bool loadCachedDts), ("", "", true), + "(string shapePath, GuiTreeViewCtrl ctrl) Collect scene information from " + "a COLLADA file and store it in a GuiTreeView control. This function is " + "used by the COLLADA import gui to show a preview of the scene contents " + "prior to import, and is probably not much use for anything else.\n" + "@param shapePath COLLADA filename\n" + "@param ctrl GuiTreeView control to add elements to\n" + "@param loadCachedDts dictates if it should try and load the cached dts file if it exists" + "@return true if successful, false otherwise\n" + "@ingroup Editors\n" + "@internal") +{ + return enumColladaForImport(shapePath, ctrl, loadCachedDts); +}*/ diff --git a/Engine/source/T3D/cameraSpline.cpp b/Engine/source/T3D/cameraSpline.cpp index 1129f91f8..d7c525e33 100644 --- a/Engine/source/T3D/cameraSpline.cpp +++ b/Engine/source/T3D/cameraSpline.cpp @@ -36,6 +36,7 @@ CameraSpline::Knot::Knot() mSpeed = 0.0f; mType = NORMAL; mPath = SPLINE; + mDistance = 0.0f; prev = NULL; next = NULL; }; @@ -46,6 +47,7 @@ CameraSpline::Knot::Knot(const Knot &k) mSpeed = k.mSpeed; mType = k.mType; mPath = k.mPath; + mDistance = k.mDistance; prev = NULL; next = NULL; } @@ -56,6 +58,7 @@ CameraSpline::Knot::Knot(const Point3F &p, const QuatF &r, F32 s, Knot::Type typ mSpeed = s; mType = type; mPath = path; + mDistance = 0.0f; prev = NULL; next = NULL; } diff --git a/Engine/source/T3D/convexShape.cpp b/Engine/source/T3D/convexShape.cpp index 12deb300d..8f73b564d 100644 --- a/Engine/source/T3D/convexShape.cpp +++ b/Engine/source/T3D/convexShape.cpp @@ -92,12 +92,12 @@ void ConvexShapeCollisionConvex::getFeatures( const MatrixF &mat, const VectorF if ( pShape->mGeometry.points.empty() ) { cf->material = 0; - cf->object = NULL; + cf->mObject = NULL; return; } cf->material = 0; - cf->object = mObject; + cf->mObject = mObject; // Simple implementation... Add all Points, Edges and Faces. diff --git a/Engine/source/T3D/convexShape.h b/Engine/source/T3D/convexShape.h index 6145937b7..3bbd2e657 100644 --- a/Engine/source/T3D/convexShape.h +++ b/Engine/source/T3D/convexShape.h @@ -50,7 +50,7 @@ protected: public: - ConvexShapeCollisionConvex() { mType = ConvexShapeCollisionConvexType; } + ConvexShapeCollisionConvex() { pShape = NULL; mType = ConvexShapeCollisionConvexType; } ConvexShapeCollisionConvex( const ConvexShapeCollisionConvex& cv ) { mType = ConvexShapeCollisionConvexType; @@ -297,4 +297,4 @@ protected: }; -#endif // _CONVEXSHAPE_H_ \ No newline at end of file +#endif // _CONVEXSHAPE_H_ diff --git a/Engine/source/T3D/debris.cpp b/Engine/source/T3D/debris.cpp index 24014d5c8..de991db51 100644 --- a/Engine/source/T3D/debris.cpp +++ b/Engine/source/T3D/debris.cpp @@ -533,6 +533,8 @@ Debris::Debris() mInitialTrans.identity(); mRadius = 0.2f; mStatic = false; + mElasticity = 0.5f; + mFriction = 0.5f; dMemset( mEmitterList, 0, sizeof( mEmitterList ) ); diff --git a/Engine/source/T3D/decal/decalInstance.cpp b/Engine/source/T3D/decal/decalInstance.cpp index 935361b6d..a0b2d8748 100644 --- a/Engine/source/T3D/decal/decalInstance.cpp +++ b/Engine/source/T3D/decal/decalInstance.cpp @@ -24,6 +24,23 @@ #include "T3D/decal/decalInstance.h" #include "scene/sceneRenderState.h" +DecalInstance::DecalInstance() + : mDataBlock(NULL), + mRotAroundNormal(0.0f), + mSize(0.0f), + mCreateTime(0), + mVisibility(1.0f), + mLastAlpha(1.0f), + mTextureRectIdx(0), + mVerts(NULL), + mIndices(NULL), + mVertCount(0), + mIndxCount(0), + mFlags(0), + mRenderPriority(0), + mId(-1), + mCustomTex(NULL) +{} void DecalInstance::getWorldMatrix( MatrixF *outMat, bool flip ) { outMat->setPosition( mPosition ); diff --git a/Engine/source/T3D/decal/decalInstance.h b/Engine/source/T3D/decal/decalInstance.h index 52402e89a..9365f4a3a 100644 --- a/Engine/source/T3D/decal/decalInstance.h +++ b/Engine/source/T3D/decal/decalInstance.h @@ -87,7 +87,7 @@ class DecalInstance /// Calculates the size of this decal onscreen in pixels, used for LOD. F32 calcPixelSize( U32 viewportHeight, const Point3F &cameraPos, F32 worldToScreenScaleY ) const; - DecalInstance() : mId(-1) {} + DecalInstance(); }; #endif // _DECALINSTANCE_H_ diff --git a/Engine/source/T3D/fx/explosion.cpp b/Engine/source/T3D/fx/explosion.cpp index 4da7b2902..be9badc73 100644 --- a/Engine/source/T3D/fx/explosion.cpp +++ b/Engine/source/T3D/fx/explosion.cpp @@ -238,6 +238,9 @@ ExplosionData::ExplosionData() explosionScale.set(1.0f, 1.0f, 1.0f); playSpeed = 1.0f; + explosionShape = NULL; + explosionAnimation = -1; + dMemset( emitterList, 0, sizeof( emitterList ) ); dMemset( emitterIDList, 0, sizeof( emitterIDList ) ); dMemset( debrisList, 0, sizeof( debrisList ) ); @@ -924,6 +927,7 @@ Explosion::Explosion() ss_index = 0; mDataBlock = 0; soundProfile_clone = 0; + mRandomVal = 0; } Explosion::~Explosion() @@ -962,7 +966,7 @@ void Explosion::setInitialState(const Point3F& point, const Point3F& normal, con void Explosion::initPersistFields() { Parent::initPersistFields(); - + addField("initialNormal", TypePoint3F, Offset(mInitialNormal, Explosion), "Initial starting Normal."); // } diff --git a/Engine/source/T3D/fx/fxFoliageReplicator.cpp b/Engine/source/T3D/fx/fxFoliageReplicator.cpp index bd8389486..4f21482f8 100644 --- a/Engine/source/T3D/fx/fxFoliageReplicator.cpp +++ b/Engine/source/T3D/fx/fxFoliageReplicator.cpp @@ -286,6 +286,7 @@ fxFoliageReplicator::fxFoliageReplicator() // Reset Foliage Count. mCurrentFoliageCount = 0; + dMemset(&mFrustumRenderSet, 0, sizeof(mFrustumRenderSet)); // Reset Creation Area Angle Animation. mCreationAreaAngle = 0; @@ -299,8 +300,15 @@ fxFoliageReplicator::fxFoliageReplicator() // Reset Frame Serial ID. mFrameSerialID = 0; - + mQuadTreeLevels = 0; + mNextAllocatedNodeIdx = 0; mAlphaLookup = NULL; + mFadeInGradient = 0.0f; + mFadeOutGradient = 0.0f; + mGlobalSwayPhase = 0.0f; + mGlobalSwayTimeRatio = 1.0f; + mGlobalLightPhase = 0.0f; + mGlobalLightTimeRatio = 1.0f; mDirty = true; @@ -317,6 +325,8 @@ fxFoliageReplicator::fxFoliageReplicator() mFoliageShaderTrueBillboardSC = NULL; mFoliageShaderGroundAlphaSC = NULL; mFoliageShaderAmbientColorSC = NULL; + mDiffuseTextureSC = NULL; + mAlphaMapTextureSC = NULL; mShaderData = NULL; } diff --git a/Engine/source/T3D/fx/lightning.cpp b/Engine/source/T3D/fx/lightning.cpp index c951f022e..e808fb406 100644 --- a/Engine/source/T3D/fx/lightning.cpp +++ b/Engine/source/T3D/fx/lightning.cpp @@ -248,7 +248,7 @@ LightningData::LightningData() strikeTextureNames[i] = NULL; strikeTextures[i] = NULL; } - + numThunders = 0; mNumStrikeTextures = 0; } @@ -371,6 +371,7 @@ Lightning::Lightning() mNetFlags.set(Ghostable|ScopeAlways); mTypeMask |= StaticObjectType|EnvironmentObjectType; + mDataBlock = NULL; mLastThink = 0; mStrikeListHead = NULL; @@ -1033,6 +1034,16 @@ LightningBolt::LightningBolt() elapsedTime = 0.0f; lifetime = 1.0f; startRender = false; + endPoint.zero(); + width = 1; + numMajorNodes = 10; + maxMajorAngle = 30.0f; + numMinorNodes = 4; + maxMinorAngle = 15.0f; + fadeTime = 0.2f; + renderTime = 0.125; + dMemset(&mMajorNodes, 0, sizeof(mMajorNodes)); + percentFade = 0.0f; } //-------------------------------------------------------------------------- diff --git a/Engine/source/T3D/fx/particleEmitter.cpp b/Engine/source/T3D/fx/particleEmitter.cpp index f5b705bd5..5cbe35409 100644 --- a/Engine/source/T3D/fx/particleEmitter.cpp +++ b/Engine/source/T3D/fx/particleEmitter.cpp @@ -846,6 +846,7 @@ ParticleEmitterData::ParticleEmitterData(const ParticleEmitterData& other, bool textureName = other.textureName; textureHandle = other.textureHandle; // -- TextureHandle loads using textureName highResOnly = other.highResOnly; + glow = other.glow; renderReflection = other.renderReflection; fade_color = other.fade_color; fade_size = other.fade_size; @@ -965,7 +966,7 @@ ParticleEmitter::ParticleEmitter() pos_pe.set(0,0,0); sort_priority = 0; mDataBlock = 0; - + std::fill_n(sizes, ParticleData::PDC_NUM_KEYS, 0.0f); #if defined(AFX_CAP_PARTICLE_POOLS) pool = 0; #endif diff --git a/Engine/source/T3D/fx/ribbon.cpp b/Engine/source/T3D/fx/ribbon.cpp index a3d788590..42fa1e63e 100644 --- a/Engine/source/T3D/fx/ribbon.cpp +++ b/Engine/source/T3D/fx/ribbon.cpp @@ -170,6 +170,7 @@ void RibbonData::unpackData(BitStream* stream) // Ribbon::Ribbon() { + mDataBlock = NULL; mTypeMask |= StaticObjectType; VECTOR_SET_ASSOCIATION(mSegmentPoints); diff --git a/Engine/source/T3D/fx/ribbonNode.h b/Engine/source/T3D/fx/ribbonNode.h index cdd86ef33..d4be52fa8 100644 --- a/Engine/source/T3D/fx/ribbonNode.h +++ b/Engine/source/T3D/fx/ribbonNode.h @@ -37,9 +37,6 @@ class RibbonNodeData : public GameBaseData { typedef GameBaseData Parent; -public: - F32 timeMultiple; - public: RibbonNodeData(); ~RibbonNodeData(); diff --git a/Engine/source/T3D/fx/splash.cpp b/Engine/source/T3D/fx/splash.cpp index 812c1bb2f..d77c46edb 100644 --- a/Engine/source/T3D/fx/splash.cpp +++ b/Engine/source/T3D/fx/splash.cpp @@ -309,6 +309,7 @@ Splash::Splash() mDelayMS = 0; mCurrMS = 0; + mRandAngle = 0; mEndingMS = 1000; mActive = false; mRadius = 0.0; @@ -319,7 +320,8 @@ Splash::Splash() mElapsedTime = 0.0; mInitialNormal.set( 0.0, 0.0, 1.0 ); - + mFade = 0; + mFog = 0; // Only allocated client side. mNetFlags.set( IsGhost ); } diff --git a/Engine/source/T3D/gameBase/gameBase.cpp b/Engine/source/T3D/gameBase/gameBase.cpp index 3d0e8bd1e..2f6fd36d2 100644 --- a/Engine/source/T3D/gameBase/gameBase.cpp +++ b/Engine/source/T3D/gameBase/gameBase.cpp @@ -254,6 +254,7 @@ GameBase::GameBase() mTicksSinceLastMove = 0; mIsAiControlled = false; #endif + mCameraFov = 90.f; } GameBase::~GameBase() diff --git a/Engine/source/T3D/gameBase/moveList.cpp b/Engine/source/T3D/gameBase/moveList.cpp index c4eea88ee..f91ff291c 100644 --- a/Engine/source/T3D/gameBase/moveList.cpp +++ b/Engine/source/T3D/gameBase/moveList.cpp @@ -26,6 +26,7 @@ MoveList::MoveList() { + mConnection = NULL; mControlMismatch = false; reset(); } diff --git a/Engine/source/T3D/guiMaterialPreview.cpp b/Engine/source/T3D/guiMaterialPreview.cpp index 05d42b87f..ad1de4c2d 100644 --- a/Engine/source/T3D/guiMaterialPreview.cpp +++ b/Engine/source/T3D/guiMaterialPreview.cpp @@ -61,6 +61,8 @@ GuiMaterialPreview::GuiMaterialPreview() // By default don't do dynamic reflection // updates for this viewport. mReflectPriority = 0.0f; + mMountedModel = NULL; + mSkinTag = 0; } GuiMaterialPreview::~GuiMaterialPreview() diff --git a/Engine/source/T3D/lighting/IBLUtilities.cpp b/Engine/source/T3D/lighting/IBLUtilities.cpp index b66838778..6945c6b80 100644 --- a/Engine/source/T3D/lighting/IBLUtilities.cpp +++ b/Engine/source/T3D/lighting/IBLUtilities.cpp @@ -138,6 +138,20 @@ namespace IBLUtilities GFXShaderConstHandle* prefilterMipSizeSC = prefilterShader->getShaderConstHandle("$mipSize"); GFXShaderConstHandle* prefilterResolutionSC = prefilterShader->getShaderConstHandle("$resolution"); + GFXStateBlockDesc desc; + desc.zEnable = false; + desc.samplersDefined = true; + desc.samplers[0].addressModeU = GFXAddressClamp; + desc.samplers[0].addressModeV = GFXAddressClamp; + desc.samplers[0].addressModeW = GFXAddressClamp; + desc.samplers[0].magFilter = GFXTextureFilterLinear; + desc.samplers[0].minFilter = GFXTextureFilterLinear; + desc.samplers[0].mipFilter = GFXTextureFilterLinear; + + GFXStateBlockRef preStateBlock; + preStateBlock = GFX->createStateBlock(desc); + GFX->setStateBlock(preStateBlock); + GFX->pushActiveRenderTarget(); GFX->setShader(prefilterShader); GFX->setShaderConstBuffer(prefilterConsts); diff --git a/Engine/source/T3D/physics/physicsForce.cpp b/Engine/source/T3D/physics/physicsForce.cpp index a8f16dca5..a64cf71f7 100644 --- a/Engine/source/T3D/physics/physicsForce.cpp +++ b/Engine/source/T3D/physics/physicsForce.cpp @@ -43,6 +43,7 @@ ConsoleDocClass( PhysicsForce, PhysicsForce::PhysicsForce() : mWorld( NULL ), + mForce(0.0f), mPhysicsTick( false ), mBody( NULL ) { diff --git a/Engine/source/T3D/player.cpp b/Engine/source/T3D/player.cpp index 06ec7171a..91444bb53 100644 --- a/Engine/source/T3D/player.cpp +++ b/Engine/source/T3D/player.cpp @@ -311,6 +311,11 @@ PlayerData::PlayerData() jumpEnergyDrain = 0.0f; minJumpEnergy = 0.0f; jumpSurfaceAngle = 78.0f; + jumpSurfaceCos = mCos(mDegToRad(jumpSurfaceAngle)); + + for (U32 i = 0; i < NumRecoilSequences; i++) + recoilSequence[i] = -1; + jumpDelay = 30; minJumpSpeed = 500.0f; maxJumpSpeed = 2.0f * minJumpSpeed; @@ -370,6 +375,9 @@ PlayerData::PlayerData() actionCount = 0; lookAction = 0; + dMemset(spineNode, 0, sizeof(spineNode)); + + pickupDelta = 0.0f; // size of bounding box boxSize.set(1.0f, 1.0f, 2.3f); diff --git a/Engine/source/T3D/rigidShape.cpp b/Engine/source/T3D/rigidShape.cpp index e2ba4606c..005ef8c98 100644 --- a/Engine/source/T3D/rigidShape.cpp +++ b/Engine/source/T3D/rigidShape.cpp @@ -253,6 +253,7 @@ RigidShapeData::RigidShapeData() dustEmitter = NULL; dustID = 0; + triggerDustHeight = 3.0; dustHeight = 1.0; dMemset( splashEmitterList, 0, sizeof( splashEmitterList ) ); diff --git a/Engine/source/T3D/shapeBase.cpp b/Engine/source/T3D/shapeBase.cpp index 9042f3a82..d9830785d 100644 --- a/Engine/source/T3D/shapeBase.cpp +++ b/Engine/source/T3D/shapeBase.cpp @@ -3571,7 +3571,7 @@ Point3F ShapeBaseConvex::support(const VectorF& v) const void ShapeBaseConvex::getFeatures(const MatrixF& mat, const VectorF& n, ConvexFeature* cf) { cf->material = 0; - cf->object = mObject; + cf->mObject = mObject; TSShape::ConvexHullAccelerator* pAccel = pShapeBase->mShapeInstance->getShape()->getAccelerator(pShapeBase->mDataBlock->collisionDetails[hullId]); diff --git a/Engine/source/T3D/shapeBase.h b/Engine/source/T3D/shapeBase.h index 364d1cbe7..71b221036 100644 --- a/Engine/source/T3D/shapeBase.h +++ b/Engine/source/T3D/shapeBase.h @@ -111,7 +111,7 @@ class ShapeBaseConvex : public Convex Box3F box; public: - ShapeBaseConvex() { mType = ShapeBaseConvexType; nodeTransform = 0; } + ShapeBaseConvex() :pShapeBase(NULL), transform(NULL), hullId(NULL), nodeTransform(0) { mType = ShapeBaseConvexType; } ShapeBaseConvex(const ShapeBaseConvex& cv) { mObject = cv.mObject; pShapeBase = cv.pShapeBase; diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index a12be19c2..8293b24a0 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -134,6 +134,8 @@ ShapeBaseImageData::StateData::StateData() recoil = NoRecoil; sound = 0; emitter = NULL; + shapeSequence = NULL; + shapeSequenceScale = true; script = 0; ignoreLoadedForReady = false; @@ -1396,6 +1398,7 @@ ShapeBase::MountedImage::MountedImage() dataBlock = 0; nextImage = InvalidImagePtr; delayTime = 0; + rDT = 0.0f; ammo = false; target = false; triggerDown = false; @@ -1408,6 +1411,7 @@ ShapeBase::MountedImage::MountedImage() motion = false; lightStart = 0; lightInfo = NULL; + dMemset(emitter, 0, sizeof(emitter)); for (U32 i=0; iinsert("Core_Rendering:noShape")) { ts->mShapeName = data; + ts->mShapeAssetId = StringTable->EmptyString(); + return true; } + else + { + ts->mShapeAssetId = assetId; + ts->mShapeName = StringTable->EmptyString(); - return false; + return false; + } } } else @@ -295,7 +302,7 @@ bool TSStatic::_setShapeName(void* obj, const char* index, const char* data) ts->mShapeAsset = StringTable->EmptyString(); } - return false; + return true; } bool TSStatic::_setFieldSkin(void* object, const char* index, const char* data) @@ -1486,7 +1493,7 @@ void TSStaticPolysoupConvex::getPolyList(AbstractPolyList* list) void TSStaticPolysoupConvex::getFeatures(const MatrixF& mat, const VectorF& n, ConvexFeature* cf) { cf->material = 0; - cf->object = mObject; + cf->mObject = mObject; // For a tetrahedron this is pretty easy... first // convert everything into world space. diff --git a/Engine/source/T3D/turret/aiTurretShape.cpp b/Engine/source/T3D/turret/aiTurretShape.cpp index d4bbd70eb..b607bc974 100644 --- a/Engine/source/T3D/turret/aiTurretShape.cpp +++ b/Engine/source/T3D/turret/aiTurretShape.cpp @@ -119,6 +119,7 @@ AITurretShapeData::AITurretShapeData() } isAnimated = false; statesLoaded = false; + fireState = -1; } void AITurretShapeData::initPersistFields() diff --git a/Engine/source/T3D/turret/turretShape.cpp b/Engine/source/T3D/turret/turretShape.cpp index a7033817c..80bdd1d03 100644 --- a/Engine/source/T3D/turret/turretShape.cpp +++ b/Engine/source/T3D/turret/turretShape.cpp @@ -114,17 +114,21 @@ TurretShapeData::TurretShapeData() headingNode = -1; pitchNode = -1; - - for (U32 i=0; ideleteObject(); } -} \ No newline at end of file +} diff --git a/Engine/source/Verve/VActor/VActorPhysicsController.cpp b/Engine/source/Verve/VActor/VActorPhysicsController.cpp index 5e3332d59..326626015 100644 --- a/Engine/source/Verve/VActor/VActorPhysicsController.cpp +++ b/Engine/source/Verve/VActor/VActorPhysicsController.cpp @@ -49,7 +49,8 @@ VActorPhysicsController::VActorPhysicsController( void ) : mControlState( k_NullControlState ), mMoveState( k_NullMove ), mVelocity( VectorF::Zero ), - mGravity( 0.f, 0.f, -9.8f ) + mGravity( 0.f, 0.f, -9.8f ), + mOnGround(false) { // Void. } @@ -1274,4 +1275,4 @@ void VActorPhysicsController::unpackUpdate( NetConnection *pConnection, BitStrea // Apply. setPosition( position ); } -} \ No newline at end of file +} diff --git a/Engine/source/Verve/VPath/VPathEditor.h b/Engine/source/Verve/VPath/VPathEditor.h index c337edd0c..69c925bd5 100644 --- a/Engine/source/Verve/VPath/VPathEditor.h +++ b/Engine/source/Verve/VPath/VPathEditor.h @@ -199,7 +199,7 @@ private: public: VPathEditorEditPathAction( const UTF8 *pName = "" ) : - UndoAction( pName ) + UndoAction( pName ), mEditor(NULL), mPath(NULL) { // Void. }; @@ -218,9 +218,11 @@ private: public: VPathEditorEditNodeAction( const UTF8 *pName = "" ) : - UndoAction( pName ) + UndoAction( pName ), mEditor(NULL), mPath(NULL), mNodeIndex(0), mNodeWeight(0.0f) { // Void. + mNodeOrientation.Type = VPathNode::k_OrientationFree; + mNodeOrientation.Point = Point3F(0.0f, 0.0f, 0.0f); }; VPathEditor *mEditor; @@ -290,4 +292,4 @@ namespace Utility //----------------------------------------------------------------------------- -#endif // _VT_VPATHEDITOR_H_ \ No newline at end of file +#endif // _VT_VPATHEDITOR_H_ diff --git a/Engine/source/afx/afxCamera.h b/Engine/source/afx/afxCamera.h index 957f182f6..e04afaa13 100644 --- a/Engine/source/afx/afxCamera.h +++ b/Engine/source/afx/afxCamera.h @@ -147,8 +147,6 @@ public: DECLARE_CATEGORY("AFX"); private: // 3POV SECTION - U32 mBlockers_mask_3pov; - void cam_update_3pov(F32 dt, bool on_server); bool avoid_blocked_view(const Point3F& start, const Point3F& end, Point3F& newpos); bool test_blocked_line(const Point3F& start, const Point3F& end); diff --git a/Engine/source/afx/afxConstraint.cpp b/Engine/source/afx/afxConstraint.cpp index a739148f5..e2d4e0321 100644 --- a/Engine/source/afx/afxConstraint.cpp +++ b/Engine/source/afx/afxConstraint.cpp @@ -1904,6 +1904,9 @@ afxEffectConstraint::afxEffectConstraint(afxConstraintMgr* mgr) { mEffect_name = ST_NULLSTRING; mEffect = 0; + mClip_tag = 0; + mIs_death_clip = false; + mLock_tag = 0; } afxEffectConstraint::afxEffectConstraint(afxConstraintMgr* mgr, StringTableEntry effect_name) @@ -1911,6 +1914,9 @@ afxEffectConstraint::afxEffectConstraint(afxConstraintMgr* mgr, StringTableEntry { mEffect_name = effect_name; mEffect = 0; + mClip_tag = 0; + mIs_death_clip = false; + mLock_tag = 0; } afxEffectConstraint::~afxEffectConstraint() diff --git a/Engine/source/afx/afxEffectVector.cpp b/Engine/source/afx/afxEffectVector.cpp index 5de0a5e40..a364a2688 100644 --- a/Engine/source/afx/afxEffectVector.cpp +++ b/Engine/source/afx/afxEffectVector.cpp @@ -98,6 +98,7 @@ afxEffectVector::afxEffectVector() mOn_server = false; mTotal_fx_dur = 0; mAfter_life = 0; + mPhrase_dur = 0; } afxEffectVector::~afxEffectVector() diff --git a/Engine/source/afx/afxEffectWrapper.h b/Engine/source/afx/afxEffectWrapper.h index 79459f76f..37a0e9fcb 100644 --- a/Engine/source/afx/afxEffectWrapper.h +++ b/Engine/source/afx/afxEffectWrapper.h @@ -298,8 +298,6 @@ protected: bool mIn_scope; bool mIs_aborted; - U8 mEffect_flags; - afxXM_Base* mXfm_modifiers[MAX_XFM_MODIFIERS]; F32 mLive_scale_factor; diff --git a/Engine/source/afx/afxMagicMissile.cpp b/Engine/source/afx/afxMagicMissile.cpp index 87d919510..2c4d9e64d 100644 --- a/Engine/source/afx/afxMagicMissile.cpp +++ b/Engine/source/afx/afxMagicMissile.cpp @@ -168,13 +168,14 @@ afxMagicMissileData::afxMagicMissileData() impactForce = 0.0f; armingDelay = 0; - fadeDelay = 20000 / 32; - lifetime = 20000 / 32; activateSeq = -1; maintainSeq = -1; */ + lifetime = 20000 / 32; + fadeDelay = 20000 / 32; + gravityMod = 1.0; /* From stock Projectile code... bounceElasticity = 0.999f; diff --git a/Engine/source/afx/afxZodiacGroundPlaneRenderer_T3D.cpp b/Engine/source/afx/afxZodiacGroundPlaneRenderer_T3D.cpp index 442751a1f..0e1ad2a71 100644 --- a/Engine/source/afx/afxZodiacGroundPlaneRenderer_T3D.cpp +++ b/Engine/source/afx/afxZodiacGroundPlaneRenderer_T3D.cpp @@ -58,6 +58,10 @@ afxZodiacGroundPlaneRenderer::afxZodiacGroundPlaneRenderer() if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacGroundPlaneRenderer::afxZodiacGroundPlaneRenderer(F32 renderOrder, F32 processAddOrder) @@ -66,6 +70,10 @@ afxZodiacGroundPlaneRenderer::afxZodiacGroundPlaneRenderer(F32 renderOrder, F32 if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacGroundPlaneRenderer::~afxZodiacGroundPlaneRenderer() diff --git a/Engine/source/afx/afxZodiacMeshRoadRenderer_T3D.cpp b/Engine/source/afx/afxZodiacMeshRoadRenderer_T3D.cpp index cafb3dca7..30af55b02 100644 --- a/Engine/source/afx/afxZodiacMeshRoadRenderer_T3D.cpp +++ b/Engine/source/afx/afxZodiacMeshRoadRenderer_T3D.cpp @@ -58,6 +58,10 @@ afxZodiacMeshRoadRenderer::afxZodiacMeshRoadRenderer() if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacMeshRoadRenderer::afxZodiacMeshRoadRenderer(F32 renderOrder, F32 processAddOrder) @@ -66,6 +70,10 @@ afxZodiacMeshRoadRenderer::afxZodiacMeshRoadRenderer(F32 renderOrder, F32 proces if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacMeshRoadRenderer::~afxZodiacMeshRoadRenderer() diff --git a/Engine/source/afx/afxZodiacPolysoupRenderer_T3D.cpp b/Engine/source/afx/afxZodiacPolysoupRenderer_T3D.cpp index 84d55a092..63e17b12e 100644 --- a/Engine/source/afx/afxZodiacPolysoupRenderer_T3D.cpp +++ b/Engine/source/afx/afxZodiacPolysoupRenderer_T3D.cpp @@ -58,6 +58,10 @@ afxZodiacPolysoupRenderer::afxZodiacPolysoupRenderer() if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacPolysoupRenderer::afxZodiacPolysoupRenderer(F32 renderOrder, F32 processAddOrder) @@ -66,6 +70,10 @@ afxZodiacPolysoupRenderer::afxZodiacPolysoupRenderer(F32 renderOrder, F32 proces if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacPolysoupRenderer::~afxZodiacPolysoupRenderer() diff --git a/Engine/source/afx/afxZodiacTerrainRenderer_T3D.cpp b/Engine/source/afx/afxZodiacTerrainRenderer_T3D.cpp index 651a0fad0..aafc17020 100644 --- a/Engine/source/afx/afxZodiacTerrainRenderer_T3D.cpp +++ b/Engine/source/afx/afxZodiacTerrainRenderer_T3D.cpp @@ -68,6 +68,10 @@ afxZodiacTerrainRenderer::afxZodiacTerrainRenderer() if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacTerrainRenderer::afxZodiacTerrainRenderer(F32 renderOrder, F32 processAddOrder) @@ -76,6 +80,10 @@ afxZodiacTerrainRenderer::afxZodiacTerrainRenderer(F32 renderOrder, F32 processA if (!master) master = this; shader_initialized = false; + zodiac_shader = NULL; + shader_consts = NULL; + projection_sc = NULL; + color_sc = NULL; } afxZodiacTerrainRenderer::~afxZodiacTerrainRenderer() diff --git a/Engine/source/afx/ce/afxModel.cpp b/Engine/source/afx/ce/afxModel.cpp index 6962aea51..95a190deb 100644 --- a/Engine/source/afx/ce/afxModel.cpp +++ b/Engine/source/afx/ce/afxModel.cpp @@ -105,6 +105,11 @@ afxModelData::afxModelData(const afxModelData& other, bool temp_clone) : GameBas customAmbientForSelfIllumination = other.customAmbientForSelfIllumination; customAmbientLighting = other.customAmbientLighting; shadowEnable = other.shadowEnable; + + shadowSize = other.shadowSize; + shadowMaxVisibleDistance = other.shadowMaxVisibleDistance; + shadowProjectionDistance = other.shadowProjectionDistance; + shadowSphereAdjust = other.shadowSphereAdjust; } afxModelData::~afxModelData() @@ -360,7 +365,7 @@ afxModel::afxModel() fade_amt = 1.0f; is_visible = true; sort_priority = 0; - + mDataBlock = NULL; mNetFlags.set( IsGhost ); } diff --git a/Engine/source/afx/ce/afxMooring.cpp b/Engine/source/afx/ce/afxMooring.cpp index b9cda9ec7..9adf47526 100644 --- a/Engine/source/afx/ce/afxMooring.cpp +++ b/Engine/source/afx/ce/afxMooring.cpp @@ -133,6 +133,7 @@ afxMooring::afxMooring() chor_id = 0; hookup_with_chor = false; ghost_cons_name = ST_NULLSTRING; + mDataBlock = NULL; } afxMooring::afxMooring(U32 networking, U32 chor_id, StringTableEntry cons_name) @@ -160,6 +161,7 @@ afxMooring::afxMooring(U32 networking, U32 chor_id, StringTableEntry cons_name) this->chor_id = chor_id; hookup_with_chor = false; this->ghost_cons_name = cons_name; + mDataBlock = NULL; } afxMooring::~afxMooring() @@ -275,4 +277,4 @@ void afxMooring::onRemove() Parent::onRemove(); } -//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// \ No newline at end of file +//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// diff --git a/Engine/source/afx/ce/afxParticleEmitter.cpp b/Engine/source/afx/ce/afxParticleEmitter.cpp index 1d76b2475..c34bd5510 100644 --- a/Engine/source/afx/ce/afxParticleEmitter.cpp +++ b/Engine/source/afx/ce/afxParticleEmitter.cpp @@ -687,6 +687,7 @@ bool afxParticleEmitterDiscData::preload(bool server, String &errorStr) afxParticleEmitter::afxParticleEmitter() { + mDataBlock = NULL; pe_vector.set(0,0,1); pe_vector_norm.set(0,0,1); tpaths.clear(); @@ -1086,6 +1087,7 @@ void afxParticleEmitter::emitParticlesExt(const MatrixF& xfm, const Point3F& poi afxParticleEmitterVector::afxParticleEmitterVector() { + mDataBlock = NULL; } afxParticleEmitterVector::~afxParticleEmitterVector() @@ -1151,6 +1153,7 @@ void afxParticleEmitterVector::sub_preCompute(const MatrixF& mat) afxParticleEmitterCone::afxParticleEmitterCone() { + mDataBlock = NULL; cone_v.set(0,0,1); cone_s0.set(0,0,1); cone_s1.set(0,0,1); @@ -1266,6 +1269,7 @@ void afxParticleEmitterCone::sub_preCompute(const MatrixF& mat) afxParticleEmitterPath::afxParticleEmitterPath() { + mDataBlock = NULL; epaths.clear(); epath_mults.clear(); n_epath_points = 0; @@ -1521,6 +1525,7 @@ void afxParticleEmitterPath::groundConformPoint(Point3F& point, const MatrixF& m afxParticleEmitterDisc::afxParticleEmitterDisc() { + mDataBlock = NULL; disc_v.set(0,0,1); disc_r.set(1,0,0); } diff --git a/Engine/source/afx/ce/afxStaticShape.cpp b/Engine/source/afx/ce/afxStaticShape.cpp index 4bef19629..ffe731b55 100644 --- a/Engine/source/afx/ce/afxStaticShape.cpp +++ b/Engine/source/afx/ce/afxStaticShape.cpp @@ -122,6 +122,7 @@ ConsoleDocClass( afxStaticShape, afxStaticShape::afxStaticShape() { + mDataBlock = NULL; mAFX_data = 0; mIs_visible = true; mChor_id = 0; @@ -238,4 +239,4 @@ void afxStaticShape::prepRenderImage(SceneRenderState* state) Parent::prepRenderImage(state); } -//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// \ No newline at end of file +//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// diff --git a/Engine/source/afx/ce/afxZodiac.cpp b/Engine/source/afx/ce/afxZodiac.cpp index 3b1e976d2..62f6996ae 100644 --- a/Engine/source/afx/ce/afxZodiac.cpp +++ b/Engine/source/afx/ce/afxZodiac.cpp @@ -114,6 +114,7 @@ afxZodiacData::afxZodiacData() grade_range_user.set(0.0f, 45.0f); afxZodiacData::convertGradientRangeFromDegrees(grade_range, grade_range_user); inv_grade_range = false; + zflags = 0; } afxZodiacData::afxZodiacData(const afxZodiacData& other, bool temp_clone) : GameBaseData(other, temp_clone) diff --git a/Engine/source/afx/ce/afxZodiacPlane.cpp b/Engine/source/afx/ce/afxZodiacPlane.cpp index 2a4740298..7af581f2f 100644 --- a/Engine/source/afx/ce/afxZodiacPlane.cpp +++ b/Engine/source/afx/ce/afxZodiacPlane.cpp @@ -61,7 +61,7 @@ afxZodiacPlaneData::afxZodiacPlaneData() color.set(1,1,1,1); blend_flags = BLEND_NORMAL; respect_ori_cons = false; - + zflags = 0; double_sided = true; face_dir = FACES_UP; use_full_xfm = false; @@ -310,4 +310,4 @@ void afxZodiacPlane::onRemove() Parent::onRemove(); } -//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// \ No newline at end of file +//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// diff --git a/Engine/source/afx/ea/afxEA_PhraseEffect.cpp b/Engine/source/afx/ea/afxEA_PhraseEffect.cpp index 1e14d2c6a..84a75ee7e 100644 --- a/Engine/source/afx/ea/afxEA_PhraseEffect.cpp +++ b/Engine/source/afx/ea/afxEA_PhraseEffect.cpp @@ -75,6 +75,7 @@ afxEA_PhraseEffect::afxEA_PhraseEffect() { phrase_fx_data = 0; active_phrases = &_phrases_a; + last_trigger_mask = 0; } afxEA_PhraseEffect::~afxEA_PhraseEffect() diff --git a/Engine/source/afx/forces/afxF_Drag.cpp b/Engine/source/afx/forces/afxF_Drag.cpp index 7fb52deb1..f006fc2ad 100644 --- a/Engine/source/afx/forces/afxF_Drag.cpp +++ b/Engine/source/afx/forces/afxF_Drag.cpp @@ -60,7 +60,7 @@ class afxF_Drag : public afxForce typedef afxForce Parent; private: - afxF_DragData* datablock; + afxF_DragData* mDatablock; F32 air_friction_constant; public: @@ -149,13 +149,14 @@ afxForceData* afxF_DragData::cloneAndPerformSubstitutions(const SimObject* owner afxF_Drag::afxF_Drag() : afxForce() { + mDatablock = NULL; air_friction_constant = 1.0f; } bool afxF_Drag::onNewDataBlock(afxForceData* dptr, bool reload) { - datablock = dynamic_cast(dptr); - if (!datablock || !Parent::onNewDataBlock(dptr, reload)) + mDatablock = dynamic_cast(dptr); + if (!mDatablock || !Parent::onNewDataBlock(dptr, reload)) return false; return true; @@ -163,9 +164,9 @@ bool afxF_Drag::onNewDataBlock(afxForceData* dptr, bool reload) void afxF_Drag::start() { - air_friction_constant = 0.5f * datablock->drag_coefficient - * datablock->air_density - * datablock->cross_sectional_area; + air_friction_constant = 0.5f * mDatablock->drag_coefficient + * mDatablock->air_density + * mDatablock->cross_sectional_area; //Con::printf("Air Friction: %f", air_friction_constant); } diff --git a/Engine/source/afx/forces/afxF_Gravity.cpp b/Engine/source/afx/forces/afxF_Gravity.cpp index fc5ed1d80..cbe9e6ad2 100644 --- a/Engine/source/afx/forces/afxF_Gravity.cpp +++ b/Engine/source/afx/forces/afxF_Gravity.cpp @@ -58,7 +58,7 @@ class afxF_Gravity : public afxForce typedef afxForce Parent; private: - afxF_GravityData* datablock; + afxF_GravityData* mDatablock; public: /*C*/ afxF_Gravity(); @@ -133,12 +133,13 @@ afxForceData* afxF_GravityData::cloneAndPerformSubstitutions(const SimObject* ow afxF_Gravity::afxF_Gravity() : afxForce() { + mDatablock = NULL; } bool afxF_Gravity::onNewDataBlock(afxForceData* dptr, bool reload) { - datablock = dynamic_cast(dptr); - if (!datablock || !Parent::onNewDataBlock(dptr, reload)) + mDatablock = dynamic_cast(dptr); + if (!mDatablock || !Parent::onNewDataBlock(dptr, reload)) return false; return true; @@ -146,7 +147,7 @@ bool afxF_Gravity::onNewDataBlock(afxForceData* dptr, bool reload) Point3F afxF_Gravity::evaluate(Point3F pos, Point3F v, F32 mass) { - return Point3F(0,0,-datablock->gravity)*mass; + return Point3F(0,0,-mDatablock->gravity)*mass; } diff --git a/Engine/source/afx/util/afxAnimCurve.cpp b/Engine/source/afx/util/afxAnimCurve.cpp index 4074c15d7..2343bf9f8 100644 --- a/Engine/source/afx/util/afxAnimCurve.cpp +++ b/Engine/source/afx/util/afxAnimCurve.cpp @@ -29,6 +29,8 @@ afxAnimCurve::afxAnimCurve() : usable( false ), final_value( 0.0f ), start_value( 0.0f ) { evaluator = new afxHermiteEval(); + final_time = 0.0f; + start_time = 0.0f; } afxAnimCurve::~afxAnimCurve() @@ -277,4 +279,4 @@ void afxAnimCurve::printKey( int index ) { Key &k = keys[index]; Con::printf( "%f: %f", k.time, k.value ); -} \ No newline at end of file +} diff --git a/Engine/source/afx/util/afxCurve3D.cpp b/Engine/source/afx/util/afxCurve3D.cpp index 860cb4c4a..798cf71f4 100644 --- a/Engine/source/afx/util/afxCurve3D.cpp +++ b/Engine/source/afx/util/afxCurve3D.cpp @@ -27,7 +27,7 @@ #include "afx/util/afxCurveEval.h" #include "afx/util/afxCurve3D.h" -afxCurve3D::afxCurve3D() : usable( false ), default_vector( 0, 0, 0 ) +afxCurve3D::afxCurve3D() : usable( false ), default_vector( 0, 0, 0 ), flip(false) { evaluator = new afxHermiteEval(); } @@ -329,4 +329,4 @@ void afxCurve3D::print() Con::printf( "%f: %f %f %f", p.parameter, p.point.x, p.point.y, p.point.z ); } Con::printf( "---------------------------------" ); -} \ No newline at end of file +} diff --git a/Engine/source/afx/util/afxPath3D.cpp b/Engine/source/afx/util/afxPath3D.cpp index 5997bdc12..c82717ee0 100644 --- a/Engine/source/afx/util/afxPath3D.cpp +++ b/Engine/source/afx/util/afxPath3D.cpp @@ -29,7 +29,7 @@ #include "afx/util/afxPath3D.h" -afxPath3D::afxPath3D() : mStart_time(0), mNum_points(0), mLoop_type(LOOP_CONSTANT) +afxPath3D::afxPath3D() : mStart_time(0), mNum_points(0), mLoop_type(LOOP_CONSTANT), mEnd_time(0.0f) { } diff --git a/Engine/source/app/net/httpObject.cpp b/Engine/source/app/net/httpObject.cpp index 6d815ad35..b3d26b6f4 100644 --- a/Engine/source/app/net/httpObject.cpp +++ b/Engine/source/app/net/httpObject.cpp @@ -114,12 +114,22 @@ ConsoleDocClass( HTTPObject, //-------------------------------------- HTTPObject::HTTPObject() + : mParseState(ParsingStatusLine), + mTotalBytes(0), + mBytesRemaining(0), + mStatus(0), + mVersion(0.0f), + mContentLength(0), + mChunkedEncoding(false), + mChunkSize(0), + mContentType(""), + mHostName(NULL), + mPath(NULL), + mQuery(NULL), + mPost(NULL), + mBufferSave(NULL), + mBufferSaveSize(0) { - mHostName = 0; - mPath = 0; - mQuery = 0; - mPost = 0; - mBufferSave = 0; } HTTPObject::~HTTPObject() diff --git a/Engine/source/app/net/serverQuery.h b/Engine/source/app/net/serverQuery.h index bfa5b7381..fcdcaa6c1 100644 --- a/Engine/source/app/net/serverQuery.h +++ b/Engine/source/app/net/serverQuery.h @@ -80,6 +80,7 @@ struct ServerInfo statusString = NULL; infoString = NULL; version = 0; + dMemset(&address, '\0', sizeof(NetAddress)); ping = 0; cpuSpeed = 0; isFavorite = false; diff --git a/Engine/source/collision/boxConvex.cpp b/Engine/source/collision/boxConvex.cpp index 298fc50bb..2bd80ba44 100644 --- a/Engine/source/collision/boxConvex.cpp +++ b/Engine/source/collision/boxConvex.cpp @@ -85,7 +85,7 @@ inline bool isOnPlane(const Point3F& p,PlaneF& plane) void BoxConvex::getFeatures(const MatrixF& mat,const VectorF& n, ConvexFeature* cf) { cf->material = 0; - cf->object = mObject; + cf->mObject = mObject; S32 v = 0; v += (n.x >= 0)? 1: 0; diff --git a/Engine/source/collision/clippedPolyList.h b/Engine/source/collision/clippedPolyList.h index affce3401..c9ebcc932 100644 --- a/Engine/source/collision/clippedPolyList.h +++ b/Engine/source/collision/clippedPolyList.h @@ -49,7 +49,7 @@ class ClippedPolyList : public AbstractPolyList public: struct Vertex { Point3F point; - U32 mask; + U32 mask = 0; }; struct Poly { @@ -61,6 +61,8 @@ public: U32 vertexCount; U32 surfaceKey; U32 polyFlags; + Poly() :object(NULL), material(NULL), vertexStart(0), vertexCount(0), surfaceKey(0), polyFlags(0) {} + ~Poly() {} }; /// ??? diff --git a/Engine/source/collision/collision.h b/Engine/source/collision/collision.h index 8dec9791c..e5134c1a7 100644 --- a/Engine/source/collision/collision.h +++ b/Engine/source/collision/collision.h @@ -65,7 +65,11 @@ struct Collision object( NULL ), material( NULL ), generateTexCoord(false), - texCoord(-1.0f, -1.0f) + texCoord(-1.0f, -1.0f), + face(0), + faceDot(0.0f), + distance(0) + { } }; diff --git a/Engine/source/collision/concretePolyList.h b/Engine/source/collision/concretePolyList.h index adb23688e..482ff3ee0 100644 --- a/Engine/source/collision/concretePolyList.h +++ b/Engine/source/collision/concretePolyList.h @@ -48,6 +48,9 @@ class ConcretePolyList : public AbstractPolyList Poly() { + vertexStart = 0; + vertexCount = 0; + surfaceKey = 0; object = NULL; material = NULL; } diff --git a/Engine/source/collision/convex.cpp b/Engine/source/collision/convex.cpp index 01583c9f0..b818ffa6d 100644 --- a/Engine/source/collision/convex.cpp +++ b/Engine/source/collision/convex.cpp @@ -52,7 +52,9 @@ F32 sqrDistanceEdges(const Point3F& start0, CollisionState::CollisionState() { - mLista = mListb = 0; + mB = mA = NULL; + mDist = 0.0f; + mListb = mLista = 0; } CollisionState::~CollisionState() @@ -85,7 +87,7 @@ F32 CollisionState::distance(const MatrixF& a2w, const MatrixF& b2w, const F32 d void ConvexFeature::reset() { material = NULL; - object = NULL; + mObject = NULL; mVertexList.clear(); mEdgeList.clear(); mFaceList.clear(); @@ -114,7 +116,7 @@ bool ConvexFeature::collide(ConvexFeature& cf,CollisionList* cList, F32 tol) { Collision &col = (*cList)[cList->getCount() - 1]; col.material = cf.material; - col.object = cf.object; + col.object = cf.mObject; } vert++; } @@ -167,7 +169,7 @@ void ConvexFeature::testVertex(const Point3F& v,CollisionList* cList,bool flip, if (flip) info.normal.neg(); info.material = material; - info.object = object; + info.object = mObject; info.distance = distance; } } @@ -213,7 +215,7 @@ void ConvexFeature::testEdge(ConvexFeature* cf,const Point3F& s1, const Point3F& info.normal = normal; info.distance = distance; info.material = material; - info.object = object; + info.object = mObject; } } @@ -282,6 +284,7 @@ CollisionWorkingList::CollisionWorkingList() { wLink.mPrev = wLink.mNext = this; rLink.mPrev = rLink.mNext = this; + mConvex = NULL; } void CollisionWorkingList::wLinkAfter(CollisionWorkingList* ptr) @@ -340,6 +343,8 @@ Convex::Convex() { mNext = mPrev = this; mTag = 0; + mObject = NULL; + mType = ConvexType::BoxConvexType; } Convex::~Convex() @@ -418,7 +423,7 @@ Point3F Convex::support(const VectorF&) const void Convex::getFeatures(const MatrixF&,const VectorF&,ConvexFeature* f) { - f->object = NULL; + f->mObject = NULL; } const MatrixF& Convex::getTransform() const diff --git a/Engine/source/collision/convex.h b/Engine/source/collision/convex.h index fa6106f83..6ad33b2b5 100644 --- a/Engine/source/collision/convex.h +++ b/Engine/source/collision/convex.h @@ -56,10 +56,10 @@ public: Vector mEdgeList; Vector mFaceList; BaseMatInstance* material; - SceneObject* object; + SceneObject* mObject; ConvexFeature() - : mVertexList(64), mEdgeList(128), mFaceList(64), material( 0 ) + : mVertexList(64), mEdgeList(128), mFaceList(64), material( 0 ), mObject(NULL) { VECTOR_SET_ASSOCIATION(mVertexList); VECTOR_SET_ASSOCIATION(mEdgeList); diff --git a/Engine/source/collision/depthSortList.cpp b/Engine/source/collision/depthSortList.cpp index 2ead81479..7d5e0e337 100644 --- a/Engine/source/collision/depthSortList.cpp +++ b/Engine/source/collision/depthSortList.cpp @@ -46,6 +46,13 @@ S32 gBadSpots = 0; DepthSortList::DepthSortList() { + mBase = 0; + mBasePoly = NULL; + mBaseNormal = NULL; + mBaseDot = 0.0f; + mBaseYMax = 0.0f; + mMaxTouched = 0; + mBaseExtents = NULL; VECTOR_SET_ASSOCIATION(mPolyExtentsList); VECTOR_SET_ASSOCIATION(mPolyIndexList); } diff --git a/Engine/source/collision/extrudedPolyList.cpp b/Engine/source/collision/extrudedPolyList.cpp index 24de5af29..3c2fc0777 100644 --- a/Engine/source/collision/extrudedPolyList.cpp +++ b/Engine/source/collision/extrudedPolyList.cpp @@ -47,6 +47,7 @@ ExtrudedPolyList::ExtrudedPolyList() mPolyPlaneList.reserve(64); mPlaneList.reserve(64); mCollisionList = 0; + dMemset(&mPoly, 0, sizeof(mPoly)); } ExtrudedPolyList::~ExtrudedPolyList() diff --git a/Engine/source/collision/extrudedPolyList.h b/Engine/source/collision/extrudedPolyList.h index a802e3eba..cea6a76ef 100644 --- a/Engine/source/collision/extrudedPolyList.h +++ b/Engine/source/collision/extrudedPolyList.h @@ -56,13 +56,15 @@ class ExtrudedPolyList: public AbstractPolyList public: struct Vertex { Point3F point; - U32 mask; + U32 mask = 0; }; struct Poly { PlaneF plane; SceneObject* object; BaseMatInstance* material; + Poly() : object(NULL), material(NULL) {} + ~Poly() {} }; struct ExtrudedFace { @@ -75,6 +77,8 @@ public: F32 time; Point3F point; F32 height; + ExtrudedFace(): active(false), maxDistance(0.0f), planeMask(0), faceDot(0.0f), faceShift(0.0f), time(0.0f), height(0.0f) {} + ~ExtrudedFace() {} }; typedef Vector ExtrudedList; @@ -92,7 +96,6 @@ public: PlaneList mPlaneList; VectorF mVelocity; VectorF mNormalVelocity; - F32 mFaceShift; Poly mPoly; // Returned info diff --git a/Engine/source/collision/gjk.cpp b/Engine/source/collision/gjk.cpp index e9debee81..f07fade8e 100644 --- a/Engine/source/collision/gjk.cpp +++ b/Engine/source/collision/gjk.cpp @@ -46,6 +46,19 @@ S32 num_irregularities = 0; GjkCollisionState::GjkCollisionState() { + mBits = 0; + mAll_bits = 0; + U32 x, y; + for (x = 0; x < 16; x++) + for (y = 0; y < 4; y++) + mDet[x][y] = 0.0f; + + for (x = 0; x < 4; x++) + for (y = 0; y < 4; y++) + mDP[x][y] = 0.0f; + + mLast = 0; + mLast_bit = 0; mA = mB = 0; } diff --git a/Engine/source/collision/optimizedPolyList.h b/Engine/source/collision/optimizedPolyList.h index d8cac8df3..b66cc76c0 100644 --- a/Engine/source/collision/optimizedPolyList.h +++ b/Engine/source/collision/optimizedPolyList.h @@ -88,7 +88,9 @@ class OptimizedPolyList : public AbstractPolyList Poly() : plane( -1 ), material( NULL ), + vertexStart(0), vertexCount( 0 ), + surfaceKey(0), object( NULL ), type( TriangleFan ) { diff --git a/Engine/source/collision/planeExtractor.cpp b/Engine/source/collision/planeExtractor.cpp index f4e9ffdbb..91458e81c 100644 --- a/Engine/source/collision/planeExtractor.cpp +++ b/Engine/source/collision/planeExtractor.cpp @@ -37,6 +37,7 @@ PlaneExtractorPolyList::PlaneExtractorPolyList() { VECTOR_SET_ASSOCIATION(mVertexList); VECTOR_SET_ASSOCIATION(mPolyPlaneList); + mPlaneList = NULL; } PlaneExtractorPolyList::~PlaneExtractorPolyList() diff --git a/Engine/source/collision/polytope.h b/Engine/source/collision/polytope.h index c96a54979..347a85c70 100644 --- a/Engine/source/collision/polytope.h +++ b/Engine/source/collision/polytope.h @@ -76,6 +76,7 @@ public: Collision() { object = NULL; + material = NULL; distance = 0.0; } }; diff --git a/Engine/source/console/astNodes.cpp b/Engine/source/console/astNodes.cpp index 876a4383a..51bde9d61 100644 --- a/Engine/source/console/astNodes.cpp +++ b/Engine/source/console/astNodes.cpp @@ -142,6 +142,7 @@ StmtNode::StmtNode() { mNext = NULL; dbgFileName = CodeBlock::smCurrentParser->getCurrentFile(); + dbgLineNumber = 0; } void StmtNode::setPackage(StringTableEntry) diff --git a/Engine/source/console/codeBlock.cpp b/Engine/source/console/codeBlock.cpp index f414d7473..b4dd6b2c6 100644 --- a/Engine/source/console/codeBlock.cpp +++ b/Engine/source/console/codeBlock.cpp @@ -56,6 +56,9 @@ CodeBlock::CodeBlock() name = NULL; fullPath = NULL; modPath = NULL; + codeSize = 0; + lineBreakPairCount = 0; + nextFile = NULL; } CodeBlock::~CodeBlock() diff --git a/Engine/source/console/codeInterpreter.cpp b/Engine/source/console/codeInterpreter.cpp index 186354869..838e105ef 100644 --- a/Engine/source/console/codeInterpreter.cpp +++ b/Engine/source/console/codeInterpreter.cpp @@ -224,6 +224,9 @@ CodeInterpreter::CodeInterpreter(CodeBlock *cb) : mSaveCodeBlock(nullptr), mCurrentInstruction(0) { + dMemset(&mExec, 0, sizeof(mExec)); + dMemset(&mObjectCreationStack, 0, sizeof(mObjectCreationStack)); + dMemset(&mNSDocBlockClass, 0, sizeof(mNSDocBlockClass)); } CodeInterpreter::~CodeInterpreter() diff --git a/Engine/source/console/compiler.h b/Engine/source/console/compiler.h index df69d0819..26dc93c13 100644 --- a/Engine/source/console/compiler.h +++ b/Engine/source/console/compiler.h @@ -317,7 +317,7 @@ protected: U32 addr; ///< Address to patch U32 value; ///< Value to place at addr - PatchEntry() { ; } + PatchEntry(): addr(0), value(0) { ; } PatchEntry(U32 a, U32 v) : addr(a), value(v) { ; } } PatchEntry; diff --git a/Engine/source/console/consoleInternal.cpp b/Engine/source/console/consoleInternal.cpp index 61a63ae1e..d3d838f05 100644 --- a/Engine/source/console/consoleInternal.cpp +++ b/Engine/source/console/consoleInternal.cpp @@ -475,7 +475,7 @@ Dictionary::Entry::Entry(StringTableEntry in_name) nextEntry = NULL; mUsage = NULL; mIsConstant = false; - + mNext = NULL; // NOTE: This is data inside a nameless // union, so we don't need to init the rest. value.init(); @@ -856,6 +856,7 @@ ExprEvalState::ExprEvalState() stack.reserve(64); mShouldReset = false; mResetLocked = false; + copyVariable = NULL; } ExprEvalState::~ExprEvalState() @@ -927,6 +928,15 @@ Namespace::Entry::Entry() mUsage = NULL; mHeader = NULL; mNamespace = NULL; + cb.mStringCallbackFunc = NULL; + mFunctionLineNumber = 0; + mFunctionName = StringTable->EmptyString(); + mFunctionOffset = 0; + mMinArgs = 0; + mMaxArgs = 0; + mNext = NULL; + mPackage = StringTable->EmptyString(); + mToolOnly = false; } void Namespace::Entry::clear() @@ -959,6 +969,7 @@ Namespace::Namespace() mHashSequence = 0; mRefCountToParent = 0; mClassRep = 0; + lastUsage = NULL; } Namespace::~Namespace() diff --git a/Engine/source/console/consoleInternal.h b/Engine/source/console/consoleInternal.h index d673bb39c..129da9dfb 100644 --- a/Engine/source/console/consoleInternal.h +++ b/Engine/source/console/consoleInternal.h @@ -306,6 +306,7 @@ public: nextEntry = NULL; mUsage = NULL; mIsConstant = false; + mNext = NULL; value.init(); } diff --git a/Engine/source/console/consoleObject.h b/Engine/source/console/consoleObject.h index b15cd88ab..784e294ff 100644 --- a/Engine/source/console/consoleObject.h +++ b/Engine/source/console/consoleObject.h @@ -220,7 +220,21 @@ public: : Parent( sizeof( void* ), conIdPtr, typeName ) { VECTOR_SET_ASSOCIATION( mFieldList ); - + mCategory = StringTable->EmptyString(); + mClassGroupMask = 0; + std::fill_n(mClassId, NetClassGroupsCount, -1); + mClassName = StringTable->EmptyString(); + mClassSizeof = 0; + mClassType = 0; + mDescription = StringTable->EmptyString(); +#ifdef TORQUE_NET_STATS + dMemset(mDirtyMaskFrequency, 0, sizeof(mDirtyMaskFrequency)); + dMemset(mDirtyMaskTotal, 0, sizeof(mDirtyMaskTotal)); +#endif + mDynamicGroupExpand = false; + mNamespace = NULL; + mNetEventDir = 0; + nextClass = NULL; parentClass = NULL; mIsRenderEnabled = true; mIsSelectionEnabled = true; @@ -496,6 +510,7 @@ public: validator( NULL ), setDataFn( NULL ), getDataFn( NULL ), + writeDataFn(NULL), networkMask(0) { doNotSubstitute = keepClearSubsOnly = false; diff --git a/Engine/source/console/engineAPI.h b/Engine/source/console/engineAPI.h index 78a469522..5c9d00dd4 100644 --- a/Engine/source/console/engineAPI.h +++ b/Engine/source/console/engineAPI.h @@ -1190,7 +1190,7 @@ public: ConsoleValueRef _exec(); ConsoleValueRef _execLater(SimConsoleThreadExecEvent *evt); - _BaseEngineConsoleCallbackHelper() {;} + _BaseEngineConsoleCallbackHelper(): mThis(NULL), mInitialArgc(0), mArgc(0), mCallbackName(StringTable->EmptyString()){;} }; diff --git a/Engine/source/console/engineExports.h b/Engine/source/console/engineExports.h index 7659eeac9..1303315f8 100644 --- a/Engine/source/console/engineExports.h +++ b/Engine/source/console/engineExports.h @@ -123,6 +123,7 @@ class EngineExport : public StaticEngineObject : mExportName( "" ), mExportKind( EngineExportKindScope ), mExportScope( NULL ), + mDocString(""), mNextExport( NULL ) {} }; @@ -165,7 +166,7 @@ class EngineExportScope : public EngineExport private: /// Constructor for the global scope. - EngineExportScope() {} + EngineExportScope():mExports(NULL){} }; diff --git a/Engine/source/console/engineObject.cpp b/Engine/source/console/engineObject.cpp index f82114388..ff19c1acb 100644 --- a/Engine/source/console/engineObject.cpp +++ b/Engine/source/console/engineObject.cpp @@ -53,7 +53,7 @@ void*& _USERDATA( EngineObject* object ) //----------------------------------------------------------------------------- EngineObject::EngineObject() - : mEngineObjectUserData( NULL ) + : mEngineObjectPool(NULL), mEngineObjectUserData( NULL ) { #ifdef TORQUE_DEBUG // Add to instance list. diff --git a/Engine/source/console/engineTypeInfo.cpp b/Engine/source/console/engineTypeInfo.cpp index e258696d3..14c661c82 100644 --- a/Engine/source/console/engineTypeInfo.cpp +++ b/Engine/source/console/engineTypeInfo.cpp @@ -58,6 +58,7 @@ EngineTypeInfo::EngineTypeInfo( const char* typeName, EngineExportScope* scope, mEnumTable( NULL ), mFieldTable( NULL ), mPropertyTable( NULL ), + mArgumentTypeTable(NULL), mSuperType( NULL ), mNext( smFirst ) { diff --git a/Engine/source/console/simDatablock.cpp b/Engine/source/console/simDatablock.cpp index 7944fb889..ae0fd9c63 100644 --- a/Engine/source/console/simDatablock.cpp +++ b/Engine/source/console/simDatablock.cpp @@ -55,6 +55,7 @@ ConsoleDocClass( SimDataBlock, SimDataBlock::SimDataBlock() { + modifiedKey = 0; setModDynamicFields(true); setModStaticFields(true); } diff --git a/Engine/source/console/simDictionary.cpp b/Engine/source/console/simDictionary.cpp index 4f5aac411..93491fd1c 100644 --- a/Engine/source/console/simDictionary.cpp +++ b/Engine/source/console/simDictionary.cpp @@ -31,6 +31,8 @@ SimNameDictionary::SimNameDictionary() { #ifndef USE_NEW_SIMDICTIONARY hashTable = NULL; + hashTableSize = DefaultTableSize; + hashEntryCount = 0; #endif mutex = Mutex::createMutex(); } diff --git a/Engine/source/console/simEvents.h b/Engine/source/console/simEvents.h index 362bdb325..861c7cdde 100644 --- a/Engine/source/console/simEvents.h +++ b/Engine/source/console/simEvents.h @@ -62,7 +62,7 @@ public: /// of addition to the list. SimObject *destObject; ///< Object on which this event will be applied. - SimEvent() { destObject = NULL; } + SimEvent() { nextEvent = NULL; startTime = 0; time = 0; sequenceCount = 0; destObject = NULL; } virtual ~SimEvent() {} ///< Destructor /// /// A dummy virtual destructor is required diff --git a/Engine/source/console/simFieldDictionary.h b/Engine/source/console/simFieldDictionary.h index c89bd5b57..9701f2e1d 100644 --- a/Engine/source/console/simFieldDictionary.h +++ b/Engine/source/console/simFieldDictionary.h @@ -47,7 +47,7 @@ class SimFieldDictionary public: struct Entry { - Entry() : type(NULL) {}; + Entry() : slotName(StringTable->EmptyString()), value(NULL), next(NULL), type(NULL) {}; StringTableEntry slotName; char *value; @@ -112,4 +112,4 @@ public: }; -#endif // _SIMFIELDDICTIONARY_H_ \ No newline at end of file +#endif // _SIMFIELDDICTIONARY_H_ diff --git a/Engine/source/console/simObject.cpp b/Engine/source/console/simObject.cpp index 6cf6fd029..be89bfaea 100644 --- a/Engine/source/console/simObject.cpp +++ b/Engine/source/console/simObject.cpp @@ -57,6 +57,8 @@ SimObjectId SimObject::smForcedId = 0; bool SimObject::preventNameChanging = false; +IMPLEMENT_CALLBACK(SimObject, onInspectPostApply, void, (SimObject* obj), (obj), "Generic callback for when an object is edited"); + namespace Sim { // Defined in simManager.cpp @@ -1380,6 +1382,7 @@ SimObject::SimObject(const SimObject& other, bool temp_clone) nextIdObject = other.nextIdObject; mGroup = other.mGroup; mFlags = other.mFlags; + mProgenitorFile = other.mProgenitorFile; mCopySource = other.mCopySource; mFieldDictionary = other.mFieldDictionary; //mIdString = other.mIdString; // special treatment (see below) @@ -2237,6 +2240,7 @@ void SimObject::inspectPreApply() void SimObject::inspectPostApply() { + onInspectPostApply_callback(this); } //----------------------------------------------------------------------------- diff --git a/Engine/source/console/simObject.h b/Engine/source/console/simObject.h index beda61739..102689b41 100644 --- a/Engine/source/console/simObject.h +++ b/Engine/source/console/simObject.h @@ -965,6 +965,7 @@ class SimObject: public ConsoleObject, public TamlCallbacks virtual void getConsoleMethodData(const char * fname, S32 routingId, S32 * type, S32 * minArgs, S32 * maxArgs, void ** callback, const char ** usage) {} DECLARE_CONOBJECT( SimObject ); + DECLARE_CALLBACK(void, onInspectPostApply, (SimObject* obj)); static SimObject* __findObject( const char* id ) { return Sim::findObject( id ); } static const char* __getObjectId( ConsoleObject* object ) diff --git a/Engine/source/console/stringStack.cpp b/Engine/source/console/stringStack.cpp index 7081756c0..96aef1c86 100644 --- a/Engine/source/console/stringStack.cpp +++ b/Engine/source/console/stringStack.cpp @@ -30,7 +30,12 @@ StringStack::StringStack() mBuffer = NULL; mArgBufferSize = 0; mArgBuffer = NULL; + for (U32 i = 0; i < MaxArgs; i++) + mArgV[i] = ""; + dMemset(mFrameOffsets, 0, sizeof(mFrameOffsets)); + dMemset(mStartOffsets, 0, sizeof(mStartOffsets)); mNumFrames = 0; + mArgc = 0; mStart = 0; mLen = 0; mStartStackSize = 0; @@ -232,6 +237,7 @@ mStackPos(0) mStack[i].init(); mStack[i].type = ConsoleValue::TypeInternalString; } + dMemset(mStackFrames, 0, sizeof(mStackFrames)); } ConsoleValueStack::~ConsoleValueStack() diff --git a/Engine/source/console/telnetConsole.cpp b/Engine/source/console/telnetConsole.cpp index 620c669bf..8eaa3b3db 100644 --- a/Engine/source/console/telnetConsole.cpp +++ b/Engine/source/console/telnetConsole.cpp @@ -88,6 +88,9 @@ TelnetConsole::TelnetConsole() mAcceptPort = -1; mClientList = NULL; mRemoteEchoEnabled = false; + + dStrncpy(mTelnetPassword, "", PasswordMaxLength); + dStrncpy(mListenPassword, "", PasswordMaxLength); } TelnetConsole::~TelnetConsole() diff --git a/Engine/source/console/telnetConsole.h b/Engine/source/console/telnetConsole.h index 96677942c..4d848a0b5 100644 --- a/Engine/source/console/telnetConsole.h +++ b/Engine/source/console/telnetConsole.h @@ -78,6 +78,7 @@ class TelnetConsole S32 state; ///< State of the client. /// @see TelnetConsole::State TelnetClient *nextClient; + TelnetClient() { dStrncpy(curLine, "", Con::MaxLineLength); curPos = 0; state = 0; nextClient = NULL; } }; TelnetClient *mClientList; TelnetConsole(); diff --git a/Engine/source/console/telnetDebugger.cpp b/Engine/source/console/telnetDebugger.cpp index 161ed5695..719ed7d32 100644 --- a/Engine/source/console/telnetDebugger.cpp +++ b/Engine/source/console/telnetDebugger.cpp @@ -163,6 +163,9 @@ TelnetDebugger::TelnetDebugger() mProgramPaused = false; mWaitForClient = false; + dStrncpy(mDebuggerPassword, "", PasswordMaxLength); + dStrncpy(mLineBuffer, "", sizeof(mLineBuffer)); + // Add the version number in a global so that // scripts can detect the presence of the // "enhanced" debugger features. diff --git a/Engine/source/console/typeValidators.h b/Engine/source/console/typeValidators.h index 9ca949fa7..c4982a781 100644 --- a/Engine/source/console/typeValidators.h +++ b/Engine/source/console/typeValidators.h @@ -27,7 +27,8 @@ class TypeValidator { public: S32 fieldIndex; - + TypeValidator() : fieldIndex(0) {} + ~TypeValidator() {} /// Prints a console error message for the validator. /// /// The message is prefaced with with: diff --git a/Engine/source/core/color.h b/Engine/source/core/color.h index afc62353e..12b590f4e 100644 --- a/Engine/source/core/color.h +++ b/Engine/source/core/color.h @@ -203,7 +203,7 @@ public: class StockColorItem { private: - StockColorItem() {} + StockColorItem():mColorName("") {} public: StockColorItem( const char* pName, const U8 red, const U8 green, const U8 blue, const U8 alpha = 255 ) @@ -529,6 +529,7 @@ inline void ColorI::set(const Hsb& color) red = (U32)((((F64)r) / 100) * 255); green = (U32)((((F64)g) / 100) * 255); blue = (U32)((((F64)b) / 100) * 255); + alpha = 255; } // This is a subfunction of HSLtoRGB diff --git a/Engine/source/core/frameAllocator.h b/Engine/source/core/frameAllocator.h index 2e03e6fc2..98bf8b110 100644 --- a/Engine/source/core/frameAllocator.h +++ b/Engine/source/core/frameAllocator.h @@ -295,6 +295,7 @@ public: AssertFatal( count > 0, "Allocating a FrameTemp with less than one instance" ); \ mWaterMark = FrameAllocator::getWaterMark(); \ mMemory = reinterpret_cast( FrameAllocator::alloc( sizeof( type ) * count ) ); \ + mNumObjectsInMemory = 0; \ } \ template<>\ inline FrameTemp::~FrameTemp() \ diff --git a/Engine/source/core/ogg/oggTheoraDecoder.h b/Engine/source/core/ogg/oggTheoraDecoder.h index f4ef5899b..b148aba1f 100644 --- a/Engine/source/core/ogg/oggTheoraDecoder.h +++ b/Engine/source/core/ogg/oggTheoraDecoder.h @@ -48,9 +48,9 @@ class OggTheoraFrame : public RawData typedef RawData Parent; - OggTheoraFrame() {} + OggTheoraFrame() :mFrameNumber(0), mFrameTime(0), mFrameDuration(0) {} OggTheoraFrame( S8* data, U32 size, bool ownMemory = false ) - : Parent( data, size, ownMemory ) {} + : Parent( data, size, ownMemory ), mFrameNumber(0), mFrameTime(0), mFrameDuration(0) {} /// Serial number of this frame in the stream. U32 mFrameNumber; diff --git a/Engine/source/core/stream/fileStream.cpp b/Engine/source/core/stream/fileStream.cpp index 3d681db4d..29ce3a933 100644 --- a/Engine/source/core/stream/fileStream.cpp +++ b/Engine/source/core/stream/fileStream.cpp @@ -31,6 +31,7 @@ //----------------------------------------------------------------------------- FileStream::FileStream() { + dMemset(mBuffer, 0, sizeof(mBuffer)); // initialize the file stream init(); } diff --git a/Engine/source/core/stringBuffer.cpp b/Engine/source/core/stringBuffer.cpp index a55446885..2bc3fb069 100644 --- a/Engine/source/core/stringBuffer.cpp +++ b/Engine/source/core/stringBuffer.cpp @@ -38,6 +38,8 @@ StringBufferManager() { + request8 = 0.0; + request16 = 0.0; VECTOR_SET_ASSOCIATION( strings ); } diff --git a/Engine/source/core/util/journal/journal.h b/Engine/source/core/util/journal/journal.h index 9db84e2f6..a6b0b8957 100644 --- a/Engine/source/core/util/journal/journal.h +++ b/Engine/source/core/util/journal/journal.h @@ -335,6 +335,7 @@ class Journal struct FuncDecl { FuncDecl* next; Id id; + FuncDecl() :next(NULL), id(0){} virtual ~FuncDecl() {} virtual bool match(VoidPtr,VoidMethod) const = 0; virtual Functor* create() const = 0; diff --git a/Engine/source/core/util/str.h b/Engine/source/core/util/str.h index 046bc1f6f..f5264cfd6 100644 --- a/Engine/source/core/util/str.h +++ b/Engine/source/core/util/str.h @@ -29,6 +29,7 @@ #include "platform/types.h" #endif +#include template< class T > class Vector; @@ -244,7 +245,7 @@ public: _dynamicSize( 0 ), _len( 0 ) { - _fixedBuffer[0] = '\0'; + strncpy(_fixedBuffer, "", 2048); } StrFormat(const char *formatStr, va_list args) @@ -269,7 +270,7 @@ public: void reset() { _len = 0; - _fixedBuffer[0] = '\0'; + strncpy(_fixedBuffer, "", 2048); } /// Copy the formatted string into the output buffer which must be at least size() characters. diff --git a/Engine/source/core/util/tList.h b/Engine/source/core/util/tList.h index 4a2bcfd34..1ed9312b4 100644 --- a/Engine/source/core/util/tList.h +++ b/Engine/source/core/util/tList.h @@ -141,7 +141,7 @@ private: { Link* next; Link* prev; - Link() {} + Link(): next(NULL), prev(NULL) {} Link(Link* p,Link* n): next(n),prev(p) {} }; diff --git a/Engine/source/core/util/tSignal.h b/Engine/source/core/util/tSignal.h index f5531e217..b249aa6fd 100644 --- a/Engine/source/core/util/tSignal.h +++ b/Engine/source/core/util/tSignal.h @@ -76,7 +76,7 @@ protected: void insert(DelegateLink* node, F32 order); void unlink(); - + DelegateLink() :next(NULL), prev(NULL), mOrder(0) {} virtual ~DelegateLink() {} }; diff --git a/Engine/source/environment/VolumetricFogRTManager.cpp b/Engine/source/environment/VolumetricFogRTManager.cpp index c9caf29e4..d291bb999 100644 --- a/Engine/source/environment/VolumetricFogRTManager.cpp +++ b/Engine/source/environment/VolumetricFogRTManager.cpp @@ -87,8 +87,11 @@ VolumetricFogRTManager::VolumetricFogRTManager() setGlobalBounds(); mTypeMask |= EnvironmentObjectType; mNetFlags.set(IsGhost); + mPlatformWindow = NULL; mIsInitialized = false; mNumFogObjects = 0; + mWidth = 0; + mHeight = 0; } VolumetricFogRTManager::~VolumetricFogRTManager() @@ -291,4 +294,4 @@ DefineEngineFunction(SetFogVolumeQuality, S32, (U32 new_quality), , if (VFRTM == NULL) return -1; return VFRTM->setQuality(new_quality); -} \ No newline at end of file +} diff --git a/Engine/source/environment/basicClouds.cpp b/Engine/source/environment/basicClouds.cpp index 88cd394e9..0352c4e1a 100644 --- a/Engine/source/environment/basicClouds.cpp +++ b/Engine/source/environment/basicClouds.cpp @@ -63,11 +63,12 @@ BasicClouds::BasicClouds() mTypeMask |= EnvironmentObjectType | StaticObjectType; mNetFlags.set(Ghostable | ScopeAlways); - mTimeSC = 0; - mModelViewProjSC = 0; - mTexScaleSC = 0; - mTexDirectionSC = 0; - mTexOffsetSC = 0; + mTimeSC = NULL; + mModelViewProjSC = NULL; + mTexScaleSC = NULL; + mTexDirectionSC = NULL; + mTexOffsetSC = NULL; + mDiffuseMapSC = NULL; mLayerEnabled[0] = true; mLayerEnabled[1] = true; @@ -414,4 +415,4 @@ void BasicClouds::_initBuffers() mVB[i].unlock(); } -} \ No newline at end of file +} diff --git a/Engine/source/environment/cloudLayer.cpp b/Engine/source/environment/cloudLayer.cpp index 08cb6ce00..6c7fafb7f 100644 --- a/Engine/source/environment/cloudLayer.cpp +++ b/Engine/source/environment/cloudLayer.cpp @@ -82,15 +82,16 @@ CloudLayer::CloudLayer() mTypeMask |= EnvironmentObjectType | StaticObjectType; mNetFlags.set(Ghostable | ScopeAlways); - mModelViewProjSC = - mAmbientColorSC = - mSunColorSC = - mSunVecSC = - mTexScaleSC = - mBaseColorSC = - mCoverageSC = - mExposureSC = - mEyePosWorldSC = 0; + mModelViewProjSC = NULL; + mAmbientColorSC = NULL; + mSunColorSC = NULL; + mSunVecSC = NULL; + mTexScaleSC = NULL; + mBaseColorSC = NULL; + mCoverageSC = NULL; + mExposureSC = NULL; + mEyePosWorldSC = NULL; + mNormalHeightMapSC = NULL; mTexOffsetSC[0] = mTexOffsetSC[1] = mTexOffsetSC[2] = 0; diff --git a/Engine/source/environment/decalRoad.cpp b/Engine/source/environment/decalRoad.cpp index 00359f7bb..668bfcaae 100644 --- a/Engine/source/environment/decalRoad.cpp +++ b/Engine/source/environment/decalRoad.cpp @@ -279,7 +279,10 @@ DecalRoad::DecalRoad() mLoadRenderData( true ), mMaterial( NULL ), mMatInst( NULL ), + mTriangleCount(0), + mVertCount(0), mUpdateEventId( -1 ), + mLastEvent(NULL), mTerrainUpdateRect( Box3F::Invalid ) { // Setup NetObject. diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp index 95dfe4ad9..c9bd76d33 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp @@ -67,6 +67,7 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl() mMovePointMode("MeshRoadEditorMoveMode"), mScalePointMode("MeshRoadEditorScaleMode"), mRotatePointMode("MeshRoadEditorRotateMode"), + mSavedDrag(false), mIsDirty( false ), mRoadSet( NULL ), mSelNode( -1 ), @@ -82,7 +83,7 @@ GuiMeshRoadEditorCtrl::GuiMeshRoadEditorCtrl() mHoverSplineColor( 255,0,0,255 ), mSelectedSplineColor( 0,255,0,255 ), mHoverNodeColor( 255,255,255,255 ), - mHasCopied( false ) + mHasCopied( false ) { mMaterialName[Top] = StringTable->insert("DefaultRoadMaterialTop"); mMaterialName[Bottom] = StringTable->insert("DefaultRoadMaterialOther"); diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h index 3109c538b..f4b34004f 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.h @@ -159,6 +159,9 @@ class GuiMeshRoadEditorUndoAction : public UndoAction GuiMeshRoadEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName ) { + mEditor = NULL; + mObjId = 0; + mMetersPerSegment = 1.0f; } GuiMeshRoadEditorCtrl *mEditor; diff --git a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp index 23df5900d..97b8b7912 100644 --- a/Engine/source/environment/editors/guiRiverEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRiverEditorCtrl.cpp @@ -84,6 +84,7 @@ GuiRiverEditorCtrl::GuiRiverEditorCtrl() mStartHeight = -1.0f; mStartX = 0; + mSavedDrag = false; mIsDirty = false; mNodeHalfSize.set(4,4); diff --git a/Engine/source/environment/editors/guiRiverEditorCtrl.h b/Engine/source/environment/editors/guiRiverEditorCtrl.h index d8aa2efb5..a5dae237d 100644 --- a/Engine/source/environment/editors/guiRiverEditorCtrl.h +++ b/Engine/source/environment/editors/guiRiverEditorCtrl.h @@ -181,6 +181,10 @@ class GuiRiverEditorUndoAction : public UndoAction GuiRiverEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName ) { + mRiverEditor = NULL; + mObjId = 0; + mMetersPerSegment = 1.0f; + mSegmentsPerBatch = 10; } GuiRiverEditorCtrl *mRiverEditor; diff --git a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp index c3b3f0e99..409739b38 100644 --- a/Engine/source/environment/editors/guiRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiRoadEditorCtrl.cpp @@ -82,6 +82,7 @@ GuiRoadEditorCtrl::GuiRoadEditorCtrl() mSelectedSplineColor.set( 0,255,0,255 ); mHoverNodeColor.set( 255,255,255,255 ); + mSavedDrag = false; mIsDirty = false; mMaterialName = StringTable->insert("DefaultDecalRoadMaterial"); diff --git a/Engine/source/environment/editors/guiRoadEditorCtrl.h b/Engine/source/environment/editors/guiRoadEditorCtrl.h index f6383e548..5993f5e13 100644 --- a/Engine/source/environment/editors/guiRoadEditorCtrl.h +++ b/Engine/source/environment/editors/guiRoadEditorCtrl.h @@ -146,6 +146,11 @@ class GuiRoadEditorUndoAction : public UndoAction GuiRoadEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName ) { + mRoadEditor = NULL; + mObjId = 0; + mBreakAngle = 3.0f; + mSegmentsPerBatch = 0; + mTextureLength = 0.0f; } GuiRoadEditorCtrl *mRoadEditor; diff --git a/Engine/source/environment/meshRoad.cpp b/Engine/source/environment/meshRoad.cpp index 1ed6768fb..f9f853ada 100644 --- a/Engine/source/environment/meshRoad.cpp +++ b/Engine/source/environment/meshRoad.cpp @@ -309,7 +309,7 @@ Point3F MeshRoadConvex::support(const VectorF& vec) const void MeshRoadConvex::getFeatures(const MatrixF& mat, const VectorF& n, ConvexFeature* cf) { cf->material = 0; - cf->object = mObject; + cf->mObject = mObject; // For a tetrahedron this is pretty easy... first // convert everything into world space. @@ -629,6 +629,11 @@ MeshRoad::MeshRoad() mMatInst[Bottom] = NULL; mMatInst[Side] = NULL; mTypeMask |= TerrainLikeObjectType; + for (U32 i = 0; i < SurfaceCount; i++) + { + mVertCount[i] = 0; + mTriangleCount[i] = 0; + } } MeshRoad::~MeshRoad() diff --git a/Engine/source/environment/meshRoad.h b/Engine/source/environment/meshRoad.h index 06157b343..6279e20fa 100644 --- a/Engine/source/environment/meshRoad.h +++ b/Engine/source/environment/meshRoad.h @@ -85,7 +85,7 @@ public: public: - MeshRoadConvex() { mType = MeshRoadConvexType; } + MeshRoadConvex():pRoad(NULL), faceId(0), triangleId(0), segmentId(0) { mType = MeshRoadConvexType; } MeshRoadConvex( const MeshRoadConvex& cv ) { mType = MeshRoadConvexType; @@ -122,7 +122,7 @@ struct ObjectRenderInst; class MeshRoadSplineNode { public: - MeshRoadSplineNode() {} + MeshRoadSplineNode() :x(0.0f), y(0.0f), z(0.0f), width(0.0f), depth(0.0f) {} F32 x; F32 y; @@ -257,6 +257,7 @@ struct MeshRoadSlice depth = 0.0f; normal.set(0,0,1); texCoordV = 0.0f; + t = 0.0f; parentNodeIdx = -1; }; @@ -572,4 +573,4 @@ public: }; -#endif // _MESHROAD_H_ \ No newline at end of file +#endif // _MESHROAD_H_ diff --git a/Engine/source/environment/nodeListManager.h b/Engine/source/environment/nodeListManager.h index c4f42d3f2..f6e46b23a 100644 --- a/Engine/source/environment/nodeListManager.h +++ b/Engine/source/environment/nodeListManager.h @@ -50,7 +50,7 @@ public: U32 mTotalValidNodes; bool mListComplete; - NodeList() { mTotalValidNodes=0; mListComplete=false; } + NodeList() { mId = 0; mTotalValidNodes = 0; mListComplete = false; } virtual ~NodeList() { } }; @@ -93,7 +93,7 @@ protected: U32 mListId; public: - NodeListNotify() { } + NodeListNotify() { mListId = 0; } virtual ~NodeListNotify() { } U32 getListId() { return mListId; } @@ -115,7 +115,7 @@ public: NodeListManager::NodeList* mNodeList; public: - NodeListEvent() { mNodeList=NULL; mTotalNodes = mLocalListStart = 0; } + NodeListEvent() { mId = 0; mNodeList = NULL; mTotalNodes = mLocalListStart = 0; } virtual ~NodeListEvent(); virtual void pack(NetConnection*, BitStream*); diff --git a/Engine/source/environment/river.cpp b/Engine/source/environment/river.cpp index 0ff02c6d9..9606584f7 100644 --- a/Engine/source/environment/river.cpp +++ b/Engine/source/environment/river.cpp @@ -593,7 +593,11 @@ IMPLEMENT_CO_NETOBJECT_V1(River); River::River() - : mSegmentsPerBatch(10), + : mLowVertCount(0), + mHighVertCount(0), + mLowTriangleCount(0), + mHighTriangleCount(0), + mSegmentsPerBatch(10), mMetersPerSegment(10.0f), mDepthScale(1.0f), mFlowMagnitude(1.0f), diff --git a/Engine/source/environment/river.h b/Engine/source/environment/river.h index acb7f2926..f91217955 100644 --- a/Engine/source/environment/river.h +++ b/Engine/source/environment/river.h @@ -58,7 +58,7 @@ struct ObjectRenderInst; class RiverSplineNode { public: - RiverSplineNode() {} + RiverSplineNode() :x(0.0f), y(0.0f), z(0.0f), width(0.0f), depth(0.0f) {} F32 x; F32 y; @@ -529,4 +529,4 @@ protected: U32 mColumnCount; }; -#endif // _RIVER_H_ \ No newline at end of file +#endif // _RIVER_H_ diff --git a/Engine/source/environment/waterBlock.cpp b/Engine/source/environment/waterBlock.cpp index 4a4edc15f..23345985a 100644 --- a/Engine/source/environment/waterBlock.cpp +++ b/Engine/source/environment/waterBlock.cpp @@ -56,7 +56,8 @@ WaterBlock::WaterBlock() { mGridElementSize = 5.0f; mObjScale.set( 100.0f, 100.0f, 10.0f ); - + mWidth = 2; + mHeight = 2; mNetFlags.set(Ghostable | ScopeAlways); mObjBox.minExtents.set( -0.5f, -0.5f, -0.5f ); diff --git a/Engine/source/environment/waterObject.cpp b/Engine/source/environment/waterObject.cpp index adb81e6d1..0698cdce6 100644 --- a/Engine/source/environment/waterObject.cpp +++ b/Engine/source/environment/waterObject.cpp @@ -204,6 +204,7 @@ WaterObject::WaterObject() mCubemap( NULL ), mSpecularColor( 1.0f, 1.0f, 1.0f, 1.0f ), mEmissive( false ), + mFullReflect(true), mDepthGradientMax( 50.0f ) { mTypeMask = WaterObjectType; @@ -248,6 +249,8 @@ WaterObject::WaterObject() mSurfMatName[BasicUnderWaterMat] = "UnderWaterBasicMat"; dMemset( mMatInstances, 0, sizeof(mMatInstances) ); + dMemset(mMatParamHandles, 0, sizeof(mMatParamHandles)); + mUnderwater = false; mWaterPos.set( 0,0,0 ); mWaterPlane.set( mWaterPos, Point3F(0,0,1) ); @@ -1211,4 +1214,4 @@ S32 WaterObject::getMaterialIndex( const Point3F &camPos ) } return matIdx; -} \ No newline at end of file +} diff --git a/Engine/source/forest/editor/forestSelectionTool.cpp b/Engine/source/forest/editor/forestSelectionTool.cpp index f6689c9b8..aafd473da 100644 --- a/Engine/source/forest/editor/forestSelectionTool.cpp +++ b/Engine/source/forest/editor/forestSelectionTool.cpp @@ -161,7 +161,9 @@ ForestSelectionTool::ForestSelectionTool() : Parent(), mGizmo( NULL ), mCurrAction( NULL ), - mGizmoProfile( NULL ) + mGizmoProfile( NULL ), + mMouseDragged(false), + mUsingGizmo(false) { mBounds = Box3F::Invalid; diff --git a/Engine/source/forest/forest.h b/Engine/source/forest/forest.h index b44764b70..42f026976 100644 --- a/Engine/source/forest/forest.h +++ b/Engine/source/forest/forest.h @@ -114,9 +114,6 @@ protected: static bool smDrawCells; static bool smDrawBounds; - /// - bool mRegen; - enum MaskBits { MediaMask = Parent::NextFreeMask << 1, @@ -211,4 +208,4 @@ public: void updateCollision(); }; -#endif // _H_FOREST_ \ No newline at end of file +#endif // _H_FOREST_ diff --git a/Engine/source/forest/forestCollision.cpp b/Engine/source/forest/forestCollision.cpp index 468c901dc..6c1038a7d 100644 --- a/Engine/source/forest/forestCollision.cpp +++ b/Engine/source/forest/forestCollision.cpp @@ -124,7 +124,7 @@ Point3F ForestConvex::support(const VectorF& v) const void ForestConvex::getFeatures( const MatrixF &mat, const VectorF &n, ConvexFeature *cf ) { cf->material = 0; - cf->object = mObject; + cf->mObject = mObject; TSShapeInstance *si = mData->getShapeInstance(); @@ -475,4 +475,4 @@ bool ForestItem::castRay( const Point3F &start, const Point3F &end, RayInfo *out *(ForestItem*)(outInfo->userData) = *this; return true; -} \ No newline at end of file +} diff --git a/Engine/source/forest/forestCollision.h b/Engine/source/forest/forestCollision.h index 716ec8991..0118307ec 100644 --- a/Engine/source/forest/forestCollision.h +++ b/Engine/source/forest/forestCollision.h @@ -46,7 +46,11 @@ public: ForestConvex() { mType = ForestConvexType; - mTransform.identity(); + mTransform.identity(); + hullId = 0; + mForestItemKey = 0; + mData = NULL; + mScale = 1.0f; } ForestConvex( const ForestConvex &cv ) diff --git a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp index a544452f8..1bbd68e6d 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Device.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11Device.cpp @@ -90,6 +90,8 @@ GFXD3D11Device::GFXD3D11Device(U32 index) mDeviceSwizzle24 = &Swizzles::bgr; mAdapterIndex = index; + mSwapChain = NULL; + mD3DDevice = NULL; mD3DDeviceContext = NULL; mVolatileVB = NULL; @@ -107,6 +109,8 @@ GFXD3D11Device::GFXD3D11Device(U32 index) mPixVersion = 0.0; + mFeatureLevel = D3D_FEATURE_LEVEL_9_1; //lowest listed. should be overridden by init + mVertexShaderTarget = String::EmptyString; mPixelShaderTarget = String::EmptyString; mShaderModel = String::EmptyString; @@ -123,7 +127,8 @@ GFXD3D11Device::GFXD3D11Device(U32 index) mCreateFenceType = -1; // Unknown, test on first allocate mCurrentConstBuffer = NULL; - + mMultisampleDesc.Count = 0; + mMultisampleDesc.Quality = 0; mOcclusionQuerySupported = false; mDebugLayers = false; diff --git a/Engine/source/gfx/D3D11/gfxD3D11Device.h b/Engine/source/gfx/D3D11/gfxD3D11Device.h index 9fd853b86..75525ce95 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Device.h +++ b/Engine/source/gfx/D3D11/gfxD3D11Device.h @@ -79,6 +79,7 @@ protected: class D3D11VertexDecl : public GFXVertexDecl { public: + D3D11VertexDecl() :decl(NULL) {} virtual ~D3D11VertexDecl() { SAFE_RELEASE( decl ); diff --git a/Engine/source/gfx/D3D11/gfxD3D11PrimitiveBuffer.h b/Engine/source/gfx/D3D11/gfxD3D11PrimitiveBuffer.h index 1be1952d4..948176af6 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11PrimitiveBuffer.h +++ b/Engine/source/gfx/D3D11/gfxD3D11PrimitiveBuffer.h @@ -73,11 +73,11 @@ inline GFXD3D11PrimitiveBuffer::GFXD3D11PrimitiveBuffer( GFXDevice *device, mLocked = false; #ifdef TORQUE_DEBUG mDebugGuardBuffer = NULL; - mLockedBuffer = NULL; mLockedSize = 0; +#endif mIndexStart = 0; mIndexEnd = 0; -#endif + mLockedBuffer = NULL; } #endif diff --git a/Engine/source/gfx/D3D11/gfxD3D11Shader.h b/Engine/source/gfx/D3D11/gfxD3D11Shader.h index b20ea8e3c..8ae17a979 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Shader.h +++ b/Engine/source/gfx/D3D11/gfxD3D11Shader.h @@ -77,17 +77,17 @@ enum REGISTER_TYPE struct ConstantDesc { - String Name; - S32 RegisterIndex; - S32 RegisterCount; - S32 Rows; - S32 Columns; - S32 Elements; - S32 StructMembers; - REGISTER_TYPE RegisterSet; - CONST_CLASS Class; - CONST_TYPE Type; - U32 Bytes; + String Name = String::EmptyString; + S32 RegisterIndex = 0; + S32 RegisterCount = 0; + S32 Rows = 0; + S32 Columns = 0; + S32 Elements = 0; + S32 StructMembers = 0; + REGISTER_TYPE RegisterSet = D3DRS_FLOAT4; + CONST_CLASS Class = D3DPC_SCALAR; + CONST_TYPE Type = D3DPT_FLOAT; + U32 Bytes = 0; }; class ConstantTable diff --git a/Engine/source/gfx/D3D11/gfxD3D11Target.cpp b/Engine/source/gfx/D3D11/gfxD3D11Target.cpp index 45aabbf07..29eb8fb46 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Target.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11Target.cpp @@ -324,6 +324,8 @@ GFXD3D11WindowTarget::GFXD3D11WindowTarget() mDepthStencilView = NULL; mDepthStencil = NULL; mBackBufferView = NULL; + mSwapChain = NULL; + dMemset(&mPresentationParams, 0, sizeof(mPresentationParams)); mSecondaryWindow = false; } diff --git a/Engine/source/gfx/D3D11/gfxD3D11TextureObject.cpp b/Engine/source/gfx/D3D11/gfxD3D11TextureObject.cpp index e2508eb40..27965a7da 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11TextureObject.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11TextureObject.cpp @@ -46,10 +46,13 @@ GFXD3D11TextureObject::GFXD3D11TextureObject( GFXDevice * d, GFXTextureProfile * mLocked = false; mD3DSurface = NULL; + dMemset(&mLockRect, 0, sizeof(mLockRect)); + dMemset(&mLockBox, 0, sizeof(mLockBox)); mLockedSubresource = 0; mDSView = NULL; mRTView = NULL; mSRView = NULL; + isManaged = false; } GFXD3D11TextureObject::~GFXD3D11TextureObject() @@ -318,4 +321,4 @@ ID3D11RenderTargetView** GFXD3D11TextureObject::getRTViewPtr() ID3D11DepthStencilView** GFXD3D11TextureObject::getDSViewPtr() { return &mDSView; -} \ No newline at end of file +} diff --git a/Engine/source/gfx/D3D11/gfxD3D11VertexBuffer.h b/Engine/source/gfx/D3D11/gfxD3D11VertexBuffer.h index 380a0f93b..9e961cc87 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11VertexBuffer.h +++ b/Engine/source/gfx/D3D11/gfxD3D11VertexBuffer.h @@ -68,10 +68,10 @@ inline GFXD3D11VertexBuffer::GFXD3D11VertexBuffer() : GFXVertexBuffer(0,0,0,0,(G mIsFirstLock = true; lockedVertexEnd = lockedVertexStart = 0; mClearAtFrameEnd = false; + mLockedBuffer = NULL; #ifdef TORQUE_DEBUG mDebugGuardBuffer = NULL; - mLockedBuffer = NULL; #endif } @@ -92,4 +92,4 @@ inline GFXD3D11VertexBuffer::GFXD3D11VertexBuffer( GFXDevice *device, #endif } -#endif // _GFXD3D_VERTEXBUFFER_H_ \ No newline at end of file +#endif // _GFXD3D_VERTEXBUFFER_H_ diff --git a/Engine/source/gfx/Null/gfxNullDevice.cpp b/Engine/source/gfx/Null/gfxNullDevice.cpp index 83933733c..8767d4eee 100644 --- a/Engine/source/gfx/Null/gfxNullDevice.cpp +++ b/Engine/source/gfx/Null/gfxNullDevice.cpp @@ -187,7 +187,7 @@ public: const GFXVertexFormat *vertexFormat, U32 vertexSize, GFXBufferType bufferType ) : - GFXVertexBuffer(device, numVerts, vertexFormat, vertexSize, bufferType) { }; + GFXVertexBuffer(device, numVerts, vertexFormat, vertexSize, bufferType) {tempBuf =NULL;}; virtual void lock(U32 vertexStart, U32 vertexEnd, void **vertexPtr); virtual void unlock(); virtual void prepare(); diff --git a/Engine/source/gfx/bitmap/ddsFile.h b/Engine/source/gfx/bitmap/ddsFile.h index 8e726c54a..7aae54ff4 100644 --- a/Engine/source/gfx/bitmap/ddsFile.h +++ b/Engine/source/gfx/bitmap/ddsFile.h @@ -176,7 +176,15 @@ struct DDSFile // For debugging fun! static S32 smActiveCopies; - DDSFile() + DDSFile(): + mBytesPerPixel(0), + mHeight(0), + mWidth(0), + mDepth(0), + mFormat(GFXFormat_FIRST), + mFourCC(0), + mMipMapCount(0), + mPitchOrLinearSize(0) { VECTOR_SET_ASSOCIATION( mSurfaces ); smActiveCopies++; @@ -203,4 +211,4 @@ struct DDSFile bool decompressToGBitmap(GBitmap *dest); }; -#endif // _DDSFILE_H_ \ No newline at end of file +#endif // _DDSFILE_H_ diff --git a/Engine/source/gfx/bitmap/gBitmap.cpp b/Engine/source/gfx/bitmap/gBitmap.cpp index fe73ecf7e..380070346 100644 --- a/Engine/source/gfx/bitmap/gBitmap.cpp +++ b/Engine/source/gfx/bitmap/gBitmap.cpp @@ -50,8 +50,7 @@ GBitmap::GBitmap() mNumMipLevels(0), mHasTransparency(false) { - for (U32 i = 0; i < c_maxMipLevels; i++) - mMipLevelOffsets[i] = 0xffffffff; + std::fill_n(mMipLevelOffsets, c_maxMipLevels, 0xffffffff); } GBitmap::GBitmap(const GBitmap& rCopy) diff --git a/Engine/source/gfx/bitmap/gBitmap.h b/Engine/source/gfx/bitmap/gBitmap.h index 7ff215a81..16cb24985 100644 --- a/Engine/source/gfx/bitmap/gBitmap.h +++ b/Engine/source/gfx/bitmap/gBitmap.h @@ -82,6 +82,9 @@ public: Registration() { + readFunc = NULL; + writeFunc = NULL; + defaultCompression = 0; priority = 0; VECTOR_SET_ASSOCIATION( extensions ); } diff --git a/Engine/source/gfx/bitmap/imageUtils.cpp b/Engine/source/gfx/bitmap/imageUtils.cpp index 2d9e7ab8d..ed8d108da 100644 --- a/Engine/source/gfx/bitmap/imageUtils.cpp +++ b/Engine/source/gfx/bitmap/imageUtils.cpp @@ -69,7 +69,6 @@ namespace ImageUtil { S32 width; S32 height; - S32 flags; const U8 *pSrc; U8 *pDst; GFXFormat format; @@ -306,4 +305,4 @@ namespace ImageUtil { return mFloor(mLog2(mMax(width, height))) + 1; } -} \ No newline at end of file +} diff --git a/Engine/source/gfx/gFont.cpp b/Engine/source/gfx/gFont.cpp index 9193b1e58..d64e1066e 100644 --- a/Engine/source/gfx/gFont.cpp +++ b/Engine/source/gfx/gFont.cpp @@ -198,14 +198,17 @@ GFont::GFont() VECTOR_SET_ASSOCIATION(mCharInfoList); VECTOR_SET_ASSOCIATION(mTextureSheets); - for (U32 i = 0; i < (sizeof(mRemapTable) / sizeof(S32)); i++) - mRemapTable[i] = -1; + std::fill_n(mRemapTable, Font_Table_MAX,-1); mCurX = mCurY = mCurSheet = -1; mPlatformFont = NULL; mSize = 0; mCharSet = 0; + mHeight = 0; + mBaseline = 0; + mAscent = 0; + mDescent = 0; mNeedSave = false; mMutex = Mutex::createMutex(); diff --git a/Engine/source/gfx/gFont.h b/Engine/source/gfx/gFont.h index b67d7e72f..2f5274af2 100644 --- a/Engine/source/gfx/gFont.h +++ b/Engine/source/gfx/gFont.h @@ -42,6 +42,7 @@ GFX_DeclareTextureProfile(GFXFontTextureProfile); +#define Font_Table_MAX 65536 class GFont { @@ -159,7 +160,7 @@ private: Vector mCharInfoList; /// Index remapping - S32 mRemapTable[65536]; + S32 mRemapTable[Font_Table_MAX]; }; inline U32 GFont::getCharXIncrement(const UTF16 in_charIndex) diff --git a/Engine/source/gfx/gfxAdapter.h b/Engine/source/gfx/gfxAdapter.h index a7988e910..80435618c 100644 --- a/Engine/source/gfx/gfxAdapter.h +++ b/Engine/source/gfx/gfxAdapter.h @@ -82,6 +82,7 @@ public: mShaderModel = 0.f; mIndex = 0; dMemset(&mLUID, '\0', sizeof(mLUID)); + mType = GFXAdapterType::NullDevice; } ~GFXAdapter() diff --git a/Engine/source/gfx/gfxCubemap.h b/Engine/source/gfx/gfxCubemap.h index 798251d12..b3c6eac0e 100644 --- a/Engine/source/gfx/gfxCubemap.h +++ b/Engine/source/gfx/gfxCubemap.h @@ -125,7 +125,7 @@ protected: GFXFormat mFormat; public: - + GFXCubemapArray() :mNumCubemaps(0), mSize(0), mMipMapLevels(0), mFormat(GFXFormat_FIRST) {} virtual ~GFXCubemapArray() {}; /// Initialize from an array of cubemaps virtual void init(GFXCubemapHandle *cubemaps, const U32 cubemapCount) = 0; diff --git a/Engine/source/gfx/gfxFontRenderBatcher.cpp b/Engine/source/gfx/gfxFontRenderBatcher.cpp index fd4cb11cb..4b7722b7e 100644 --- a/Engine/source/gfx/gfxFontRenderBatcher.cpp +++ b/Engine/source/gfx/gfxFontRenderBatcher.cpp @@ -25,6 +25,8 @@ FontRenderBatcher::FontRenderBatcher() : mStorage(8096) { + mFont = NULL; + mLength = 0; if (!mFontSB) { GFXStateBlockDesc f; @@ -246,4 +248,4 @@ void FontRenderBatcher::init( GFont *font, U32 n ) mFont = font; mLength = n; -} \ No newline at end of file +} diff --git a/Engine/source/gfx/gfxFormatUtils.h b/Engine/source/gfx/gfxFormatUtils.h index 9000dcf3a..4d5729f00 100644 --- a/Engine/source/gfx/gfxFormatUtils.h +++ b/Engine/source/gfx/gfxFormatUtils.h @@ -57,7 +57,7 @@ struct GFXFormatInfo /// If true, channels are in floating-point. bool mIsFloatingPoint; - Data() {} + Data() :mBytesPerPixel(0), mHasAlpha(false), mIsCompressed(false), mIsFloatingPoint(false) {} Data( U32 bpp, bool hasAlpha = false, bool isCompressed = false, bool isFP = false ) : mBytesPerPixel( bpp ), mHasAlpha( hasAlpha ), diff --git a/Engine/source/gfx/gfxStructs.h b/Engine/source/gfx/gfxStructs.h index 3f2602331..65d0781bb 100644 --- a/Engine/source/gfx/gfxStructs.h +++ b/Engine/source/gfx/gfxStructs.h @@ -159,7 +159,12 @@ struct GFXPrimitive GFXPrimitive() { - dMemset( this, 0, sizeof( GFXPrimitive ) ); + type = GFXPT_FIRST; + startVertex = 0; + minIndex = 0; + startIndex = 0; + numPrimitives = 0; + numVertices = 0; } }; diff --git a/Engine/source/gfx/gfxVertexBuffer.h b/Engine/source/gfx/gfxVertexBuffer.h index 329d0cf72..b37769ad5 100644 --- a/Engine/source/gfx/gfxVertexBuffer.h +++ b/Engine/source/gfx/gfxVertexBuffer.h @@ -68,6 +68,10 @@ public: mVertexSize( vertexSize ), mBufferType( bufferType ), mDevice( device ), + isLocked(false), + lockedVertexStart(0), + lockedVertexEnd(0), + lockedVertexPtr(NULL), mVolatileStart( 0 ) { if ( vertexFormat ) diff --git a/Engine/source/gfx/gfxVertexFormat.cpp b/Engine/source/gfx/gfxVertexFormat.cpp index 943813d3c..bafd56da4 100644 --- a/Engine/source/gfx/gfxVertexFormat.cpp +++ b/Engine/source/gfx/gfxVertexFormat.cpp @@ -77,6 +77,7 @@ GFXVertexFormat::GFXVertexFormat() mHasColor( false ), mHasTangent( false ), mHasInstancing( false ), + mHasBlendIndices(false), mTexCoordCount( 0 ), mSizeInBytes( 0 ), mDecl( NULL ) diff --git a/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h b/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h index a3d2cb1dd..6abeaf8e4 100644 --- a/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h +++ b/Engine/source/gfx/gl/gfxGLCircularVolatileBuffer.h @@ -174,7 +174,8 @@ public: struct { - U32 mOffset, mSize; + U32 mOffset = 0; + U32 mSize = 0; }_getBufferData; void lock(const U32 size, U32 offsetAlign, U32 &outOffset, void* &outPtr) diff --git a/Engine/source/gfx/gl/gfxGLCubemap.cpp b/Engine/source/gfx/gl/gfxGLCubemap.cpp index 40bf88f91..541cd4fc7 100644 --- a/Engine/source/gfx/gl/gfxGLCubemap.cpp +++ b/Engine/source/gfx/gl/gfxGLCubemap.cpp @@ -41,6 +41,8 @@ static GLenum faceList[6] = GFXGLCubemap::GFXGLCubemap() : mCubemap(0), mDynamicTexSize(0), + mWidth(0), + mHeight(0), mFaceFormat( GFXFormatR8G8B8A8 ) { for(U32 i = 0; i < 6; i++) @@ -313,6 +315,7 @@ U8* GFXGLCubemap::getTextureData(U32 face, U32 mip) GFXGLCubemapArray::GFXGLCubemapArray() { + mCubemap = NULL; } GFXGLCubemapArray::~GFXGLCubemapArray() diff --git a/Engine/source/gfx/gl/gfxGLDevice.cpp b/Engine/source/gfx/gl/gfxGLDevice.cpp index 9c09d324f..0b1932f6e 100644 --- a/Engine/source/gfx/gl/gfxGLDevice.cpp +++ b/Engine/source/gfx/gl/gfxGLDevice.cpp @@ -235,6 +235,7 @@ GFXGLDevice::GFXGLDevice(U32 adapterIndex) : mActiveTextureType[i] = GL_ZERO; mNumVertexStream = 2; + mSupportsAnisotropic = false; for(int i = 0; i < GS_COUNT; ++i) mModelViewProjSC[i] = NULL; diff --git a/Engine/source/gfx/gl/gfxGLDeviceProfiler.cpp b/Engine/source/gfx/gl/gfxGLDeviceProfiler.cpp index 423fbcc6c..d12ddb923 100644 --- a/Engine/source/gfx/gl/gfxGLDeviceProfiler.cpp +++ b/Engine/source/gfx/gl/gfxGLDeviceProfiler.cpp @@ -53,7 +53,7 @@ public: typedef Data DataType; - GLTimer(GFXDevice *device, Data &data) : mData(&data) + GLTimer(GFXDevice *device, Data &data) : mName(NULL), mData(&data) { glGenQueries(1, &mQueryId); } diff --git a/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp b/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp index 3df694de9..1c1b81171 100644 --- a/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp +++ b/Engine/source/gfx/gl/gfxGLPrimitiveBuffer.cpp @@ -38,7 +38,9 @@ GLCircularVolatileBuffer* getCircularVolatileIndexBuffer() GFXGLPrimitiveBuffer::GFXGLPrimitiveBuffer(GFXDevice *device, U32 indexCount, U32 primitiveCount, GFXBufferType bufferType) : GFXPrimitiveBuffer(device, indexCount, primitiveCount, bufferType), mBufferOffset(0), - mZombieCache(NULL) + mZombieCache(NULL), + lockedIndexEnd(0), + lockedIndexStart(0) { if( mBufferType == GFXBufferTypeVolatile ) { @@ -185,4 +187,4 @@ MODULE_BEGIN( GFX_GL_PrimitiveBuffer ) { GFXDevice::getDeviceEventSignal( ).remove( &onGFXDeviceSignal ); } -MODULE_END \ No newline at end of file +MODULE_END diff --git a/Engine/source/gfx/gl/gfxGLShader.cpp b/Engine/source/gfx/gl/gfxGLShader.cpp index 267924163..5d9d4d380 100644 --- a/Engine/source/gfx/gl/gfxGLShader.cpp +++ b/Engine/source/gfx/gl/gfxGLShader.cpp @@ -69,6 +69,7 @@ public: GFXGLShaderConstHandle::GFXGLShaderConstHandle( GFXGLShader *shader ) : mShader( shader ), mLocation(0), mOffset(0), mSize(0), mSamplerNum(-1), mInstancingConstant(false) { + dMemset(&mDesc, 0, sizeof(mDesc)); mValid = false; } diff --git a/Engine/source/gfx/gl/gfxGLTextureObject.cpp b/Engine/source/gfx/gl/gfxGLTextureObject.cpp index e326664b3..a7bc1d4f7 100644 --- a/Engine/source/gfx/gl/gfxGLTextureObject.cpp +++ b/Engine/source/gfx/gl/gfxGLTextureObject.cpp @@ -33,15 +33,24 @@ GFXGLTextureObject::GFXGLTextureObject(GFXDevice * aDevice, GFXTextureProfile *profile) : GFXTextureObject(aDevice, profile), + mIsNPoT2(false), mBinding(GL_TEXTURE_2D), mBytesPerTexel(4), mLockedRectRect(0, 0, 0, 0), mGLDevice(static_cast(mDevice)), + mIsZombie(false), mZombieCache(NULL), mNeedInitSamplerState(true), mFrameAllocatorMark(0), mFrameAllocatorPtr(NULL) { + +#if TORQUE_DEBUG + mFrameAllocatorMarkGuard == FrameAllocator::getWaterMark(); +#endif + + dMemset(&mLockedRect, 0, sizeof(mLockedRect)); + AssertFatal(dynamic_cast(mDevice), "GFXGLTextureObject::GFXGLTextureObject - Invalid device type, expected GFXGLDevice!"); glGenTextures(1, &mHandle); glGenBuffers(1, &mBuffer); diff --git a/Engine/source/gfx/gl/gfxGLVertexDecl.h b/Engine/source/gfx/gl/gfxGLVertexDecl.h index 545694323..dd80dd852 100644 --- a/Engine/source/gfx/gl/gfxGLVertexDecl.h +++ b/Engine/source/gfx/gl/gfxGLVertexDecl.h @@ -7,7 +7,7 @@ class GFXGLDevice; class GFXGLVertexDecl : public GFXVertexDecl { public: - GFXGLVertexDecl() : mFormat(NULL), mVertexAttribActiveMask(0) {} + GFXGLVertexDecl() : mFormat(NULL), mVertexAttribActiveMask(0) { std::fill_n(mVertexSize, 4, 0); } void init(const GFXVertexFormat *format); void prepareVertexFormat() const; @@ -36,4 +36,4 @@ protected: void _initVerticesFormat2(); }; -#endif //GFX_GL_VERTEX_DECL \ No newline at end of file +#endif //GFX_GL_VERTEX_DECL diff --git a/Engine/source/gfx/video/theoraTexture.cpp b/Engine/source/gfx/video/theoraTexture.cpp index 4ac7bb41e..1b85837b7 100644 --- a/Engine/source/gfx/video/theoraTexture.cpp +++ b/Engine/source/gfx/video/theoraTexture.cpp @@ -278,7 +278,9 @@ bool TheoraTexture::AsyncState::isAtEnd() TheoraTexture::TheoraTexture() : mCurrentFrame( NULL ), mPlaybackQueue( NULL ), - mIsPaused( true ) + mIsPaused( true ), + mLastFrameNumber(0), + mNumDroppedFrames(0) { GFXTextureManager::addEventDelegate( this, &TheoraTexture::_onTextureEvent ); } diff --git a/Engine/source/gfx/video/videoCapture.cpp b/Engine/source/gfx/video/videoCapture.cpp index c147cf8ae..101f784e3 100644 --- a/Engine/source/gfx/video/videoCapture.cpp +++ b/Engine/source/gfx/video/videoCapture.cpp @@ -52,12 +52,16 @@ MODULE_BEGIN( VideoCapture ) MODULE_END; -VideoCapture::VideoCapture() : +VideoCapture::VideoCapture() : + mCapturedFramePos(-1.0f), mEncoder(NULL), mFrameGrabber(NULL), mCanvas(NULL), mIsRecording(false), + mVideoCaptureStartTime(0), + mNextFramePosition(0.0f), mFrameRate(30.0f), + mMsPerFrame(1000.0f / mFrameRate), mResolution(0,0), mWaitingForCanvas(false), mEncoderName("THEORA"), diff --git a/Engine/source/gfx/video/videoCapture.h b/Engine/source/gfx/video/videoCapture.h index 7f46b133f..ca3598067 100644 --- a/Engine/source/gfx/video/videoCapture.h +++ b/Engine/source/gfx/video/videoCapture.h @@ -126,12 +126,12 @@ private: /// Frame to be captured next F32 mNextFramePosition; - /// The per-frame time (in milliseconds) - F32 mMsPerFrame; - /// The framerate we'll use to record F32 mFrameRate; + /// The per-frame time (in milliseconds) + F32 mMsPerFrame; + /// Accumulated error when converting the per-frame-time to integer /// this is used to dither the value and keep overall time advancing /// correct diff --git a/Engine/source/gfx/video/videoEncoderTheora.cpp b/Engine/source/gfx/video/videoEncoderTheora.cpp index f3c1e4674..d64f76487 100644 --- a/Engine/source/gfx/video/videoEncoderTheora.cpp +++ b/Engine/source/gfx/video/videoEncoderTheora.cpp @@ -195,6 +195,11 @@ public: VideoEncoderTheora() : mCurrentFrame(0), td(NULL), mLastFrame(NULL) { + dMemset(&to, 0, sizeof(to)); + dMemset(&ti, 0, sizeof(ti)); + dMemset(&tc, 0, sizeof(tc)); + dMemset(&mBuffer, 0, sizeof(mBuffer)); + setStatus(false); } @@ -458,4 +463,4 @@ public: REGISTER_VIDEO_ENCODER(VideoEncoderTheora, THEORA) -#endif \ No newline at end of file +#endif diff --git a/Engine/source/gui/3d/guiTSControl.cpp b/Engine/source/gui/3d/guiTSControl.cpp index 0be010272..7183e0877 100644 --- a/Engine/source/gui/3d/guiTSControl.cpp +++ b/Engine/source/gui/3d/guiTSControl.cpp @@ -164,6 +164,8 @@ GuiTSCtrl::GuiTSCtrl() mLastCameraQuery.hasStereoTargets = false; mLastCameraQuery.ortho = false; + mOrthoWidth = 0.1f; + mOrthoHeight = 0.1f; } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/buttons/guiButtonCtrl.cpp b/Engine/source/gui/buttons/guiButtonCtrl.cpp index 14d6f1aa7..c0d5f4e08 100644 --- a/Engine/source/gui/buttons/guiButtonCtrl.cpp +++ b/Engine/source/gui/buttons/guiButtonCtrl.cpp @@ -58,6 +58,7 @@ GuiButtonCtrl::GuiButtonCtrl() { setExtent(140, 30); mButtonText = StringTable->EmptyString(); + mHasTheme = false; } //----------------------------------------------------------------------------- @@ -121,4 +122,4 @@ void GuiButtonCtrl::onRender(Point2I offset, //render the children renderChildControls( offset, updateRect); -} \ No newline at end of file +} diff --git a/Engine/source/gui/containers/guiAutoScrollCtrl.cpp b/Engine/source/gui/containers/guiAutoScrollCtrl.cpp index 08104d0f3..bb3432bce 100644 --- a/Engine/source/gui/containers/guiAutoScrollCtrl.cpp +++ b/Engine/source/gui/containers/guiAutoScrollCtrl.cpp @@ -90,8 +90,10 @@ EndImplementEnumType; GuiAutoScrollCtrl::GuiAutoScrollCtrl() : mDirection( Up ), mIsLooping( true ), - mCurrentPhase( PhaseComplete ), + mCurrentPhase( GuiAutoScrollCtrl::PhaseComplete ), mCurrentTime( 0.f ), + mCompleteTime(F32_MAX), + mCurrentPosition(0.0f), mStartDelay( 3.f ), mResetDelay( 5.f ), mChildBorder( 10 ), diff --git a/Engine/source/gui/containers/guiFormCtrl.cpp b/Engine/source/gui/containers/guiFormCtrl.cpp index 0c562d49d..4cbb7ffa9 100644 --- a/Engine/source/gui/containers/guiFormCtrl.cpp +++ b/Engine/source/gui/containers/guiFormCtrl.cpp @@ -59,6 +59,7 @@ GuiFormCtrl::GuiFormCtrl() // The attached menu bar mHasMenu = false; mMenuBar = NULL; + mMouseMovingWin = false; } GuiFormCtrl::~GuiFormCtrl() diff --git a/Engine/source/gui/containers/guiFrameCtrl.h b/Engine/source/gui/containers/guiFrameCtrl.h index 682946198..8f5ff99db 100644 --- a/Engine/source/gui/containers/guiFrameCtrl.h +++ b/Engine/source/gui/containers/guiFrameCtrl.h @@ -114,10 +114,6 @@ protected: /* member variables */ Vector mColumnOffsets; Vector mRowOffsets; - GuiCursor *mMoveCursor; - GuiCursor *mUpDownCursor; - GuiCursor *mLeftRightCursor; - GuiCursor *mDefaultCursor; FrameDetail mFramesetDetails; VectorPtr mFrameDetails; bool mAutoBalance; diff --git a/Engine/source/gui/containers/guiRolloutCtrl.cpp b/Engine/source/gui/containers/guiRolloutCtrl.cpp index 6f2272d9a..095a6a358 100644 --- a/Engine/source/gui/containers/guiRolloutCtrl.cpp +++ b/Engine/source/gui/containers/guiRolloutCtrl.cpp @@ -74,7 +74,10 @@ GuiRolloutCtrl::GuiRolloutCtrl() mIsContainer = true; mCanCollapse = true; mAutoCollapseSiblings = false; + mDefaultCursor = NULL; + mVertSizingCursor = NULL; mHasTexture = false; + mBitmapBounds = NULL; // Make sure we receive our ticks. setProcessTicks(); } diff --git a/Engine/source/gui/containers/guiScrollCtrl.cpp b/Engine/source/gui/containers/guiScrollCtrl.cpp index bea540e19..a52a5816e 100644 --- a/Engine/source/gui/containers/guiScrollCtrl.cpp +++ b/Engine/source/gui/containers/guiScrollCtrl.cpp @@ -74,10 +74,22 @@ GuiScrollCtrl::GuiScrollCtrl() mChildPos(0, 0), mChildExt(0, 0), mScrollTargetPos( -1, -1 ), - mBaseThumbSize(0) + mBaseThumbSize(0), + mHBarEnabled(false), + mVBarEnabled(false), + mHasHScrollBar(false), + mHasVScrollBar(false), + mHThumbSize(1), + mHThumbPos(0), + mVThumbSize(1), + mVThumbPos(0), + mThumbMouseDelta(0) { + mBitmapBounds = NULL; mIsContainer = true; setExtent(200,200); + mLastPreRender = Platform::getVirtualMilliseconds(); + mLastUpdated = Platform::getVirtualMilliseconds(); } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/containers/guiWindowCtrl.cpp b/Engine/source/gui/containers/guiWindowCtrl.cpp index 20af7fc2e..17000909b 100644 --- a/Engine/source/gui/containers/guiWindowCtrl.cpp +++ b/Engine/source/gui/containers/guiWindowCtrl.cpp @@ -116,6 +116,11 @@ GuiWindowCtrl::GuiWindowCtrl() mMaximizeButtonPressed = false; mMinimizeButtonPressed = false; + mRepositionWindow = false; + mResizeWindow = false; + mSnapSignal = false; + mPreCollapsedYExtent = 200; + mPreCollapsedYMinExtent = 176; mText = "New Window"; } diff --git a/Engine/source/gui/controls/guiDecoyCtrl.cpp b/Engine/source/gui/controls/guiDecoyCtrl.cpp index f7fd881e8..61b489995 100644 --- a/Engine/source/gui/controls/guiDecoyCtrl.cpp +++ b/Engine/source/gui/controls/guiDecoyCtrl.cpp @@ -54,7 +54,8 @@ ConsoleDocClass( GuiDecoyCtrl, GuiDecoyCtrl::GuiDecoyCtrl() : mMouseOver(false), mIsDecoy(true), - mDecoyReference(NULL) + mDecoyReference(NULL), + mMouseOverDecoy(false) { } @@ -235,4 +236,4 @@ void GuiDecoyCtrl::onMiddleMouseUp(const GuiEvent &) void GuiDecoyCtrl::onMiddleMouseDragged(const GuiEvent &) { -} \ No newline at end of file +} diff --git a/Engine/source/gui/controls/guiPopUpCtrl.cpp b/Engine/source/gui/controls/guiPopUpCtrl.cpp index 418f1a0de..40649b920 100644 --- a/Engine/source/gui/controls/guiPopUpCtrl.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrl.cpp @@ -280,6 +280,10 @@ GuiPopUpMenuCtrl::GuiPopUpMenuCtrl(void) mBitmapName = StringTable->EmptyString(); // Added mBitmapBounds.set(16, 16); // Added mIdMax = -1; + mBackground = NULL; + mTl = NULL; + mSc = NULL; + mReplaceText = false; } //------------------------------------------------------------------------------ diff --git a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp index bec481163..bd8462ecd 100644 --- a/Engine/source/gui/controls/guiPopUpCtrlEx.cpp +++ b/Engine/source/gui/controls/guiPopUpCtrlEx.cpp @@ -332,6 +332,10 @@ GuiPopUpMenuCtrlEx::GuiPopUpMenuCtrlEx(void) mBitmapBounds.set(16, 16); // Added mHotTrackItems = false; mIdMax = -1; + mBackground = NULL; + mTl = NULL; + mSc = NULL; + mReplaceText = false; } //------------------------------------------------------------------------------ diff --git a/Engine/source/gui/controls/guiSliderCtrl.cpp b/Engine/source/gui/controls/guiSliderCtrl.cpp index d84d6311b..3b2090427 100644 --- a/Engine/source/gui/controls/guiSliderCtrl.cpp +++ b/Engine/source/gui/controls/guiSliderCtrl.cpp @@ -100,8 +100,10 @@ GuiSliderCtrl::GuiSliderCtrl() mMouseOver( false ), mDepressed( false ), mMouseDragged( false ), + mHasTexture(false), mUseFillBar(false), - mFillBarColor(ColorI(255,255,255)) + mFillBarColor(ColorI(255,255,255)), + mBitmapBounds(NULL) { } diff --git a/Engine/source/gui/controls/guiTabPageCtrl.cpp b/Engine/source/gui/controls/guiTabPageCtrl.cpp index c87363cde..b8c84ff0b 100644 --- a/Engine/source/gui/controls/guiTabPageCtrl.cpp +++ b/Engine/source/gui/controls/guiTabPageCtrl.cpp @@ -53,6 +53,7 @@ GuiTabPageCtrl::GuiTabPageCtrl(void) dStrcpy(mText,(UTF8*)"TabPage", MAX_STRING_LENGTH); mActive = true; mIsContainer = true; + mTabIndex = -1; } void GuiTabPageCtrl::initPersistFields() diff --git a/Engine/source/gui/controls/guiTextEditSliderBitmapCtrl.cpp b/Engine/source/gui/controls/guiTextEditSliderBitmapCtrl.cpp index 37ed5fe54..055b7890f 100644 --- a/Engine/source/gui/controls/guiTextEditSliderBitmapCtrl.cpp +++ b/Engine/source/gui/controls/guiTextEditSliderBitmapCtrl.cpp @@ -95,6 +95,8 @@ GuiTextEditSliderBitmapCtrl::GuiTextEditSliderBitmapCtrl() mTextAreaHit = None; mFocusOnMouseWheel = false; mBitmapName = StringTable->insert( "" ); + mMouseDownTime = 0; + mNumberOfBitmaps = 0; } GuiTextEditSliderBitmapCtrl::~GuiTextEditSliderBitmapCtrl() @@ -444,4 +446,4 @@ void GuiTextEditSliderBitmapCtrl::setBitmap(const char *name) if(awake) onWake(); setUpdate(); -} \ No newline at end of file +} diff --git a/Engine/source/gui/controls/guiTextEditSliderCtrl.cpp b/Engine/source/gui/controls/guiTextEditSliderCtrl.cpp index a3e9c884f..599678fc3 100644 --- a/Engine/source/gui/controls/guiTextEditSliderCtrl.cpp +++ b/Engine/source/gui/controls/guiTextEditSliderCtrl.cpp @@ -62,6 +62,7 @@ GuiTextEditSliderCtrl::GuiTextEditSliderCtrl() mFormat = StringTable->insert("%3.2f"); mTextAreaHit = None; mFocusOnMouseWheel = false; + mMouseDownTime = 0.0f; } GuiTextEditSliderCtrl::~GuiTextEditSliderCtrl() diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index 10191b0da..d774a52e1 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -150,6 +150,7 @@ GuiCanvas::GuiCanvas(): GuiControl(), #else mNumFences = 0; #endif + mConsumeLastInputEvent = false; } GuiCanvas::~GuiCanvas() diff --git a/Engine/source/gui/core/guiScriptNotifyControl.cpp b/Engine/source/gui/core/guiScriptNotifyControl.cpp index bd1cc63de..93ec5bb90 100644 --- a/Engine/source/gui/core/guiScriptNotifyControl.cpp +++ b/Engine/source/gui/core/guiScriptNotifyControl.cpp @@ -57,6 +57,8 @@ GuiScriptNotifyCtrl::GuiScriptNotifyCtrl() mOnResize = false; mOnChildResized = false; mOnParentResized = false; + mOnLoseFirstResponder = true; + mOnGainFirstResponder = true; } GuiScriptNotifyCtrl::~GuiScriptNotifyCtrl() diff --git a/Engine/source/gui/core/guiTypes.cpp b/Engine/source/gui/core/guiTypes.cpp index 7fbbe62c0..7ef0ef4ad 100644 --- a/Engine/source/gui/core/guiTypes.cpp +++ b/Engine/source/gui/core/guiTypes.cpp @@ -79,6 +79,7 @@ GuiCursor::GuiCursor() mRenderOffset.set(0.0f,0.0f); mExtent.set(1,1); mTextureObject = NULL; + mBitmapName = StringTable->EmptyString(); } GuiCursor::~GuiCursor() diff --git a/Engine/source/gui/editor/guiDebugger.cpp b/Engine/source/gui/editor/guiDebugger.cpp index 7c60d4359..4ad0e6683 100644 --- a/Engine/source/gui/editor/guiDebugger.cpp +++ b/Engine/source/gui/editor/guiDebugger.cpp @@ -64,6 +64,12 @@ DbgFileView::DbgFileView() mFindLineNumber = -1; mSize.set(1, 0); + mbMouseDragging = false; + mMouseDownChar = -1; + mMouseOverVariable[0] = '\0'; + mMouseOverValue[0] = '\0'; + mMouseVarStart = -1; + mMouseVarEnd = -1; } DefineEngineMethod(DbgFileView, setCurrentLine, void, (S32 line, bool selected), , "(int line, bool selected)" diff --git a/Engine/source/gui/editor/guiEditCtrl.cpp b/Engine/source/gui/editor/guiEditCtrl.cpp index 208c9b4fc..6be77962c 100644 --- a/Engine/source/gui/editor/guiEditCtrl.cpp +++ b/Engine/source/gui/editor/guiEditCtrl.cpp @@ -101,7 +101,9 @@ GuiEditCtrl::GuiEditCtrl() mDrawBorderLines( true ), mFullBoxSelection( false ), mSnapSensitivity( 2 ), - mDrawGuides( true ) + mDrawGuides( true ), + mDragAddSelection(false), + mDragMoveUndo(false) { VECTOR_SET_ASSOCIATION( mSelectedControls ); VECTOR_SET_ASSOCIATION( mDragBeginPoints ); @@ -116,11 +118,21 @@ GuiEditCtrl::GuiEditCtrl() mDragGuide[ GuideVertical ] = false; mDragGuide[ GuideHorizontal ] = false; + mDragGuideIndex[0] = 0; + mDragGuideIndex[1] = 1; + + std::fill_n(mSnapOffset, 2, 0); + std::fill_n(mSnapEdge, 2, SnapEdgeMin); if( !smGuidesPropertyName[ GuideVertical ] ) smGuidesPropertyName[ GuideVertical ] = StringTable->insert( "guidesVertical" ); if( !smGuidesPropertyName[ GuideHorizontal ] ) smGuidesPropertyName[ GuideHorizontal ] = StringTable->insert( "guidesHorizontal" ); + + mTrash = NULL; + mSelectedSet = NULL; + mMouseDownMode = GuiEditCtrl::Selecting; + mSizingMode = GuiEditCtrl::sizingNone; } //----------------------------------------------------------------------------- diff --git a/Engine/source/gui/editor/guiInspectorTypes.cpp b/Engine/source/gui/editor/guiInspectorTypes.cpp index 0e8f341a4..818df2ba1 100644 --- a/Engine/source/gui/editor/guiInspectorTypes.cpp +++ b/Engine/source/gui/editor/guiInspectorTypes.cpp @@ -1087,7 +1087,7 @@ bool GuiInspectorTypeEaseF::updateRects() // GuiInspectorTypeColor (Base for ColorI/LinearColorF) //----------------------------------------------------------------------------- GuiInspectorTypeColor::GuiInspectorTypeColor() - : mBrowseButton( NULL ) + : mColorFunction(NULL), mBrowseButton( NULL ) { } diff --git a/Engine/source/gui/editor/guiParticleGraphCtrl.cpp b/Engine/source/gui/editor/guiParticleGraphCtrl.cpp index 4b71a1518..d27be2f1a 100644 --- a/Engine/source/gui/editor/guiParticleGraphCtrl.cpp +++ b/Engine/source/gui/editor/guiParticleGraphCtrl.cpp @@ -102,6 +102,8 @@ GuiParticleGraphCtrl::GuiParticleGraphCtrl() mPointXMovementClamped = false; mOutlineColor = ColorI(1, 1, 1); mCursorPos = Point2I(0, 0); + mTooltipSelectedPlot = 0; + mRenderNextGraphTooltip = false; } ImplementEnumType( GuiParticleGraphType, diff --git a/Engine/source/gui/editor/guiPopupMenuCtrl.cpp b/Engine/source/gui/editor/guiPopupMenuCtrl.cpp index 9fb25c497..e405864cf 100644 --- a/Engine/source/gui/editor/guiPopupMenuCtrl.cpp +++ b/Engine/source/gui/editor/guiPopupMenuCtrl.cpp @@ -95,6 +95,7 @@ GuiPopupMenuTextListCtrl::GuiPopupMenuTextListCtrl() mPopup = nullptr; mLastHighlightedMenuIdx = -1; + mBackground = NULL; } void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver) @@ -258,4 +259,4 @@ void GuiPopupMenuTextListCtrl::onCellHighlighted(Point2I cell) list->mSubMenu->showPopup(getRoot(), getPosition().x + mCellSize.x, getPosition().y + (selectionIndex * mCellSize.y)); } } -} \ No newline at end of file +} diff --git a/Engine/source/gui/editor/guiShapeEdPreview.cpp b/Engine/source/gui/editor/guiShapeEdPreview.cpp index bb83d85d7..5f8a80279 100644 --- a/Engine/source/gui/editor/guiShapeEdPreview.cpp +++ b/Engine/source/gui/editor/guiShapeEdPreview.cpp @@ -69,6 +69,7 @@ GuiShapeEdPreview::GuiShapeEdPreview() mRenderNodes( false ), mRenderBounds( false ), mRenderObjBox( false ), + mRenderColMeshes( false ), mRenderMounts( true ), mSunDiffuseColor( 255, 255, 255, 255 ), mSelectedNode( -1 ), diff --git a/Engine/source/gui/editor/inspector/customField.cpp b/Engine/source/gui/editor/inspector/customField.cpp index 27feb7ebe..ac92f37bd 100644 --- a/Engine/source/gui/editor/inspector/customField.cpp +++ b/Engine/source/gui/editor/inspector/customField.cpp @@ -42,13 +42,15 @@ GuiInspectorCustomField::GuiInspectorCustomField( GuiInspector *inspector, { mInspector = inspector; mParent = parent; - setBounds(0,0,100,20); + setBounds(0,0,100,20); + mDoc = StringTable->insert("no Docs Found!"); } GuiInspectorCustomField::GuiInspectorCustomField() { mInspector = NULL; mParent = NULL; + mDoc = StringTable->insert("no Docs Found!"); } void GuiInspectorCustomField::setData( const char* data, bool callbacks ) diff --git a/Engine/source/gui/editor/inspector/dynamicField.h b/Engine/source/gui/editor/inspector/dynamicField.h index 405717295..477873395 100644 --- a/Engine/source/gui/editor/inspector/dynamicField.h +++ b/Engine/source/gui/editor/inspector/dynamicField.h @@ -34,7 +34,7 @@ class GuiInspectorDynamicField : public GuiInspectorField public: GuiInspectorDynamicField( GuiInspector *inspector, GuiInspectorGroup* parent, SimFieldDictionary::Entry* field ); - GuiInspectorDynamicField() {}; + GuiInspectorDynamicField() :mDynField(NULL), mDeleteButton(NULL) {}; ~GuiInspectorDynamicField() {}; DECLARE_CONOBJECT( GuiInspectorDynamicField ); diff --git a/Engine/source/gui/editor/inspector/dynamicGroup.h b/Engine/source/gui/editor/inspector/dynamicGroup.h index 65708159d..fdc8d19c2 100644 --- a/Engine/source/gui/editor/inspector/dynamicGroup.h +++ b/Engine/source/gui/editor/inspector/dynamicGroup.h @@ -37,9 +37,9 @@ private: public: DECLARE_CONOBJECT(GuiInspectorDynamicGroup); - GuiInspectorDynamicGroup() { /*mNeedScroll=false;*/ }; + GuiInspectorDynamicGroup() { mAddCtrl = NULL;/*mNeedScroll=false;*/ }; GuiInspectorDynamicGroup( StringTableEntry groupName, SimObjectPtr parent ) - : GuiInspectorGroup( groupName, parent) { /*mNeedScroll=false;*/}; + : GuiInspectorGroup( groupName, parent) { mAddCtrl = NULL;/*mNeedScroll=false;*/}; //----------------------------------------------------------------------------- // inspectGroup is overridden in GuiInspectorDynamicGroup to inspect an diff --git a/Engine/source/gui/editor/inspector/field.cpp b/Engine/source/gui/editor/inspector/field.cpp index ccbb2f55f..84fc4ccfc 100644 --- a/Engine/source/gui/editor/inspector/field.cpp +++ b/Engine/source/gui/editor/inspector/field.cpp @@ -52,7 +52,11 @@ GuiInspectorField::GuiInspectorField( GuiInspector* inspector, mEdit( NULL ), mTargetObject(NULL), mUseHeightOverride(false), - mHeightOverride(18) + mHighlighted(false), + mHeightOverride(18), + mSpecialEditField(false), + mVariableName(StringTable->EmptyString()), + mCallbackName(StringTable->EmptyString()) { if( field != NULL ) mCaption = field->pFieldname; diff --git a/Engine/source/gui/editor/inspector/variableField.cpp b/Engine/source/gui/editor/inspector/variableField.cpp index 8f39fb65d..63ed1cb1d 100644 --- a/Engine/source/gui/editor/inspector/variableField.cpp +++ b/Engine/source/gui/editor/inspector/variableField.cpp @@ -41,7 +41,10 @@ ConsoleDocClass( GuiInspectorVariableField, "@internal" ); -GuiInspectorVariableField::GuiInspectorVariableField() +GuiInspectorVariableField::GuiInspectorVariableField() + : mVariableName(StringTable->EmptyString()), + mSetCallbackName(StringTable->EmptyString()), + mOwnerObject(NULL) { } diff --git a/Engine/source/gui/game/guiMessageVectorCtrl.cpp b/Engine/source/gui/game/guiMessageVectorCtrl.cpp index 9f5f45800..2b2d12fc0 100644 --- a/Engine/source/gui/game/guiMessageVectorCtrl.cpp +++ b/Engine/source/gui/game/guiMessageVectorCtrl.cpp @@ -164,6 +164,7 @@ GuiMessageVectorCtrl::GuiMessageVectorCtrl() VECTOR_SET_ASSOCIATION(mLineElements); mMessageVector = NULL; + mMinSensibleWidth = 1; mLineSpacingPixels = 0; mLineContinuationIndent = 10; diff --git a/Engine/source/gui/game/guiProgressBitmapCtrl.cpp b/Engine/source/gui/game/guiProgressBitmapCtrl.cpp index df06e242d..1d7d621e7 100644 --- a/Engine/source/gui/game/guiProgressBitmapCtrl.cpp +++ b/Engine/source/gui/game/guiProgressBitmapCtrl.cpp @@ -121,7 +121,9 @@ GuiProgressBitmapCtrl::GuiProgressBitmapCtrl() : mProgress( 0.f ), mBitmapName( StringTable->EmptyString() ), mUseVariable( false ), - mTile( false ) + mTile( false ), + mNumberOfBitmaps(0), + mDim(0) { } diff --git a/Engine/source/gui/utility/guiBubbleTextCtrl.h b/Engine/source/gui/utility/guiBubbleTextCtrl.h index 909644c74..c8175d0f7 100644 --- a/Engine/source/gui/utility/guiBubbleTextCtrl.h +++ b/Engine/source/gui/utility/guiBubbleTextCtrl.h @@ -52,7 +52,7 @@ class GuiBubbleTextCtrl : public GuiTextCtrl DECLARE_DESCRIPTION( "A single-line text control that displays its text in a multi-line\n" "popup when clicked." ); - GuiBubbleTextCtrl() { mInAction = false; } + GuiBubbleTextCtrl() :mInAction(false), mDlg(NULL), mPopup(NULL), mMLText(NULL) {} virtual void onMouseDown(const GuiEvent &event); }; diff --git a/Engine/source/gui/worldEditor/creator.cpp b/Engine/source/gui/worldEditor/creator.cpp index 99264f4ba..c268787eb 100644 --- a/Engine/source/gui/worldEditor/creator.cpp +++ b/Engine/source/gui/worldEditor/creator.cpp @@ -146,7 +146,9 @@ S32 CreatorTree::Node::getSelected() CreatorTree::CreatorTree() : mCurId(0), mRoot(0), - mTxtOffset(5) + mTxtOffset(5), + mTabSize(11), + mMaxWidth(0) { VECTOR_SET_ASSOCIATION(mNodeList); clear(); diff --git a/Engine/source/gui/worldEditor/editTSCtrl.cpp b/Engine/source/gui/worldEditor/editTSCtrl.cpp index 8d9f98809..fbe4ff090 100644 --- a/Engine/source/gui/worldEditor/editTSCtrl.cpp +++ b/Engine/source/gui/worldEditor/editTSCtrl.cpp @@ -106,7 +106,7 @@ EditTSCtrl::EditTSCtrl() mMiddleMouseDown = false; mMiddleMouseTriggered = false; mMouseLeft = false; - + mLastMouseClamping = false; mBlendSB = NULL; } diff --git a/Engine/source/gui/worldEditor/gizmo.cpp b/Engine/source/gui/worldEditor/gizmo.cpp index 4b0ac19ab..7bfe554c4 100644 --- a/Engine/source/gui/worldEditor/gizmo.cpp +++ b/Engine/source/gui/worldEditor/gizmo.cpp @@ -202,6 +202,7 @@ GizmoProfile::GizmoProfile() centroidColor.set( 255, 255, 255 ); centroidHighlightColor.set( 255, 0, 255 ); + hideDisabledAxes = true; restoreDefaultState(); } @@ -297,6 +298,7 @@ Gizmo::Gizmo() mObjectMat( true ), mTransform( true ), mCameraMat( true ), + mProjLen(1000.0f), mSelectionIdx( -1 ), mObjectMatInv( true ), mCurrentTransform( true ), @@ -308,10 +310,13 @@ Gizmo::Gizmo() mCurrentAlignment( World ), mDeltaTotalScale( 0,0,0 ), mDeltaTotalRot( 0,0,0 ), + mDeltaAngle(0.0f), + mLastAngle(0.0f), mDeltaTotalPos( 0,0,0 ), mCurrentMode( MoveMode ), mMouseDownPos( -1,-1 ), mDirty( false ), + mSign(0.0f), mMouseDown( false ), mLastWorldMat( true ), mLastProjMat( true ), @@ -324,9 +329,10 @@ Gizmo::Gizmo() mHighlightAll( false ), mMoveGridEnabled( true ), mMoveGridSize( 20.f ), - mMoveGridSpacing( 1.f ) -{ - mUniformHandleEnabled = true; + mMoveGridSpacing( 1.f ), + mUniformHandleEnabled(true), + mScreenRotateHandleEnabled(false) +{ mAxisEnabled[0] = mAxisEnabled[1] = mAxisEnabled[2] = true; } diff --git a/Engine/source/gui/worldEditor/gizmo.h b/Engine/source/gui/worldEditor/gizmo.h index a9baf1aa1..5cc64514a 100644 --- a/Engine/source/gui/worldEditor/gizmo.h +++ b/Engine/source/gui/worldEditor/gizmo.h @@ -391,9 +391,9 @@ protected: /// Spacing between grid lines on the move grid. U32 mMoveGridSpacing; - bool mAxisEnabled[3]; bool mUniformHandleEnabled; bool mScreenRotateHandleEnabled; + bool mAxisEnabled[3]; // Used to override rendering of handles. bool mHighlightCentroidHandle; diff --git a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp index 5f1b32638..a53b0e641 100644 --- a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp +++ b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.cpp @@ -68,6 +68,7 @@ GuiConvexEditorCtrl::GuiConvexEditorCtrl() mFaceHL( -1 ), mFaceSavedXfm( true ), mSavedUndo( false ), + mHasGeometry(false), mDragging( false ), mGizmoMatOffset( Point3F::Zero ), mPivotPos( Point3F::Zero ), diff --git a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.h b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.h index 3f4b91606..6ede0cf61 100644 --- a/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.h +++ b/Engine/source/gui/worldEditor/guiConvexShapeEditorCtrl.h @@ -248,7 +248,7 @@ class GuiConvexEditorUndoAction : public UndoAction friend class GuiConvexEditorCtrl; public: - GuiConvexEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName ) + GuiConvexEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName ), mEditor(NULL), mObjId(NULL) { } diff --git a/Engine/source/gui/worldEditor/guiMissionArea.h b/Engine/source/gui/worldEditor/guiMissionArea.h index fb1d1cd85..caa0527cb 100644 --- a/Engine/source/gui/worldEditor/guiMissionArea.h +++ b/Engine/source/gui/worldEditor/guiMissionArea.h @@ -142,7 +142,7 @@ class GuiMissionAreaUndoAction : public UndoAction { public: - GuiMissionAreaUndoAction( const UTF8* actionName ) : UndoAction( actionName ) + GuiMissionAreaUndoAction( const UTF8* actionName ) : UndoAction( actionName ), mMissionAreaEditor(NULL), mObjId(NULL) { } diff --git a/Engine/source/gui/worldEditor/terrainActions.cpp b/Engine/source/gui/worldEditor/terrainActions.cpp index b64cade26..3fc07205d 100644 --- a/Engine/source/gui/worldEditor/terrainActions.cpp +++ b/Engine/source/gui/worldEditor/terrainActions.cpp @@ -773,7 +773,7 @@ ConsoleDocClass( TerrainSmoothAction, ); TerrainSmoothAction::TerrainSmoothAction() - : UndoAction( "Terrain Smoothing" ) + : UndoAction("Terrain Smoothing"), mFactor(1.0), mSteps(1), mTerrainId(NULL) { } @@ -836,4 +836,4 @@ void TerrainSmoothAction::redo() // Tell the terrain to update itself. terrain->updateGrid( Point2I::Zero, Point2I::Max, true ); -} \ No newline at end of file +} diff --git a/Engine/source/gui/worldEditor/terrainActions.h b/Engine/source/gui/worldEditor/terrainActions.h index e0e31d988..2fc0b2df5 100644 --- a/Engine/source/gui/worldEditor/terrainActions.h +++ b/Engine/source/gui/worldEditor/terrainActions.h @@ -211,7 +211,7 @@ class ScaleHeightAction : public TerrainAction class BrushAdjustHeightAction : public TerrainAction { public: - BrushAdjustHeightAction(TerrainEditor * editor) : TerrainAction(editor){} + BrushAdjustHeightAction(TerrainEditor* editor) : TerrainAction(editor) { mPreviousZ = 0.0f; } StringTableEntry getName(){return("brushAdjustHeight");} void process(Selection * sel, const Gui3DMouseEvent & event, bool selChanged, Type type); diff --git a/Engine/source/gui/worldEditor/undoActions.cpp b/Engine/source/gui/worldEditor/undoActions.cpp index de23353d8..2f137bc72 100644 --- a/Engine/source/gui/worldEditor/undoActions.cpp +++ b/Engine/source/gui/worldEditor/undoActions.cpp @@ -219,6 +219,7 @@ ConsoleDocClass( InspectorFieldUndoAction, InspectorFieldUndoAction::InspectorFieldUndoAction() { + mInspector = NULL; mObjId = 0; mField = NULL; mSlotName = StringTable->EmptyString(); diff --git a/Engine/source/gui/worldEditor/worldEditor.h b/Engine/source/gui/worldEditor/worldEditor.h index d52ecd699..e903e024b 100644 --- a/Engine/source/gui/worldEditor/worldEditor.h +++ b/Engine/source/gui/worldEditor/worldEditor.h @@ -133,6 +133,7 @@ class WorldEditor : public EditTSCtrl WorldEditorUndoAction( const UTF8* actionName ) : UndoAction( actionName ) { + mWorldEditor = NULL; } WorldEditor *mWorldEditor; diff --git a/Engine/source/lighting/advanced/advancedLightBinManager.h b/Engine/source/lighting/advanced/advancedLightBinManager.h index aca1d2024..8b256f533 100644 --- a/Engine/source/lighting/advanced/advancedLightBinManager.h +++ b/Engine/source/lighting/advanced/advancedLightBinManager.h @@ -70,7 +70,7 @@ protected: GFXStateBlockRef mLitState[NUM_LIT_STATES][2]; public: - LightMatInstance(Material &mat) : Parent(mat), mLightMapParamsSC(NULL), mInternalPass(false) {} + LightMatInstance(Material &mat) : Parent(mat), mLightMapParamsSC(NULL), mInternalPass(false), mSpecialLight(NULL) {} virtual bool init( const FeatureSet &features, const GFXVertexFormat *vertexFormat ); virtual bool setupPass( SceneRenderState *state, const SceneData &sgData ); diff --git a/Engine/source/lighting/advanced/advancedLightManager.cpp b/Engine/source/lighting/advanced/advancedLightManager.cpp index bc16efe7a..00704c2bc 100644 --- a/Engine/source/lighting/advanced/advancedLightManager.cpp +++ b/Engine/source/lighting/advanced/advancedLightManager.cpp @@ -63,6 +63,9 @@ AdvancedLightManager::AdvancedLightManager() { mLightBinManager = NULL; mLastShader = NULL; + mLastConstants = NULL; + mSpherePrimitiveCount = 0; + mConePrimitiveCount = 0; mAvailableSLInterfaces = NULL; } diff --git a/Engine/source/lighting/common/blobShadow.cpp b/Engine/source/lighting/common/blobShadow.cpp index f0d87be28..34da7fcb4 100644 --- a/Engine/source/lighting/common/blobShadow.cpp +++ b/Engine/source/lighting/common/blobShadow.cpp @@ -55,7 +55,7 @@ BlobShadow::BlobShadow(SceneObject* parentObject, LightInfo* light, TSShapeInsta mRadius = 0.0f; mLastRenderTime = 0; mDepthBias = -0.0002f; - + mInvShadowDistance = 1.0f; generateGenericShadowBitmap(smGenericShadowDim); setupStateBlocks(); } diff --git a/Engine/source/lighting/common/sceneLighting.cpp b/Engine/source/lighting/common/sceneLighting.cpp index cdaf4a2b8..afc83f9ba 100644 --- a/Engine/source/lighting/common/sceneLighting.cpp +++ b/Engine/source/lighting/common/sceneLighting.cpp @@ -440,7 +440,8 @@ SceneLighting::SceneLighting(AvailableSLInterfaces* lightingInterfaces) mStartTime = 0; mFileName[0] = '\0'; mSceneManager = NULL; - + sgTimeTemp = 0; + sgTimeTemp2 = 0; // Registering vars more than once doesn't hurt anything. Con::addVariable("$sceneLighting::terminateLighting", TypeBool, &gTerminateLighting); Con::addVariable("$sceneLighting::lightingProgress", TypeF32, &gLightingProgress); @@ -1084,4 +1085,4 @@ bool SceneLighting::ObjectProxy::setPersistInfo(PersistInfo::PersistChunk * chun { mChunkCRC = chunk->mChunkCRC; return(true); -} \ No newline at end of file +} diff --git a/Engine/source/lighting/shadowMap/pssmLightShadowMap.cpp b/Engine/source/lighting/shadowMap/pssmLightShadowMap.cpp index 3bdf6a8b7..86e4bc6bc 100644 --- a/Engine/source/lighting/shadowMap/pssmLightShadowMap.cpp +++ b/Engine/source/lighting/shadowMap/pssmLightShadowMap.cpp @@ -64,8 +64,12 @@ F32 PSSMLightShadowMap::smSmallestVisiblePixelSize = 25.0f; PSSMLightShadowMap::PSSMLightShadowMap( LightInfo *light ) : LightShadowMap( light ), - mNumSplits( 1 ) -{ + mNumSplits( 1 ), + mLogWeight(0.91f) +{ + for (U32 i = 0; i <= MAX_SPLITS; i++) //% depth distance + mSplitDist[i] = mPow(F32(i/MAX_SPLITS),2.0f); + mIsViewDependent = true; } diff --git a/Engine/source/lighting/shadowMap/shadowMapPass.h b/Engine/source/lighting/shadowMap/shadowMapPass.h index d860da79b..8e1fa0ef5 100644 --- a/Engine/source/lighting/shadowMap/shadowMapPass.h +++ b/Engine/source/lighting/shadowMap/shadowMapPass.h @@ -52,7 +52,7 @@ class ShadowMapPass { public: - ShadowMapPass() {} // Only called by ConsoleSystem + ShadowMapPass() : mTimer(NULL), mLightManager(NULL), mShadowManager(NULL), mActiveLights(0), mPrevCamFov(90.0f) {} // Only called by ConsoleSystem ShadowMapPass(LightManager* LightManager, ShadowMapManager* ShadowManager); virtual ~ShadowMapPass(); diff --git a/Engine/source/materials/customShaderBindingData.h b/Engine/source/materials/customShaderBindingData.h index 29271d33f..444fa6b9a 100644 --- a/Engine/source/materials/customShaderBindingData.h +++ b/Engine/source/materials/customShaderBindingData.h @@ -29,13 +29,13 @@ public: Matrix4x4 }; private: - StringTableEntry targetedUniformName; + StringTableEntry targetedUniformName = StringTable->EmptyString(); //ShaderConstHandles shaderConstHandle; - UniformType type; + UniformType type = CustomShaderBindingData::Float; - F32 mFloat; + F32 mFloat = 0.0f; Point2F mFloat2; Point3F mFloat3; Point4F mFloat4; @@ -49,7 +49,7 @@ public: { targetedUniformName = shaderConstName; mFloat = f; - type = Float; + type = UniformType::Float; } F32 getFloat() { return mFloat; } diff --git a/Engine/source/materials/materialDefinition.cpp b/Engine/source/materials/materialDefinition.cpp index 8f7e110ac..83a711343 100644 --- a/Engine/source/materials/materialDefinition.cpp +++ b/Engine/source/materials/materialDefinition.cpp @@ -97,6 +97,8 @@ ImplementEnumType( MaterialWaveType, { Material::Square, "Square", "Warps the material along a wave which transitions between two oppposite states. As a Square Wave, the transition is quick and sudden." }, EndImplementEnumType; +#define initMapSlot(name,id) m##name##Filename[id] = String::EmptyString; m##name##AssetId[id] = StringTable->EmptyString(); m##name##Asset[id] = NULL; +#define bindMapSlot(name,id) if (m##name##AssetId[id] != String::EmptyString) m##name##Asset[id] = m##name##AssetId[id]; bool Material::sAllowTextureTargetAssignment = false; @@ -111,19 +113,18 @@ GFXCubemap * Material::GetNormalizeCube() GFXCubemapHandle Material::smNormalizeCube; + Material::Material() { for( U32 i=0; iEmptyString(); - mDiffuseMapAssetId[i] = StringTable->EmptyString(); mSmoothness[i] = 0.0f; mMetalness[i] = 0.0f; - mIsSRGb[i] = false; + mIsSRGb[i] = true; mInvertSmoothness[i] = false; mSmoothnessChan[i] = 0; @@ -136,7 +137,25 @@ Material::Material() mAccuStrength[i] = 0.6f; mAccuCoverage[i] = 0.9f; mAccuSpecular[i] = 16.0f; - + + initMapSlot(DiffuseMap, i); + initMapSlot(OverlayMap, i); + initMapSlot(LightMap, i); + initMapSlot(ToneMap, i); + initMapSlot(DetailMap, i); + initMapSlot(NormalMap, i); + initMapSlot(PBRConfigMap, i); + initMapSlot(RoughMap, i); + initMapSlot(AOMap, i); + initMapSlot(MetalMap, i); + initMapSlot(GlowMap, i); + initMapSlot(DetailNormalMap, i); + + //cogs specific + initMapSlot(AlbedoDamageMap, i); + initMapSlot(NormalDamageMap, i); + initMapSlot(CompositeDamageMap, i); + mParallaxScale[i] = 0.0f; mVertLit[i] = false; @@ -174,13 +193,10 @@ Material::Material() // Deferred Shading mMatInfoFlags[i] = 0.0f; - mRoughMapFilename[i].clear(); - mRoughMapAsset[i] = StringTable->EmptyString(); - mAOMapFilename[i].clear(); - mMetalMapFilename[i].clear(); - mMetalMapAsset[i] = StringTable->EmptyString(); - mGlowMapFilename[i].clear(); - mGlowMapAsset[i] = StringTable->EmptyString(); + + // Damage + mMaterialDamageMin[i] = 0.0f; + mAlbedoDamageMapSRGB[i] = true; mGlowMul[i] = 0.0f; } @@ -218,6 +234,7 @@ Material::Material() dMemset( mEffectColor, 0, sizeof( mEffectColor ) ); mFootstepSoundId = -1; mImpactSoundId = -1; + mImpactFXIndex = -1; mFootstepSoundCustom = 0; mImpactSoundCustom = 0; mFriction = 0.0; @@ -225,6 +242,11 @@ Material::Material() mReverbSoundOcclusion = 1.0; } + +#define assetText(x,suff) std::string(std::string(#x) + std::string(#suff)).c_str() +#define scriptBindMapSlot(name,arraySize) addField(#name, TypeImageFilename, Offset(m##name##Filename, Material), arraySize, assetText(name,texture map.)); \ + addField(assetText(name,Asset), TypeImageAssetPtr, Offset(m##name##AssetId, Material), arraySize, assetText(name,asset reference.)); + void Material::initPersistFields() { addField("mapTo", TypeRealString, Offset(mMapTo, Material), @@ -236,38 +258,25 @@ void Material::initPersistFields() "This color is multiplied against the diffuse texture color. If no diffuse texture " "is present this is the material color." ); - addField("diffuseMap", TypeImageFilename, Offset(mDiffuseMapFilename, Material), MAX_STAGES, - "The diffuse color texture map." ); - - addField("diffuseMapAsset", TypeImageAssetPtr, Offset(mDiffuseMapAssetId, Material), MAX_STAGES, - "The diffuse color texture map." ); + scriptBindMapSlot(DiffuseMap, MAX_STAGES); + scriptBindMapSlot(OverlayMap, MAX_STAGES); + scriptBindMapSlot(LightMap, MAX_STAGES); + scriptBindMapSlot(ToneMap, MAX_STAGES); + scriptBindMapSlot(DetailMap, MAX_STAGES); + scriptBindMapSlot(NormalMap, MAX_STAGES); + scriptBindMapSlot(PBRConfigMap, MAX_STAGES); + scriptBindMapSlot(RoughMap, MAX_STAGES); + scriptBindMapSlot(AOMap, MAX_STAGES); + scriptBindMapSlot(MetalMap, MAX_STAGES); + scriptBindMapSlot(GlowMap, MAX_STAGES); + scriptBindMapSlot(DetailNormalMap, MAX_STAGES); addField("diffuseMapSRGB", TypeBool, Offset(mDiffuseMapSRGB, Material), MAX_STAGES, "Enable sRGB for the diffuse color texture map."); - addField("overlayMap", TypeImageFilename, Offset(mOverlayMapFilename, Material), MAX_STAGES, - "A secondary diffuse color texture map which will use the second texcoord of a mesh." ); - - addField("lightMap", TypeImageFilename, Offset(mLightMapFilename, Material), MAX_STAGES, - "The lightmap texture used with pureLight." ); - - addField("toneMap", TypeImageFilename, Offset(mToneMapFilename, Material), MAX_STAGES, - "The tonemap texture used with pureLight."); - - addField("detailMap", TypeImageFilename, Offset(mDetailMapFilename, Material), MAX_STAGES, - "A typically greyscale detail texture additively blended into the material." ); - addField("detailScale", TypePoint2F, Offset(mDetailScale, Material), MAX_STAGES, "The scale factor for the detail map." ); - addField( "normalMap", TypeImageFilename, Offset(mNormalMapFilename, Material), MAX_STAGES, - "The normal map texture. You can use the DXTnm format only when per-pixel " - "specular highlights are disabled, or a specular map is in use." ); - - addField( "detailNormalMap", TypeImageFilename, Offset(mDetailNormalMapFilename, Material), MAX_STAGES, - "A second normal map texture applied at the detail scale. You can use the DXTnm " - "format only when per-pixel specular highlights are disabled." ); - addField( "detailNormalMapStrength", TypeF32, Offset(mDetailNormalMapStrength, Material), MAX_STAGES, "Used to scale the strength of the detail normal map when blended with the base normal map." ); @@ -304,27 +313,14 @@ void Material::initPersistFields() addField("invertSmoothness", TypeBool, Offset(mInvertSmoothness, Material), MAX_STAGES, "Treat Smoothness as Roughness"); - addField( "PBRConfigMap", TypeImageFilename, Offset(mPBRConfigMapFilename, Material), MAX_STAGES, - "Prepacked specular map texture. The RGB channels of this texture provide per-pixel reference values for: " - "smoothness (R), Ambient Occlusion (G), and metalness(B)"); - - addField("roughMap", TypeImageFilename, Offset(mRoughMapFilename, Material), MAX_STAGES, - "smoothness map. will be packed into the R channel of a packed 'specular' map"); addField("smoothnessChan", TypeF32, Offset(mSmoothnessChan, Material), MAX_STAGES, "The input channel smoothness maps use."); - addField("aoMap", TypeImageFilename, Offset(mAOMapFilename, Material), MAX_STAGES, - "Ambient Occlusion map. will be packed into the G channel of a packed 'specular' map"); addField("AOChan", TypeF32, Offset(mAOChan, Material), MAX_STAGES, "The input channel AO maps use."); - - addField("metalMap", TypeImageFilename, Offset(mMetalMapFilename, Material), MAX_STAGES, - "Metalness map. will be packed into the B channel of a packed 'specular' map"); addField("metalChan", TypeF32, Offset(mMetalChan, Material), MAX_STAGES, "The input channel metalness maps use."); - addField("glowMap", TypeImageFilename, Offset(mGlowMapFilename, Material), MAX_STAGES, - "Metalness map. will be packed into the B channel of a packed 'specular' map"); addField("glowMul", TypeF32, Offset(mGlowMul, Material), MAX_STAGES, "The input channel metalness maps use."); addField("glow", TypeBool, Offset(mGlow, Material), MAX_STAGES, @@ -426,6 +422,22 @@ void Material::initPersistFields() endArray( "Stages" ); + addGroup("Damage"); + + //cogs + scriptBindMapSlot(AlbedoDamageMap, MAX_STAGES); + /// Damage blend maps (normal) + scriptBindMapSlot(NormalDamageMap, MAX_STAGES); + /// Damage blend maps (Roughness, AO, Metalness) + scriptBindMapSlot(CompositeDamageMap, MAX_STAGES); + + addField("albedoDamageSRGB", TypeBool, Offset(mAlbedoDamageMapSRGB, Material), MAX_STAGES, + "Enable sRGB for the albedo damage map"); + + addField("minDamage", TypeF32, Offset(mMaterialDamageMin, Material), MAX_STAGES, + "The minimum ammount of blended damage."); + endGroup("Damage"); + addField( "castShadows", TypeBool, Offset(mCastShadows, Material), "If set to false the lighting system will not cast shadows from this material." ); @@ -498,6 +510,10 @@ void Material::initPersistFields() "What sound to play from the PlayerData sound list when the player impacts on the surface with a velocity equal or greater " "than PlayerData::groundImpactMinSpeed.\n\n" "For a list of IDs, see #footstepSoundId" ); + addField("ImpactFXIndex", TypeS32, Offset(mImpactFXIndex, Material), + "What FX to play from the PlayerData sound list when the player impacts on the surface with a velocity equal or greater " + "than PlayerData::groundImpactMinSpeed.\n\n" + "For a list of IDs, see #impactFXId"); addField( "customImpactSound", TypeSFXTrackName, Offset( mImpactSoundCustom, Material ), "The sound to play when the player impacts on the surface with a velocity equal or greater than PlayerData::groundImpactMinSpeed. " "If this is set, it overrides #impactSoundId. This field is useful for directly assigning custom impact sounds to materials " @@ -565,6 +581,7 @@ bool Material::protectedSetCustomShaderFeatureUniforms(void *object, const char return false; } + bool Material::onAdd() { if (Parent::onAdd() == false) @@ -589,6 +606,7 @@ bool Material::onAdd() if ( slash != String::NPos ) mPath = scriptFile.substr( 0, slash + 1 ); + /* //bind any assets we have for (U32 i = 0; i < MAX_STAGES; i++) { @@ -597,6 +615,26 @@ bool Material::onAdd() mDiffuseMapAsset[0] = mDiffuseMapAssetId[0]; } } + */ + for (U32 i = 0; i < MAX_STAGES; i++) + { + bindMapSlot(DiffuseMap, i); + bindMapSlot(OverlayMap, i); + bindMapSlot(LightMap, i); + bindMapSlot(ToneMap, i); + bindMapSlot(DetailMap, i); + bindMapSlot(PBRConfigMap, i); + bindMapSlot(RoughMap, i); + bindMapSlot(AOMap, i); + bindMapSlot(MetalMap, i); + bindMapSlot(GlowMap, i); + bindMapSlot(DetailNormalMap, i); + + //cogs specific + bindMapSlot(AlbedoDamageMap, i); + bindMapSlot(NormalDamageMap, i); + bindMapSlot(CompositeDamageMap, i); + } _mapMaterial(); diff --git a/Engine/source/materials/materialDefinition.h b/Engine/source/materials/materialDefinition.h index 481176a4b..b41c495dd 100644 --- a/Engine/source/materials/materialDefinition.h +++ b/Engine/source/materials/materialDefinition.h @@ -61,6 +61,10 @@ class MaterialSoundProfile; class MaterialPhysicsProfile; class CustomShaderFeatureData; +#define DECLARE_TEXTUREARRAY(name,max) FileName m##name##Filename[max];\ + StringTableEntry m##name##AssetId[max];\ + AssetPtr m##name##Asset[max]; + /// The basic material definition. class Material : public BaseMaterialDefinition { @@ -209,63 +213,48 @@ public: //----------------------------------------------------------------------- // Data //----------------------------------------------------------------------- - FileName mDiffuseMapFilename[MAX_STAGES]; - StringTableEntry mDiffuseMapAssetId[MAX_STAGES]; - AssetPtr mDiffuseMapAsset[MAX_STAGES]; + DECLARE_TEXTUREARRAY(DiffuseMap, MAX_STAGES); bool mDiffuseMapSRGB[MAX_STAGES]; // SRGB diffuse + DECLARE_TEXTUREARRAY(OverlayMap, MAX_STAGES); + DECLARE_TEXTUREARRAY(LightMap, MAX_STAGES);; + DECLARE_TEXTUREARRAY(ToneMap, MAX_STAGES); + DECLARE_TEXTUREARRAY(DetailMap, MAX_STAGES);; + DECLARE_TEXTUREARRAY(NormalMap, MAX_STAGES); + DECLARE_TEXTUREARRAY(PBRConfigMap, MAX_STAGES); + bool mIsSRGb[MAX_STAGES]; + DECLARE_TEXTUREARRAY(RoughMap, MAX_STAGES); + bool mInvertSmoothness[MAX_STAGES]; + F32 mSmoothnessChan[MAX_STAGES]; + DECLARE_TEXTUREARRAY(AOMap, MAX_STAGES); + F32 mAOChan[MAX_STAGES]; + DECLARE_TEXTUREARRAY(MetalMap, MAX_STAGES); + F32 mMetalChan[MAX_STAGES]; + DECLARE_TEXTUREARRAY(GlowMap, MAX_STAGES); + F32 mGlowMul[MAX_STAGES]; + /// A second normal map which repeats at the detail map + /// scale and blended with the base normal map. + DECLARE_TEXTUREARRAY(DetailNormalMap, MAX_STAGES); + /// The strength scalar for the detail normal map. + F32 mDetailNormalMapStrength[MAX_STAGES]; + bool mAccuEnabled[MAX_STAGES]; F32 mAccuScale[MAX_STAGES]; F32 mAccuDirection[MAX_STAGES]; F32 mAccuStrength[MAX_STAGES]; F32 mAccuCoverage[MAX_STAGES]; F32 mAccuSpecular[MAX_STAGES]; - FileName mOverlayMapFilename[MAX_STAGES]; - StringTableEntry mOverlayMapAssetId[MAX_STAGES]; - AssetPtr mOverlayMapAsset[MAX_STAGES]; - FileName mLightMapFilename[MAX_STAGES]; - StringTableEntry mLightMapAssetId[MAX_STAGES]; - AssetPtr mLightMapAsset[MAX_STAGES]; - FileName mToneMapFilename[MAX_STAGES]; - StringTableEntry mToneMapAssetId[MAX_STAGES]; - AssetPtr mToneMapAsset[MAX_STAGES]; - FileName mDetailMapFilename[MAX_STAGES]; - StringTableEntry mDetailMapAssetId[MAX_STAGES]; - AssetPtr mDetailMapAsset[MAX_STAGES]; - FileName mNormalMapFilename[MAX_STAGES]; - StringTableEntry mNormalMapAssetId[MAX_STAGES]; - AssetPtr mNormalMapAsset[MAX_STAGES]; - bool mIsSRGb[MAX_STAGES]; - bool mInvertSmoothness[MAX_STAGES]; - FileName mPBRConfigMapFilename[MAX_STAGES]; - StringTableEntry mPBRConfigMapAssetId[MAX_STAGES]; - AssetPtr mPBRConfigMapAsset[MAX_STAGES]; - FileName mRoughMapFilename[MAX_STAGES]; - StringTableEntry mRoughMapAssetId[MAX_STAGES]; - AssetPtr mRoughMapAsset[MAX_STAGES]; - F32 mSmoothnessChan[MAX_STAGES]; - FileName mAOMapFilename[MAX_STAGES]; - StringTableEntry mAOMapAssetId[MAX_STAGES]; - AssetPtr mAOMapAsset[MAX_STAGES]; - F32 mAOChan[MAX_STAGES]; - FileName mMetalMapFilename[MAX_STAGES]; - StringTableEntry mMetalMapAssetId[MAX_STAGES]; - AssetPtr mMetalMapAsset[MAX_STAGES]; - F32 mMetalChan[MAX_STAGES]; + //cogs specific + /// Damage blend maps (albedo) + DECLARE_TEXTUREARRAY(AlbedoDamageMap, MAX_STAGES); + bool mAlbedoDamageMapSRGB[MAX_STAGES]; + /// Damage blend maps (normal) + DECLARE_TEXTUREARRAY(NormalDamageMap, MAX_STAGES); + /// Damage blend maps (Roughness, AO, Metalness) + DECLARE_TEXTUREARRAY(CompositeDamageMap, MAX_STAGES); + /// Damage blend minimum + F32 mMaterialDamageMin[MAX_STAGES]; - FileName mGlowMapFilename[MAX_STAGES]; - StringTableEntry mGlowMapAssetId[MAX_STAGES]; - AssetPtr mGlowMapAsset[MAX_STAGES]; - F32 mGlowMul[MAX_STAGES]; - /// A second normal map which repeats at the detail map - /// scale and blended with the base normal map. - FileName mDetailNormalMapFilename[MAX_STAGES]; - StringTableEntry mDetailNormalMapAssetId[MAX_STAGES]; - AssetPtr mDetailNormalMapAsset[MAX_STAGES]; - - /// The strength scalar for the detail normal map. - F32 mDetailNormalMapStrength[MAX_STAGES]; - /// This color is the diffuse color of the material /// or if it has a texture it is multiplied against /// the diffuse texture color. @@ -369,6 +358,7 @@ public: /// @see mFootstepSoundCustom S32 mFootstepSoundId; S32 mImpactSoundId; + S32 mImpactFXIndex; /// Sound effect to play when walking on surface with this material. /// If defined, overrides mFootstepSoundId. diff --git a/Engine/source/math/mAngAxis.h b/Engine/source/math/mAngAxis.h index a61b8e4f6..fd02ad8ec 100644 --- a/Engine/source/math/mAngAxis.h +++ b/Engine/source/math/mAngAxis.h @@ -67,6 +67,8 @@ class AngAxisF inline AngAxisF::AngAxisF() { + axis = Point3F(0.0f,0.0f,1.0f); + angle = 0.0f; } inline AngAxisF::AngAxisF( const Point3F & _axis, F32 _angle ) diff --git a/Engine/source/math/mMatrix.h b/Engine/source/math/mMatrix.h index 71a95946b..5c2f3e8ae 100644 --- a/Engine/source/math/mMatrix.h +++ b/Engine/source/math/mMatrix.h @@ -22,7 +22,7 @@ #ifndef _MMATRIX_H_ #define _MMATRIX_H_ - +#include #ifndef _MPLANE_H_ #include "math/mPlane.h" #endif @@ -232,6 +232,8 @@ inline MatrixF::MatrixF(bool _identity) { if (_identity) identity(); + else + std::fill_n(m, 16, 0); } inline MatrixF::MatrixF( const EulerF &e ) diff --git a/Engine/source/math/mPlane.h b/Engine/source/math/mPlane.h index a67d5c60b..6191251ff 100644 --- a/Engine/source/math/mPlane.h +++ b/Engine/source/math/mPlane.h @@ -66,7 +66,7 @@ class PlaneF : public Point3F /// @name Initialization /// @{ - PlaneF() {} + PlaneF() :d(0.0f) {} PlaneF( const Point3F& p, const Point3F& n ); /// NOTE: d is the NEGATIVE distance along the xyz normal. PlaneF( F32 _x, F32 _y, F32 _z, F32 _d); @@ -571,6 +571,7 @@ public: inline PlaneD::PlaneD() { + d = 0.0; } inline PlaneD:: diff --git a/Engine/source/math/mPlaneSet.h b/Engine/source/math/mPlaneSet.h index 511c7bd92..8c83b01d6 100644 --- a/Engine/source/math/mPlaneSet.h +++ b/Engine/source/math/mPlaneSet.h @@ -76,7 +76,7 @@ class PlaneSet /// Create an uninitialized set. /// @warn None of the members will be initialized. - PlaneSet() {} + PlaneSet() :mNumPlanes(0), mPlanes(NULL) {} /// Use the given set of planes to initialize the set. /// diff --git a/Engine/source/math/mPoint2.h b/Engine/source/math/mPoint2.h index c141400b9..d48fea3c9 100644 --- a/Engine/source/math/mPoint2.h +++ b/Engine/source/math/mPoint2.h @@ -266,8 +266,8 @@ class Point2D //-------------------------------------- Point2I // inline Point2I::Point2I() + :x(0),y(0) { - // } @@ -448,8 +448,8 @@ inline Point2I& Point2I::operator/=(const Point2I &_vec) //-------------------------------------- Point2F // inline Point2F::Point2F() + :x(0.0f), y(0.0f) { - // } @@ -692,8 +692,8 @@ inline void Point2F::normalizeSafe() //-------------------------------------- Point2D // inline Point2D::Point2D() + :x(0.0), y(0.0) { - // } diff --git a/Engine/source/math/mPoint3.h b/Engine/source/math/mPoint3.h index 12af91c4b..c1bb72923 100644 --- a/Engine/source/math/mPoint3.h +++ b/Engine/source/math/mPoint3.h @@ -276,8 +276,8 @@ public: //-------------------------------------- Point3I // inline Point3I::Point3I() + : x(0), y(0), z(0) { - // } inline Point3I::Point3I(const Point3I& _copy) @@ -431,9 +431,7 @@ inline Point3I& Point3I::operator/=(S32 div) //-------------------------------------- Point3F // inline Point3F::Point3F() -#if defined(TORQUE_OS_LINUX) - : x(0.f), y(0.f), z(0.f) -#endif + : x(0.0f), y(0.0f), z(0.0f) { // Uninitialized points are definitely a problem. // Enable the following code to see how often they crop up. @@ -761,6 +759,7 @@ inline Point3F& Point3F::operator=(const Point3D &_vec) //-------------------------------------- Point3D // inline Point3D::Point3D() + : x(0.0), y(0.0), z(0.0) { // } diff --git a/Engine/source/math/mPoint4.h b/Engine/source/math/mPoint4.h index 793ff06fc..6fd371af3 100644 --- a/Engine/source/math/mPoint4.h +++ b/Engine/source/math/mPoint4.h @@ -39,7 +39,7 @@ class Point4I { public: - Point4I() {} + Point4I() :x(0), y(0), z(0), w(0) {} Point4I(S32 _x, S32 _y, S32 _z, S32 _w); void zero(); ///< Zero all values @@ -127,6 +127,7 @@ inline void Point4I::zero() //-------------------------------------- Point4F // inline Point4F::Point4F() + :x(0.0f), y(0.0f), z(0.0f), w(0.0f) { } diff --git a/Engine/source/math/mPolyhedron.h b/Engine/source/math/mPolyhedron.h index 3da780e0c..c52d40b8a 100644 --- a/Engine/source/math/mPolyhedron.h +++ b/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() {} + Edge() { std::fill_n(face, 2, 0), std::fill_n(vertex, 0, 0); } Edge( U32 face1, U32 face2, U32 vertex1, U32 vertex2 ) { face[ 0 ] = face1; diff --git a/Engine/source/math/mQuat.h b/Engine/source/math/mQuat.h index 261b66a88..d713b405d 100644 --- a/Engine/source/math/mQuat.h +++ b/Engine/source/math/mQuat.h @@ -42,7 +42,7 @@ public: public: F32 x,y,z,w; - QuatF() {} // no init constructor + QuatF() :x(0.0f), y(0.0f), z(0.0f), w(1.0f) {} //identity constructor QuatF( F32 _x, F32 _y, F32 _z, F32 w ); QuatF( const Point3F &axis, F32 angle ); QuatF( const MatrixF & m ); diff --git a/Engine/source/math/mRandom.h b/Engine/source/math/mRandom.h index 632925228..c69c06477 100644 --- a/Engine/source/math/mRandom.h +++ b/Engine/source/math/mRandom.h @@ -33,7 +33,7 @@ class MRandomGenerator { protected: - MRandomGenerator() {} + MRandomGenerator() :mSeed(-1) {} S32 mSeed; public: diff --git a/Engine/source/math/mSphere.h b/Engine/source/math/mSphere.h index 7990f8f21..8f76dce86 100644 --- a/Engine/source/math/mSphere.h +++ b/Engine/source/math/mSphere.h @@ -35,7 +35,7 @@ public: F32 radius; public: - SphereF() { } + SphereF() :radius(1.0f) {} SphereF( const Point3F& in_rPosition, const F32 in_rRadius ) : center(in_rPosition), radius(in_rRadius) diff --git a/Engine/source/math/util/frustum.h b/Engine/source/math/util/frustum.h index 9de0c4c6a..2129abd7d 100644 --- a/Engine/source/math/util/frustum.h +++ b/Engine/source/math/util/frustum.h @@ -186,8 +186,16 @@ struct FrustumData : public PolyhedronData void _update() const; FrustumData() - : mDirty( false ), - mIsInverted( false ) {} + : mIsOrtho(false), + mNearLeft(-1.0f), + mNearRight(1.0f), + mNearTop(1.0f), + mNearBottom(-1.0f), + mNearDist(0.1f), + mFarDist(1.0f), + mTransform(MatrixF(true)), + mDirty( false ), + mIsInverted( false ) {} public: @@ -478,4 +486,4 @@ class Frustum : public PolyhedronImpl< FrustumData > /// @} }; -#endif // _MATHUTIL_FRUSTUM_H_ \ No newline at end of file +#endif // _MATHUTIL_FRUSTUM_H_ diff --git a/Engine/source/math/util/tResponseCurve.h b/Engine/source/math/util/tResponseCurve.h index ad5329bda..cf282acc5 100644 --- a/Engine/source/math/util/tResponseCurve.h +++ b/Engine/source/math/util/tResponseCurve.h @@ -73,7 +73,7 @@ public: struct Sample { - Sample() {} + Sample() :mF(0) { dMemset(&mVal, 0, sizeof(mVal)); } Sample( F32 f, const T &val ) : mF(f), mVal(val) {} F32 mF; diff --git a/Engine/source/navigation/duDebugDrawTorque.cpp b/Engine/source/navigation/duDebugDrawTorque.cpp index d3928ca76..29ea9ab70 100644 --- a/Engine/source/navigation/duDebugDrawTorque.cpp +++ b/Engine/source/navigation/duDebugDrawTorque.cpp @@ -45,6 +45,7 @@ duDebugDrawTorque::duDebugDrawTorque() mCurrColor = 0; mOverrideColor = 0; mOverride = false; + dMemset(&mStore, 0, sizeof(mStore)); } duDebugDrawTorque::~duDebugDrawTorque() diff --git a/Engine/source/navigation/guiNavEditorCtrl.h b/Engine/source/navigation/guiNavEditorCtrl.h index 3250f6f54..4a6780b33 100644 --- a/Engine/source/navigation/guiNavEditorCtrl.h +++ b/Engine/source/navigation/guiNavEditorCtrl.h @@ -125,7 +125,6 @@ protected: GFXStateBlockRef mZDisableSB; GFXStateBlockRef mZEnableSB; - bool mSavedDrag; bool mIsDirty; String mMode; @@ -169,15 +168,13 @@ protected: class GuiNavEditorUndoAction : public UndoAction { public: - GuiNavEditorUndoAction(const UTF8* actionName) : UndoAction(actionName) + GuiNavEditorUndoAction(const UTF8* actionName) : UndoAction(actionName), mNavEditor(NULL), mObjId(NULL) { } GuiNavEditorCtrl *mNavEditor; SimObjectId mObjId; - F32 mMetersPerSegment; - U32 mSegmentsPerBatch; virtual void undo(); virtual void redo() { undo(); } diff --git a/Engine/source/navigation/navMesh.cpp b/Engine/source/navigation/navMesh.cpp index c6189c366..0c3cd3a5a 100644 --- a/Engine/source/navigation/navMesh.cpp +++ b/Engine/source/navigation/navMesh.cpp @@ -213,6 +213,7 @@ NavMesh::NavMesh() mAlwaysRender = false; mBuilding = false; + mCurLinkID = 0; } NavMesh::~NavMesh() diff --git a/Engine/source/navigation/navMesh.h b/Engine/source/navigation/navMesh.h index 75efcdacb..a4096cdfc 100644 --- a/Engine/source/navigation/navMesh.h +++ b/Engine/source/navigation/navMesh.h @@ -166,14 +166,14 @@ public: /// @name Annotations /// @{ - + /* not implemented /// Should we automatically generate jump-down links? bool mJumpDownLinks; /// Height of a 'small' jump link. F32 mJumpLinkSmall; /// Height of a 'large' jump link. F32 mJumpLinkLarge; - + */ /// Distance to search for cover. F32 mCoverDist; diff --git a/Engine/source/navigation/navPath.cpp b/Engine/source/navigation/navPath.cpp index a66afe136..7d055b78e 100644 --- a/Engine/source/navigation/navPath.cpp +++ b/Engine/source/navigation/navPath.cpp @@ -70,6 +70,7 @@ NavPath::NavPath() : mRenderSearch = false; mQuery = NULL; + mStatus = DT_FAILURE; } NavPath::~NavPath() diff --git a/Engine/source/persistence/taml/json/tamlJSONParser.h b/Engine/source/persistence/taml/json/tamlJSONParser.h index ff74f0d79..6ef9c1020 100644 --- a/Engine/source/persistence/taml/json/tamlJSONParser.h +++ b/Engine/source/persistence/taml/json/tamlJSONParser.h @@ -38,7 +38,7 @@ class TamlJSONParser : public TamlParser { public: - TamlJSONParser() {} + TamlJSONParser() :mDocumentDirty(false) {} virtual ~TamlJSONParser() {} /// Whether the parser can change a property or not. @@ -54,4 +54,4 @@ private: bool mDocumentDirty; }; -#endif // _TAML_JSONPARSER_H_ \ No newline at end of file +#endif // _TAML_JSONPARSER_H_ diff --git a/Engine/source/persistence/taml/taml.cpp b/Engine/source/persistence/taml/taml.cpp index 82369a7c0..b8390a70c 100644 --- a/Engine/source/persistence/taml/taml.cpp +++ b/Engine/source/persistence/taml/taml.cpp @@ -140,6 +140,7 @@ ImplementEnumType(_TamlFormatMode, // The string-table-entries are set to string literals below because Taml is used in a static scope and the string-table cannot currently be used like that. Taml::Taml() : + mMasterNodeId(0), mFormatMode(XmlFormat), mJSONStrict(true), mBinaryCompression(true), diff --git a/Engine/source/persistence/taml/xml/tamlXmlParser.h b/Engine/source/persistence/taml/xml/tamlXmlParser.h index 28b51a472..467fcba3a 100644 --- a/Engine/source/persistence/taml/xml/tamlXmlParser.h +++ b/Engine/source/persistence/taml/xml/tamlXmlParser.h @@ -38,7 +38,7 @@ class TamlXmlParser : public TamlParser { public: - TamlXmlParser() {} + TamlXmlParser() :mDocumentDirty(false) {} virtual ~TamlXmlParser() {} /// Whether the parser can change a property or not. diff --git a/Engine/source/platform/async/asyncPacketQueue.h b/Engine/source/platform/async/asyncPacketQueue.h index 513d6ab29..3bf36e9a5 100644 --- a/Engine/source/platform/async/asyncPacketQueue.h +++ b/Engine/source/platform/async/asyncPacketQueue.h @@ -164,9 +164,7 @@ class AsyncPacketQueue mConsumer( consumer ) { - #ifdef TORQUE_DEBUG mTotalQueuedPackets = 0; - #endif } /// Return true if there are currently diff --git a/Engine/source/platform/nativeDialogs/fileDialog.cpp b/Engine/source/platform/nativeDialogs/fileDialog.cpp index 067458e9f..4e85cbf07 100644 --- a/Engine/source/platform/nativeDialogs/fileDialog.cpp +++ b/Engine/source/platform/nativeDialogs/fileDialog.cpp @@ -54,6 +54,7 @@ FileDialogData::FileDialogData() mTitle = StringTable->EmptyString(); mStyle = 0; + mOpaqueData = NULL; } FileDialogData::~FileDialogData() @@ -123,6 +124,7 @@ FileDialog::FileDialog() : mData() mData.mStyle = FileDialogData::FDS_OPEN | FileDialogData::FDS_MUSTEXIST; mChangePath = false; mForceRelativePath = true; + mBoolTranslator = false; } FileDialog::~FileDialog() diff --git a/Engine/source/platformSDL/threads/thread.cpp b/Engine/source/platformSDL/threads/thread.cpp index 08409fe11..a7de28753 100644 --- a/Engine/source/platformSDL/threads/thread.cpp +++ b/Engine/source/platformSDL/threads/thread.cpp @@ -83,6 +83,7 @@ Thread::Thread(ThreadRunFunction func, void* arg, bool start_thread, bool autode mData->mDead = false; mData->mSdlThread = NULL; autoDelete = autodelete; + shouldStop = true; } Thread::~Thread() diff --git a/Engine/source/platformWin32/winAsync.cpp b/Engine/source/platformWin32/winAsync.cpp index 8910ee420..277b698fe 100644 --- a/Engine/source/platformWin32/winAsync.cpp +++ b/Engine/source/platformWin32/winAsync.cpp @@ -59,6 +59,7 @@ AsyncPeriodicUpdateThread::AsyncPeriodicUpdateThread( String name, // This is a bit contrived. The 'dueTime' is in 100 nanosecond intervals // and relative if it is negative. The period is in milliseconds. + mIntervalMS = intervalMS; LARGE_INTEGER deltaTime; deltaTime.QuadPart = - LONGLONG( intervalMS * 10 /* micro */ * 1000 /* milli */ ); diff --git a/Engine/source/platformWin32/winDirectInput.cpp b/Engine/source/platformWin32/winDirectInput.cpp index fd016496f..b5ba6d2ce 100644 --- a/Engine/source/platformWin32/winDirectInput.cpp +++ b/Engine/source/platformWin32/winDirectInput.cpp @@ -47,6 +47,13 @@ DInputManager::DInputManager() mJoystickActive = mXInputActive = true; mXInputLib = NULL; + mfnXInputGetState = NULL; + mfnXInputSetState = NULL; + dMemset(mXInputStateOld, 0, sizeof(mXInputStateOld)); + dMemset(mXInputStateNew, 0, sizeof(mXInputStateNew)); + mXInputStateReset = false; + mXInputDeadZoneOn = true; + for(S32 i=0; i<4; i++) mLastDisconnectTime[i] = -1; } diff --git a/Engine/source/platformWin32/winFont.cpp b/Engine/source/platformWin32/winFont.cpp index a67b096b3..2efdd6a08 100644 --- a/Engine/source/platformWin32/winFont.cpp +++ b/Engine/source/platformWin32/winFont.cpp @@ -129,6 +129,7 @@ PlatformFont *createPlatformFont(const char *name, dsize_t size, U32 charset /* WinFont::WinFont() : mFont(NULL) { + dMemset(&mTextMetric, 0, sizeof(mTextMetric)); } WinFont::~WinFont() diff --git a/Engine/source/platformWin32/winTimer.cpp b/Engine/source/platformWin32/winTimer.cpp index 940e2c7b8..77e820b07 100644 --- a/Engine/source/platformWin32/winTimer.cpp +++ b/Engine/source/platformWin32/winTimer.cpp @@ -49,11 +49,12 @@ public: mUsingPerfCounter = QueryPerformanceFrequency((LARGE_INTEGER *) &mFrequency); if(mUsingPerfCounter) mUsingPerfCounter = QueryPerformanceCounter((LARGE_INTEGER *) &mPerfCountCurrent); - if(!mUsingPerfCounter) - { + mPerfCountNext = 0.0; + if (!mUsingPerfCounter) mTickCountCurrent = GetTickCount(); - mTickCountNext = 0; - } + else + mTickCountCurrent = 0; + mTickCountNext = 0; } const S32 getElapsedMs() diff --git a/Engine/source/renderInstance/renderDeferredMgr.cpp b/Engine/source/renderInstance/renderDeferredMgr.cpp index 8632b36a3..8d34c809d 100644 --- a/Engine/source/renderInstance/renderDeferredMgr.cpp +++ b/Engine/source/renderInstance/renderDeferredMgr.cpp @@ -584,7 +584,7 @@ const GFXStateBlockDesc & RenderDeferredMgr::getOpaqueStencilTestDesc() ProcessedDeferredMaterial::ProcessedDeferredMaterial( Material& mat, const RenderDeferredMgr *deferredMgr ) -: Parent(mat), mDeferredMgr(deferredMgr) +: Parent(mat), mDeferredMgr(deferredMgr), mIsLightmappedGeometry(false) { } diff --git a/Engine/source/renderInstance/renderProbeMgr.cpp b/Engine/source/renderInstance/renderProbeMgr.cpp index 4d7bf39c7..00e5795cc 100644 --- a/Engine/source/renderInstance/renderProbeMgr.cpp +++ b/Engine/source/renderInstance/renderProbeMgr.cpp @@ -36,6 +36,7 @@ #include "materials/shaderData.h" #include "gfx/gfxTextureManager.h" +#include "scene/reflectionManager.h" #include "postFx/postEffect.h" #include "T3D/lighting/reflectionProbe.h" @@ -213,6 +214,7 @@ RenderProbeMgr::RenderProbeMgr() smProbeManager = this; mCubeMapCount = 0; + mCubeSlotCount = PROBE_ARRAY_SLOT_BUFFER_SIZE; for (U32 i = 0; i < PROBE_MAX_COUNT; i++) { @@ -222,7 +224,17 @@ RenderProbeMgr::RenderProbeMgr() RenderProbeMgr::RenderProbeMgr(RenderInstType riType, F32 renderOrder, F32 processAddOrder) : RenderBinManager(riType, renderOrder, processAddOrder) -{ +{ + mCubeMapCount = 0; + dMemset(mCubeMapSlots, false, sizeof(mCubeMapSlots)); + mCubeSlotCount = PROBE_ARRAY_SLOT_BUFFER_SIZE; + mDefaultSkyLight = nullptr; + mEffectiveProbeCount = 0; + mHasSkylight = false; + mSkylightCubemapIdx = -1; + mLastConstants = nullptr; + mMipCount = 0; + mProbesDirty = false; } RenderProbeMgr::~RenderProbeMgr() @@ -919,6 +931,14 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe) if (!renderWithProbes) RenderProbeMgr::smRenderReflectionProbes = false; + GFXFormat reflectFormat; + + if (clientProbe->mUseHDRCaptures) + reflectFormat = GFXFormatR16G16B16A16F; + else + reflectFormat = GFXFormatR8G8B8A8; + const GFXFormat oldRefFmt = REFLECTMGR->getReflectFormat(); + REFLECTMGR->setReflectFormat(reflectFormat); cubeRefl.updateReflection(reflParams); //Now, save out the maps @@ -929,16 +949,8 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe) clientProbe->createClientResources(); //Prep it with whatever resolution we've dictated for our bake - if (clientProbe->mUseHDRCaptures) - { - clientProbe->mIrridianceMap->mCubemap->initDynamic(resolution, GFXFormatR16G16B16A16F); - clientProbe->mPrefilterMap->mCubemap->initDynamic(resolution, GFXFormatR16G16B16A16F); - } - else - { - clientProbe->mIrridianceMap->mCubemap->initDynamic(resolution, GFXFormatR8G8B8A8); - clientProbe->mPrefilterMap->mCubemap->initDynamic(resolution, GFXFormatR8G8B8A8); - } + clientProbe->mIrridianceMap->mCubemap->initDynamic(resolution, reflectFormat); + clientProbe->mPrefilterMap->mCubemap->initDynamic(resolution, reflectFormat); GFXTextureTargetRef renderTarget = GFX->allocRenderToTextureTarget(false); @@ -969,6 +981,7 @@ void RenderProbeMgr::bakeProbe(ReflectionProbe *probe) probe->setMaskBits(-1); Con::warnf("RenderProbeMgr::bake() - Finished bake! Took %g milliseconds", diffTime); + REFLECTMGR->setReflectFormat(oldRefFmt); } void RenderProbeMgr::bakeProbes() diff --git a/Engine/source/renderInstance/renderProbeMgr.h b/Engine/source/renderInstance/renderProbeMgr.h index 50391ff20..24faccb65 100644 --- a/Engine/source/renderInstance/renderProbeMgr.h +++ b/Engine/source/renderInstance/renderProbeMgr.h @@ -100,8 +100,6 @@ struct ProbeRenderInst U32 mProbeIdx; - F32 mMultiplier; - public: ProbeRenderInst(); @@ -202,6 +200,8 @@ struct ProbeDataSet dMemset(refBoxMaxArray.getBuffer(), 0, refBoxMaxArray.getBufferSize()); dMemset(probeRefPositionArray.getBuffer(), 0, probeRefPositionArray.getBufferSize()); dMemset(probeConfigArray.getBuffer(), 0, probeConfigArray.getBufferSize()); + skyLightIdx = -1; + effectiveProbeCount = 0; } }; diff --git a/Engine/source/scene/culling/sceneCullingVolume.h b/Engine/source/scene/culling/sceneCullingVolume.h index 7cc64d1e8..6d3306269 100644 --- a/Engine/source/scene/culling/sceneCullingVolume.h +++ b/Engine/source/scene/culling/sceneCullingVolume.h @@ -75,7 +75,7 @@ class SceneCullingVolume public: /// Create an *uninitialized* culling volume. - SceneCullingVolume() {} + SceneCullingVolume() : mType(Includer), mSortPoint(1.f) {} /// SceneCullingVolume( Type type, const PlaneSetF& planes ) diff --git a/Engine/source/scene/culling/sceneZoneCullingState.h b/Engine/source/scene/culling/sceneZoneCullingState.h index 3420442dd..48494296b 100644 --- a/Engine/source/scene/culling/sceneZoneCullingState.h +++ b/Engine/source/scene/culling/sceneZoneCullingState.h @@ -66,7 +66,7 @@ class SceneZoneCullingState CullingVolumeLink* mNext; CullingVolumeLink( const SceneCullingVolume& volume ) - : mVolume( volume ) {} + : mVolume( volume ) {mNext=NULL;} }; /// Iterator over the culling volumes assigned to a zone. @@ -134,7 +134,7 @@ class SceneZoneCullingState /// Zone states are constructed by SceneCullingState. This constructor should not /// be used otherwise. It is public due to the use through Vector in SceneCullingState. - SceneZoneCullingState() {} + SceneZoneCullingState():mCanShortcuit(false), mCullingVolumes(NULL), mHaveSortedVolumes(false), mHaveIncluders(false), mHaveOccluders(false){} /// Return true if the zone is visible. This is the case if any /// includers have been added to the zone's rendering state. diff --git a/Engine/source/scene/pathManager.h b/Engine/source/scene/pathManager.h index d239c275f..2a9590706 100644 --- a/Engine/source/scene/pathManager.h +++ b/Engine/source/scene/pathManager.h @@ -56,6 +56,7 @@ class PathManager Vector msToNext; PathEntry() { + totalTime = 0; VECTOR_SET_ASSOCIATION(positions); VECTOR_SET_ASSOCIATION(rotations); VECTOR_SET_ASSOCIATION(smoothingType); @@ -105,7 +106,6 @@ class PathManager private: bool mIsServer; - bool mPathsSent; }; struct PathNode { diff --git a/Engine/source/scene/sceneObject.cpp b/Engine/source/scene/sceneObject.cpp index 0238d6528..10443cf18 100644 --- a/Engine/source/scene/sceneObject.cpp +++ b/Engine/source/scene/sceneObject.cpp @@ -93,7 +93,6 @@ ConsoleDocClass( SceneObject, "@ingroup gameObjects\n" ); -IMPLEMENT_CALLBACK(SceneObject, onInspectPostApply, void, (SceneObject* obj), (obj),"Generic callback for when an object is edited"); #ifdef TORQUE_TOOLS extern bool gEditingMission; #endif @@ -387,7 +386,6 @@ void SceneObject::inspectPostApply() { if( isServerObject() ) setMaskBits( MountedMask ); - onInspectPostApply_callback(this); Parent::inspectPostApply(); } diff --git a/Engine/source/scene/sceneObject.h b/Engine/source/scene/sceneObject.h index ef44982cf..36c8e1cad 100644 --- a/Engine/source/scene/sceneObject.h +++ b/Engine/source/scene/sceneObject.h @@ -798,7 +798,6 @@ class SceneObject : public NetObject, private SceneContainer::Link, public Proce static bool _setGameObject(void* object, const char* index, const char* data); DECLARE_CONOBJECT( SceneObject ); - DECLARE_CALLBACK(void, onInspectPostApply, (SceneObject* obj)); private: SceneObject( const SceneObject& ); ///< @deprecated disallowed diff --git a/Engine/source/sfx/media/sfxVorbisStream.cpp b/Engine/source/sfx/media/sfxVorbisStream.cpp index 3a2f12ba6..38e4e5d95 100644 --- a/Engine/source/sfx/media/sfxVorbisStream.cpp +++ b/Engine/source/sfx/media/sfxVorbisStream.cpp @@ -40,6 +40,7 @@ SFXVorbisStream* SFXVorbisStream::create( Stream *stream ) SFXVorbisStream::SFXVorbisStream() : mVF( NULL ), + mBitstream(-1), mBytesRead( 0 ) { } @@ -47,6 +48,9 @@ SFXVorbisStream::SFXVorbisStream() SFXVorbisStream::SFXVorbisStream( const SFXVorbisStream& cloneFrom ) : Parent( cloneFrom ) { + mVF = NULL; + mBitstream = -1; + mBytesRead = 0; if( !mStream->hasCapability( Stream::StreamPosition ) ) { Con::errorf( "SFXVorbisStream::SFXVorbisStream() - Source stream does not allow seeking" ); diff --git a/Engine/source/sfx/media/sfxWavStream.cpp b/Engine/source/sfx/media/sfxWavStream.cpp index 3e5f4b983..e3833c401 100644 --- a/Engine/source/sfx/media/sfxWavStream.cpp +++ b/Engine/source/sfx/media/sfxWavStream.cpp @@ -94,6 +94,7 @@ SFXWavStream* SFXWavStream::create( Stream *stream ) } SFXWavStream::SFXWavStream() + :mDataStart(-1) { } diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index 080d77d6d..9dd308c58 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -35,8 +35,11 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, : Parent( name, provider, useHardware, maxBuffers ), mOpenAL( openal ), mContext( NULL ), - mDevice( NULL ), - mRolloffFactor( 1.0f ) + mDevice( NULL ), + mDistanceModel(SFXDistanceModelLinear), + mDistanceFactor(1.0f), + mRolloffFactor( 1.0f ), + mUserRolloffFactor(1.0f) { mMaxBuffers = getMax( maxBuffers, 8 ); @@ -80,6 +83,12 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, SFXInternal::gUpdateThread->start(); } #endif + +#if defined(AL_ALEXT_PROTOTYPES) + dMemset(effectSlot, 0, sizeof(effectSlot)); + dMemset(effect, 0, sizeof(effect)); + uLoop = 0; +#endif } //----------------------------------------------------------------------------- diff --git a/Engine/source/sfx/openal/sfxALProvider.cpp b/Engine/source/sfx/openal/sfxALProvider.cpp index 47b2444b3..434d4a44c 100644 --- a/Engine/source/sfx/openal/sfxALProvider.cpp +++ b/Engine/source/sfx/openal/sfxALProvider.cpp @@ -36,7 +36,7 @@ class SFXALProvider : public SFXProvider public: SFXALProvider() - : SFXProvider( "OpenAL" ) { mALDL = NULL; } + : SFXProvider( "OpenAL" ) { dMemset(&mOpenAL,0,sizeof(mOpenAL)); mALDL = NULL; } virtual ~SFXALProvider(); protected: diff --git a/Engine/source/sfx/sfxController.cpp b/Engine/source/sfx/sfxController.cpp index 2d9592eef..6bb5924b9 100644 --- a/Engine/source/sfx/sfxController.cpp +++ b/Engine/source/sfx/sfxController.cpp @@ -75,7 +75,8 @@ ConsoleDocClass( SFXController, SFXController::SFXController( SFXPlayList* playList ) : Parent( playList ), - mTrace( playList->trace() ) + mTrace( playList->trace() ), + mLoopCounter(0) { VECTOR_SET_ASSOCIATION( mInsns ); VECTOR_SET_ASSOCIATION( mSources ); diff --git a/Engine/source/sfx/sfxController.h b/Engine/source/sfx/sfxController.h index 32039d7c4..7d2ee4980 100644 --- a/Engine/source/sfx/sfxController.h +++ b/Engine/source/sfx/sfxController.h @@ -93,13 +93,14 @@ class SFXController : public SFXSource U32 mLoopCount; } mArg; - Insn() {} + Insn() + : mOpcode(SFXController::OP_Delay), mSlotIndex(0), mState(NULL) {mArg.mLoopCount=0;} Insn( EOp opcode ) - : mOpcode( opcode ), mSlotIndex( U32_MAX ), mState( NULL ) {} + : mOpcode( opcode ), mSlotIndex( U32_MAX ), mState( NULL ) {mArg.mLoopCount=0;} Insn( U32 slotIndex, SFXState* state ) - : mSlotIndex( slotIndex ), mState( state ) {} + : mOpcode(SFXController::OP_Delay), mSlotIndex( slotIndex ), mState( state ){mArg.mLoopCount=0;} Insn( EOp opcode, U32 slotIndex, SFXState* state ) - : mOpcode( opcode ), mSlotIndex( slotIndex ), mState( state ) {} + : mOpcode( opcode ), mSlotIndex( slotIndex ), mState( state ) {mArg.mLoopCount=0;} }; /// @@ -130,7 +131,7 @@ class SFXController : public SFXSource F32 mFadeOutTime; Source() - : mState( 0 ) {} + : mState( 0 ), mSlotIndex(0), mVolumeScale(1.0f), mPitchScale(1.0f), mFadeInTime(0), mFadeOutTime(0) {} }; /// The current instruction in "mInsns". @@ -169,7 +170,7 @@ class SFXController : public SFXSource void _genTransition( Insn& insn, SFXPlayList::ETransitionMode transition ); /// - void _dumpInsns(); + void _dumpInsns() {}; /// void _initInsn(); @@ -198,7 +199,7 @@ class SFXController : public SFXSource ~SFXController(); /// Constructor for the sake of ConsoleObject. - explicit SFXController() {} + explicit SFXController(): mIp(0), mTrace(false), mDelayEndTime(0), mLoopCounter(0) {} /// Return the playlist being played back by the controller. SFXPlayList* getPlayList() const; diff --git a/Engine/source/sfx/sfxInternal.h b/Engine/source/sfx/sfxInternal.h index 137456eac..4d0a922f5 100644 --- a/Engine/source/sfx/sfxInternal.h +++ b/Engine/source/sfx/sfxInternal.h @@ -324,7 +324,7 @@ class SFXWrapAroundBuffer : public SFXBuffer SFXWrapAroundBuffer( const ThreadSafeRef< SFXStream >& stream, SFXDescription* description ); SFXWrapAroundBuffer( SFXDescription* description ) - : Parent( description ), mBufferSize( 0 ) {} + : Parent( description ), mBufferSize( 0 ), mWriteOffset(0) {} virtual U32 getMemoryUsed() const { return mBufferSize; } }; diff --git a/Engine/source/sfx/sfxModifier.cpp b/Engine/source/sfx/sfxModifier.cpp index 3bc98c31f..bf63f392e 100644 --- a/Engine/source/sfx/sfxModifier.cpp +++ b/Engine/source/sfx/sfxModifier.cpp @@ -107,6 +107,8 @@ bool SFXRangeModifier::update() SFXFadeModifier::SFXFadeModifier( SFXSource* source, F32 time, F32 endVolume, F32 startTime, EOnEnd onEndDo, bool removeWhenDone ) : Parent( source, startTime, startTime + time, removeWhenDone ), + mStartVolume(source->getVolume()), + mCurrentVolume(source->getVolume()), mEndVolume( endVolume ), mOnEnd( onEndDo ) { diff --git a/Engine/source/sfx/sfxModifier.h b/Engine/source/sfx/sfxModifier.h index 182609964..39f2a7316 100644 --- a/Engine/source/sfx/sfxModifier.h +++ b/Engine/source/sfx/sfxModifier.h @@ -47,7 +47,7 @@ class SFXModifier : public IPolled /// Create an effect that operates on "source". SFXModifier( SFXSource* source, bool removeWhenDone = false ) - : mSource( source ) {} + : mSource( source ), mRemoveWhenDone(removeWhenDone) {} virtual ~SFXModifier() {} }; diff --git a/Engine/source/sfx/sfxSound.cpp b/Engine/source/sfx/sfxSound.cpp index 6b4895f80..c62c41605 100644 --- a/Engine/source/sfx/sfxSound.cpp +++ b/Engine/source/sfx/sfxSound.cpp @@ -68,7 +68,7 @@ ConsoleDocClass( SFXSound, //----------------------------------------------------------------------------- SFXSound::SFXSound() - : mVoice( NULL ) + : mVoice( NULL ), mDuration(0), mSetPositionValue(0) { // NOTE: This should never be used directly // and is only here to satisfy satisfy the @@ -79,7 +79,7 @@ SFXSound::SFXSound() SFXSound::SFXSound( SFXProfile *profile, SFXDescription* desc ) : Parent( profile, desc ), - mVoice( NULL ) + mVoice( NULL ), mDuration(0) { mSetPositionValue = 0; } diff --git a/Engine/source/sfx/sfxWorld.h b/Engine/source/sfx/sfxWorld.h index 289455b69..427e4721d 100644 --- a/Engine/source/sfx/sfxWorld.h +++ b/Engine/source/sfx/sfxWorld.h @@ -208,7 +208,7 @@ class SFXWorld : public ScopeTracker< NUM_DIMENSIONS, Object > /// between this space and the space above us in the stack. Object mObject; - Scope() {} + Scope() :mSortValue(0), mSoundscape(NULL) {} Scope( F32 sortValue, Object object ) : mSortValue( sortValue ), mSoundscape( NULL ), diff --git a/Engine/source/sim/actionMap.h b/Engine/source/sim/actionMap.h index c2c4cbd72..26caffe7b 100644 --- a/Engine/source/sim/actionMap.h +++ b/Engine/source/sim/actionMap.h @@ -92,7 +92,7 @@ class ActionMap : public SimObject U32 deviceInst; Vector nodeMap; - DeviceMap() { + DeviceMap():deviceType(NULL), deviceInst(NULL){ VECTOR_SET_ASSOCIATION(nodeMap); } ~DeviceMap(); diff --git a/Engine/source/sim/netConnection.cpp b/Engine/source/sim/netConnection.cpp index c952a0258..9d70ff2dc 100644 --- a/Engine/source/sim/netConnection.cpp +++ b/Engine/source/sim/netConnection.cpp @@ -469,6 +469,8 @@ NetConnection::PacketNotify::PacketNotify() sendTime = 0; eventList = 0; ghostList = 0; + subList = NULL; + nextPacket = NULL; } bool NetConnection::checkTimeout(U32 time) diff --git a/Engine/source/sim/netConnection.h b/Engine/source/sim/netConnection.h index 55422f9eb..ab58ac0e0 100644 --- a/Engine/source/sim/netConnection.h +++ b/Engine/source/sim/netConnection.h @@ -273,7 +273,7 @@ public: /// @{ /// - NetEvent() { mGuaranteeType = GuaranteedOrdered; } + NetEvent() { mSourceId = -1; mGuaranteeType = GuaranteedOrdered; } virtual ~NetEvent(); virtual void write(NetConnection *ps, BitStream *bstream) = 0; @@ -863,7 +863,7 @@ public: void setScopeObject(NetObject *object); /// Get the object around which we are currently scoping network traffic. - NetObject *getScopeObject(); + NetObject* getScopeObject() {}; /// Add an object to scope. void objectInScope(NetObject *object); @@ -1047,7 +1047,7 @@ public: bool startDemoRecord(const char *fileName); bool replayDemoRecord(const char *fileName); - void startDemoRead(); + void startDemoRead() {}; void stopRecording(); void stopDemoPlayback(); diff --git a/Engine/source/sim/netInterface.cpp b/Engine/source/sim/netInterface.cpp index fd2c51bc4..e11d65383 100644 --- a/Engine/source/sim/netInterface.cpp +++ b/Engine/source/sim/netInterface.cpp @@ -42,7 +42,8 @@ NetInterface::NetInterface() mLastTimeoutCheckTime = 0; mAllowConnections = false; - + dMemset(mRandomHashData, 0, sizeof(mRandomHashData)); + mRandomDataInitialized = false; } void NetInterface::initRandomData() diff --git a/Engine/source/sim/netStringTable.h b/Engine/source/sim/netStringTable.h index 948d497ce..a3cc9f530 100644 --- a/Engine/source/sim/netStringTable.h +++ b/Engine/source/sim/netStringTable.h @@ -64,7 +64,6 @@ class NetStringTable U32 size; U32 firstFree; U32 firstValid; - U32 sequenceCount; Entry *table; U32 hashTable[HashTableSize]; diff --git a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp index 1bcfbd099..3431e08bb 100644 --- a/Engine/source/terrain/glsl/terrFeatureGLSL.cpp +++ b/Engine/source/terrain/glsl/terrFeatureGLSL.cpp @@ -1019,19 +1019,28 @@ void TerrainNormalMapFeatGLSL::processPix( Vector &component LangElement *bumpNormDecl = new DecOp( bumpNorm ); meta->addStatement( expandNormalMap( texOp, bumpNormDecl, bumpNorm, fd ) ); - // Normalize is done later... - // Note: The reverse mul order is intentional. Affine matrix. - meta->addStatement( new GenOp( " @ = lerp( @, tMul( @.xyz, @ ), min( @, @.w ) );\r\n", - gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet ) ); - - // End the conditional block. - meta->addStatement( new GenOp( " }\r\n" ) ); - // If this is the last normal map then we // can test to see the total blend value // to see if we should clip the result. - //if ( fd.features.getNextFeatureIndex( MFT_TerrainNormalMap, normalIndex ) == -1 ) - //meta->addStatement( new GenOp( " clip( @ - 0.0001f );\r\n", blendTotal ) ); + Var* blendTotal = (Var*)LangElement::find("blendTotal"); + if (blendTotal) + { + if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1) + meta->addStatement(new GenOp(" if ( @ > 0.0001f ){\r\n\r\n", blendTotal)); + } + // Normalize is done later... + // Note: The reverse mul order is intentional. Affine matrix. + meta->addStatement(new GenOp(" @ = lerp( @, mul( @.xyz, @ ), min( @, @.w ) );\r\n", + gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet)); + + if (blendTotal) + { + if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1) + meta->addStatement(new GenOp(" }\r\n")); + } + + // End the conditional block. + meta->addStatement( new GenOp( " }\r\n" ) ); output = meta; } @@ -1103,11 +1112,12 @@ void TerrainAdditiveFeatGLSL::processPix( Vector &componentLis const MaterialFeatureData &fd ) { Var *color = NULL; + Var* norm = NULL; if (fd.features[MFT_isDeferred]) { - color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ); + color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1)); + norm = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); } - else color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget)); Var *blendTotal = (Var*)LangElement::find( "blendTotal" ); @@ -1118,6 +1128,10 @@ void TerrainAdditiveFeatGLSL::processPix( Vector &componentLis meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) ); meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) ); + if (fd.features[MFT_isDeferred]) + { + meta->addStatement(new GenOp(" @.a = @;\r\n", norm, blendTotal)); + } output = meta; } diff --git a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp index 63d342a8a..d49297b02 100644 --- a/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp +++ b/Engine/source/terrain/hlsl/terrFeatureHLSL.cpp @@ -1028,20 +1028,28 @@ void TerrainNormalMapFeatHLSL::processPix( Vector &component LangElement *bumpNormDecl = new DecOp( bumpNorm ); meta->addStatement( expandNormalMap( texOp, bumpNormDecl, bumpNorm, fd ) ); - // Normalize is done later... - // Note: The reverse mul order is intentional. Affine matrix. - meta->addStatement( new GenOp( " @ = lerp( @, mul( @.xyz, @ ), min( @, @.w ) );\r\n", - gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet ) ); - - // End the conditional block. - meta->addStatement( new GenOp( " }\r\n" ) ); - // If this is the last normal map then we // can test to see the total blend value // to see if we should clip the result. - //if ( fd.features.getNextFeatureIndex( MFT_TerrainNormalMap, normalIndex ) == -1 ) - //meta->addStatement( new GenOp( " clip( @ - 0.0001f );\r\n", blendTotal ) ); + Var* blendTotal = (Var*)LangElement::find("blendTotal"); + if (blendTotal) + { + if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1) + meta->addStatement(new GenOp(" if ( @ > 0.0001f ){\r\n\r\n", blendTotal)); + } + // Normalize is done later... + // Note: The reverse mul order is intentional. Affine matrix. + meta->addStatement( new GenOp( " @ = lerp( @, mul( @.xyz, @ ), min( @, @.w ) );\r\n", + gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet ) ); + if (blendTotal) + { + if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1) + meta->addStatement(new GenOp(" }\r\n")); + } + // End the conditional block. + meta->addStatement( new GenOp( " }\r\n" ) ); + output = meta; } @@ -1112,9 +1120,11 @@ void TerrainAdditiveFeatHLSL::processPix( Vector &componentLis const MaterialFeatureData &fd ) { Var *color = NULL; + Var* norm = NULL; if (fd.features[MFT_isDeferred]) { color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ); + norm = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) ); } else color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) ); @@ -1127,6 +1137,10 @@ void TerrainAdditiveFeatHLSL::processPix( Vector &componentLis meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) ); meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) ); + if (fd.features[MFT_isDeferred]) + { + meta->addStatement(new GenOp(" @.a = @;\r\n", norm, blendTotal)); + } output = meta; } @@ -1226,7 +1240,7 @@ void TerrainCompositeMapFeatHLSL::processVert(Vector &componen U32 TerrainCompositeMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const { - return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1; + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; } void TerrainCompositeMapFeatHLSL::processPix(Vector &componentList, @@ -1264,7 +1278,7 @@ void TerrainCompositeMapFeatHLSL::processPix(Vector &component // search for material var Var * pbrConfig; - OutputTarget targ = RenderTarget1; + OutputTarget targ = DefaultTarget; if (fd.features[MFT_isDeferred]) { targ = RenderTarget2; @@ -1317,7 +1331,7 @@ ShaderFeature::Resources TerrainCompositeMapFeatHLSL::getResources(const Materia // reminder, the matinfo buffer is flags, smooth, ao, metal U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const { - return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1; + return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget; } void TerrainBlankInfoMapFeatHLSL::processPix(Vector &componentList, @@ -1325,7 +1339,7 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector &component { // search for material var Var *material; - OutputTarget targ = RenderTarget1; + OutputTarget targ = DefaultTarget; if (fd.features[MFT_isDeferred]) { targ = RenderTarget2; diff --git a/Engine/source/terrain/terrCell.cpp b/Engine/source/terrain/terrCell.cpp index ba1262df1..e1b0caecb 100644 --- a/Engine/source/terrain/terrCell.cpp +++ b/Engine/source/terrain/terrCell.cpp @@ -58,7 +58,11 @@ TerrCell::TerrCell() mHasEmpty( false ), mMaterial( NULL ), mMaterials( 0 ), - mIsInteriorOnly( false ) + mIsInteriorOnly( false ), + mSize(smMinCellSize), + mLevel(0), + mTerrain(NULL), + mRadius(0.5f) { dMemset( mChildren, 0, sizeof( mChildren ) ); zode_vertexBuffer = 0; diff --git a/Engine/source/terrain/terrCellMaterial.cpp b/Engine/source/terrain/terrCellMaterial.cpp index 66ecfb4c2..fbcac6f1e 100644 --- a/Engine/source/terrain/terrCellMaterial.cpp +++ b/Engine/source/terrain/terrCellMaterial.cpp @@ -73,7 +73,8 @@ TerrainCellMaterial::TerrainCellMaterial() : mTerrain( NULL ), mCurrPass( 0 ), mDeferredMat( NULL ), - mReflectMat( NULL ) + mReflectMat( NULL ), + mMaterials(0) { smAllMaterials.push_back( this ); } diff --git a/Engine/source/terrain/terrCellMaterial.h b/Engine/source/terrain/terrCellMaterial.h index d762dd4d5..a635486ba 100644 --- a/Engine/source/terrain/terrCellMaterial.h +++ b/Engine/source/terrain/terrCellMaterial.h @@ -58,6 +58,8 @@ protected: public: MaterialInfo() + :mat(NULL), layerId(0), detailTexConst(NULL), macroTexConst(NULL), normalTexConst(NULL), + compositeTexConst(NULL), detailInfoVConst(NULL), detailInfoPConst(NULL), macroInfoVConst(NULL), macroInfoPConst(NULL) { } @@ -92,7 +94,15 @@ protected: public: Pass() - : shader( NULL ) + : shader( NULL ), + modelViewProjConst(NULL), worldViewOnly(NULL), viewToObj(NULL), + eyePosWorldConst(NULL), eyePosConst(NULL), + objTransConst(NULL), worldToObjConst(NULL), vEyeConst(NULL), + layerSizeConst(NULL), lightParamsConst(NULL), lightInfoBufferConst(NULL), + baseTexMapConst(NULL), layerTexConst(NULL), + lightMapTexConst(NULL), + squareSize(NULL), oneOverTerrainSize(NULL), + fogDataConst(NULL), fogColorConst(NULL) { } diff --git a/Engine/source/terrain/terrCollision.cpp b/Engine/source/terrain/terrCollision.cpp index 6b0ee6f8d..0d2cb905f 100644 --- a/Engine/source/terrain/terrCollision.cpp +++ b/Engine/source/terrain/terrCollision.cpp @@ -167,13 +167,20 @@ S32 sFaceList135[16][9] = { TerrainConvex::TerrainConvex() { + halfA = true; + square = NULL; + squareId = 0; + material = 0; + split45 = false; + mType = TerrainConvexType; } TerrainConvex::TerrainConvex( const TerrainConvex &cv ) { mType = TerrainConvexType; - + halfA = false; + square = NULL; // Only a partial copy... mObject = cv.mObject; split45 = cv.split45; @@ -231,7 +238,7 @@ void TerrainConvex::getFeatures(const MatrixF& mat,const VectorF& n, ConvexFeatu { U32 i; cf->material = 0; - cf->object = mObject; + cf->mObject = mObject; // Plane is normal n + support point PlaneF plane; diff --git a/Engine/source/terrain/terrData.cpp b/Engine/source/terrain/terrData.cpp index a9c70080f..7abfbc867 100644 --- a/Engine/source/terrain/terrData.cpp +++ b/Engine/source/terrain/terrData.cpp @@ -190,6 +190,7 @@ TerrainBlock::TerrainBlock() mMaxDetailDistance( 0.0f ), mBaseTexScaleConst( NULL ), mBaseTexIdConst( NULL ), + mBaseLayerSizeConst(NULL), mDetailsDirty( false ), mLayerTexDirty( false ), mBaseTexSize( 1024 ), diff --git a/Engine/source/terrain/terrFile.cpp b/Engine/source/terrain/terrFile.cpp index 0970f48bc..727074106 100644 --- a/Engine/source/terrain/terrFile.cpp +++ b/Engine/source/terrain/terrFile.cpp @@ -46,6 +46,7 @@ template<> ResourceBase::Signature Resource::signature() TerrainFile::TerrainFile() : mSize( 256 ), + mGridLevels(0), mFileVersion( FILE_VERSION ), mNeedsResaving( false ) { diff --git a/Engine/source/ts/assimp/assimpAppMaterial.cpp b/Engine/source/ts/assimp/assimpAppMaterial.cpp index 138085036..979cf8318 100644 --- a/Engine/source/ts/assimp/assimpAppMaterial.cpp +++ b/Engine/source/ts/assimp/assimpAppMaterial.cpp @@ -57,7 +57,7 @@ AssimpAppMaterial::AssimpAppMaterial(const char* matName) { name = ColladaUtils::getOptions().matNamePrefix; name += matName; - + mAIMat = NULL; // Set some defaults flags |= TSMaterialList::S_Wrap; flags |= TSMaterialList::T_Wrap; diff --git a/Engine/source/ts/collada/colladaUtils.h b/Engine/source/ts/collada/colladaUtils.h index 9dad22056..781c41eee 100644 --- a/Engine/source/ts/collada/colladaUtils.h +++ b/Engine/source/ts/collada/colladaUtils.h @@ -886,7 +886,7 @@ struct AnimData return element ? (AnimChannels*)const_cast(element)->getUserData() : 0; } - AnimData() : enabled(false) { } + AnimData() : enabled(false), targetValueOffset(0), targetValueCount(0){ } void parseTargetString(const char* target, S32 fullCount, const char* elements[]); diff --git a/Engine/source/ts/loader/appMesh.cpp b/Engine/source/ts/loader/appMesh.cpp index bd5c291e0..a51b91002 100644 --- a/Engine/source/ts/loader/appMesh.cpp +++ b/Engine/source/ts/loader/appMesh.cpp @@ -26,7 +26,7 @@ Vector AppMesh::appMaterials; AppMesh::AppMesh() - : flags(0), vertsPerFrame(0),numFrames(0), numMatFrames(0) + : flags(0), vertsPerFrame(0),numFrames(0), numMatFrames(0), detailSize(1) { } diff --git a/Engine/source/ts/loader/appNode.cpp b/Engine/source/ts/loader/appNode.cpp index 6616d8120..e869cf02b 100644 --- a/Engine/source/ts/loader/appNode.cpp +++ b/Engine/source/ts/loader/appNode.cpp @@ -26,6 +26,7 @@ AppNode::AppNode() { mName = NULL; mParentName = NULL; + mParentIndex = 0; } AppNode::~AppNode() diff --git a/Engine/source/ts/loader/appSequence.h b/Engine/source/ts/loader/appSequence.h index c31683321..f5fdfae12 100644 --- a/Engine/source/ts/loader/appSequence.h +++ b/Engine/source/ts/loader/appSequence.h @@ -39,7 +39,7 @@ public: F32 fps; public: - AppSequence() { } + AppSequence():fps(30.0f) { } //default based on TSShapeLoader::XXXFrameRate(s) and AssimpAppSequence fallback virtual ~AppSequence() { } virtual void setActive(bool active) { } diff --git a/Engine/source/ts/loader/tsShapeLoader.h b/Engine/source/ts/loader/tsShapeLoader.h index 5ff189245..bfd0f687c 100644 --- a/Engine/source/ts/loader/tsShapeLoader.h +++ b/Engine/source/ts/loader/tsShapeLoader.h @@ -182,7 +182,7 @@ protected: void install(); public: - TSShapeLoader() : boundsNode(0) { } + TSShapeLoader() : boundsNode(0), shape(NULL) { } virtual ~TSShapeLoader(); static const Torque::Path& getShapePath() { return shapePath; } diff --git a/Engine/source/ts/tsMesh.cpp b/Engine/source/ts/tsMesh.cpp index 5800e7e7c..4f9dd434a 100644 --- a/Engine/source/ts/tsMesh.cpp +++ b/Engine/source/ts/tsMesh.cpp @@ -1182,7 +1182,14 @@ TSMesh::TSMesh() : mMeshType( StandardMeshType ) mNumVerts = 0; mVertSize = 0; mVertOffset = 0; - + mRadius = 0.0f; + mVertexFormat = NULL; + mPrimBufferOffset = 0; + numFrames = 0; + numMatFrames = 0; + vertsPerFrame = 0; + mPlanesPerFrame = 0; + mMergeBufferStart = 0; mParentMeshObject = NULL; } diff --git a/Engine/source/ts/tsMesh.h b/Engine/source/ts/tsMesh.h index cd53a04fc..b20a9a2fb 100644 --- a/Engine/source/ts/tsMesh.h +++ b/Engine/source/ts/tsMesh.h @@ -198,7 +198,7 @@ public: bool ownsData; public: - TSMeshVertexArray() : base(NULL), numElements(0), colorOffset(0), boneOffset(0), vertexDataReady(false), ownsData(false) {} + TSMeshVertexArray() : base(NULL), vertSz(0), numElements(0), colorOffset(0), boneOffset(0), vertexDataReady(false), ownsData(false) {} virtual ~TSMeshVertexArray() { set(NULL, 0, 0, 0, 0); } virtual void set(void *b, dsize_t s, U32 n, S32 inColorOffset, S32 inBoneOffset, bool nowOwnsData = true) @@ -339,7 +339,7 @@ protected: Point3F mBillboardAxis; /// @name Convex Hull Data - /// Convex hulls are convex (no angles >= 180º) meshes used for collision + /// Convex hulls are convex (no angles >= 180º) meshes used for collision /// @{ Vector mPlaneNormals; diff --git a/Engine/source/ts/tsPartInstance.cpp b/Engine/source/ts/tsPartInstance.cpp index 4c0875c3f..0c1a1b35c 100644 --- a/Engine/source/ts/tsPartInstance.cpp +++ b/Engine/source/ts/tsPartInstance.cpp @@ -51,6 +51,7 @@ void TSPartInstance::init(TSShapeInstance * sourceShape) mCurrentObjectDetail = 0; mCurrentIntraDL = 1.0f; mData = 0; + mRadius = 0.125; } TSPartInstance::~TSPartInstance() diff --git a/Engine/source/ts/tsShape.cpp b/Engine/source/ts/tsShape.cpp index 9ffef7b56..ef87b1cf2 100644 --- a/Engine/source/ts/tsShape.cpp +++ b/Engine/source/ts/tsShape.cpp @@ -68,12 +68,19 @@ U32 TSShape::smMaxSkinBones = 70; TSShape::TSShape() { + mExporterVersion = 124; + mSmallestVisibleSize = 2; + mSmallestVisibleDL = 0; + mRadius = 0; + mFlags = 0; + tubeRadius = 0; + data = NULL; materialList = NULL; mReadVersion = -1; // -1 means constructed from scratch (e.g., in exporter or no read yet) mSequencesConstructed = false; mShapeData = NULL; mShapeDataSize = 0; - + mVertexSize = 0; mUseDetailFromScreenError = false; mNeedReinit = false; diff --git a/Engine/source/ts/tsShapeConstruct.cpp b/Engine/source/ts/tsShapeConstruct.cpp index 40004e98b..0de7478c3 100644 --- a/Engine/source/ts/tsShapeConstruct.cpp +++ b/Engine/source/ts/tsShapeConstruct.cpp @@ -393,7 +393,7 @@ TSShapeConstructor* TSShapeConstructor::findShapeConstructor(const FileName& pat FileName shapePath = tss->mShapePath; char buf[1024]; - FileName fullShapePath = Platform::makeFullPathName(shapePath, buf, sizeof(buf)); + FileName fullShapePath = String(Platform::makeFullPathName(shapePath, buf, sizeof(buf))); if (shapePath.equal( path, String::NoCase ) || fullShapePath.equal(path, String::NoCase)) return tss; } diff --git a/Engine/source/ts/tsShapeConstruct.h b/Engine/source/ts/tsShapeConstruct.h index dba25d0ac..49b157f17 100644 --- a/Engine/source/ts/tsShapeConstruct.h +++ b/Engine/source/ts/tsShapeConstruct.h @@ -196,7 +196,7 @@ public: public: TSShapeConstructor(); - TSShapeConstructor(const String& path) : mShapePath(path) { } + TSShapeConstructor(const String& path) : mShapePath(path), mShape(NULL), mLoadingShape(false){ } ~TSShapeConstructor(); DECLARE_CONOBJECT(TSShapeConstructor); diff --git a/Engine/source/ts/tsShapeInstance.cpp b/Engine/source/ts/tsShapeInstance.cpp index d6889c2fe..4665efde3 100644 --- a/Engine/source/ts/tsShapeInstance.cpp +++ b/Engine/source/ts/tsShapeInstance.cpp @@ -118,6 +118,7 @@ TSShapeInstance::TSShapeInstance( const Resource &shape, bool loadMater mShapeResource = shape; mShape = mShapeResource; + mUseOverrideTexture = false; buildInstanceData( mShape, loadMaterials ); } @@ -135,6 +136,7 @@ TSShapeInstance::TSShapeInstance( TSShape *shape, bool loadMaterials ) mShapeResource = NULL; mShape = shape; + mUseOverrideTexture = false; buildInstanceData( mShape, loadMaterials ); } diff --git a/Engine/source/ts/tsSortedMesh.h b/Engine/source/ts/tsSortedMesh.h index 671fb7823..df0e58ddd 100644 --- a/Engine/source/ts/tsSortedMesh.h +++ b/Engine/source/ts/tsSortedMesh.h @@ -71,6 +71,7 @@ public: void disassemble(); TSSortedMesh() { + alwaysWriteDepth = false; mMeshType = SortedMeshType; } }; diff --git a/Engine/source/util/noise2d.cpp b/Engine/source/util/noise2d.cpp index 6c51dfc19..2e9d9870f 100644 --- a/Engine/source/util/noise2d.cpp +++ b/Engine/source/util/noise2d.cpp @@ -26,6 +26,8 @@ //-------------------------------------- Noise2D::Noise2D() { + dMemset(mPermutation, 0, sizeof(mPermutation)); + dMemset(mGradient, 0, sizeof(mGradient)); mSeed = 0; } diff --git a/Engine/source/util/sampler.cpp b/Engine/source/util/sampler.cpp index f4d051e1e..405a81800 100644 --- a/Engine/source/util/sampler.cpp +++ b/Engine/source/util/sampler.cpp @@ -118,9 +118,9 @@ class CSVSamplerBackend : public ISamplerBackend const char* mString; } mValue; - SampleRecord() {} + SampleRecord() : mKey(0), mSet(false), mType(TypeBool) { mValue.mBool = false; } SampleRecord( U32 key ) - : mKey( key ), mSet( false ) {} + : mKey( key ), mSet( false ), mType(TypeBool) { mValue.mBool = false; } void set( bool value ) { diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs index 0c6c680af..4b56ad9df 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/server.cs @@ -201,7 +201,7 @@ function onServerCreated() physicsInitWorld( "server" ); physicsStartSimulation("server"); - + DatablockFilesList.clear(); loadDatablockFiles( DatablockFilesList, true ); callOnModules("onServerScriptExec", "Core"); diff --git a/Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs b/Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs index f74fbcd0c..f1e7932d7 100644 --- a/Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs +++ b/Templates/BaseGame/game/core/postFX/scripts/HDRPostFX.cs @@ -287,7 +287,7 @@ function HDRPostFX::onEnabled( %this ) // Set the right global shader define for HDR. if ( %format $= "GFXFormatR10G10B10A2" ) addGlobalShaderMacro( "TORQUE_HDR_RGB10" ); - else if ( %format $= "GFXFormatR16G16B16A16" ) + else if ( %format $= "GFXFormatR16G16B16A16F" ) addGlobalShaderMacro( "TORQUE_HDR_RGB16" ); echo( "HDR FORMAT: " @ %format ); diff --git a/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs b/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs index 8a0a8adea..07b4f08a6 100644 --- a/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs +++ b/Templates/BaseGame/game/core/rendering/scripts/renderManager.cs @@ -34,7 +34,7 @@ function initRenderManager() enabled = "false"; //When hdr is enabled this will be changed to the appropriate format - format = "GFXFormatR8G8B8A8_SRGB"; + format = "GFXFormatR16G16B16A16F"; depthFormat = "GFXFormatD24S8"; aaLevel = 0; // -1 = match backbuffer diff --git a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl index 870756628..cfb89bf8a 100644 --- a/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl +++ b/Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl @@ -377,7 +377,7 @@ float3 boxProject(float3 wsPosition, float3 wsReflectVec, float4x4 worldToObj, f float dist = min(min(furthestPlane.x, furthestPlane.y), furthestPlane.z); float3 posonbox = wsPosition + wsReflectVec * dist; - return posonbox - refPosition.xyz; + return posonbox-refPosition; } float4 computeForwardProbes(Surface surface, diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs index 72dae5226..ac9a0bf8e 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/image.cs @@ -190,7 +190,7 @@ function AssetBrowser::buildImageAssetPreview(%this, %assetDef, %previewData) %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ "Asset Type: Image Asset\n" @ - "Asset Defition ID: " @ %assetDef @ "\n" @ + "Asset Definition ID: " @ %assetDef @ "\n" @ "Image Type: " @ %assetDef.imageType @ "\n" @ "Format: " @ getWord(%info, 0) @ "\n" @ "Height: " @ getWord(%info, 1) @ "\n" @ diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs index 28d8ac437..1b53e65c8 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/material.cs @@ -464,7 +464,7 @@ function AssetBrowser::buildMaterialAssetPreview(%this, %assetDef, %previewData) %previewData.assetDesc = %assetDef.description; %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ "Asset Type: Material Asset\n" @ - "Asset Defition ID: " @ %assetDef; + "Asset Definition ID: " @ %assetDef; } function AssetBrowser::onMaterialAssetEditorDropped(%this, %assetDef, %position) diff --git a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs index 22eeadb27..483b9b0c7 100644 --- a/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs +++ b/Templates/BaseGame/game/tools/assetBrowser/scripts/assetTypes/shape.cs @@ -253,7 +253,7 @@ function AssetBrowser::buildShapeAssetPreview(%this, %assetDef, %previewData) %previewData.assetDesc = %assetDef.description; %previewData.tooltip = "Asset Name: " @ %assetDef.assetName @ "\n" @ "Asset Type: Shape Asset\n" @ - "Asset Defition ID: " @ %assetDef; + "Asset Definition ID: " @ %assetDef; } function AssetBrowser::onShapeAssetEditorDropped(%this, %assetDef, %position) diff --git a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs index 2a4853e62..08b65c716 100644 --- a/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs +++ b/Templates/BaseGame/game/tools/worldEditor/scripts/editors/worldEditor.ed.cs @@ -489,4 +489,10 @@ function foCollaps (%this, %tab){ case "container2": %tab.visible = "0"; } -} \ No newline at end of file +} + +function simGroup::onInspectPostApply(%this) +{ + %this.callOnChildren("setHidden",%this.hidden); + %this.callOnChildren("setLocked",%this.locked); +} diff --git a/Tools/CMake/torque3d.cmake b/Tools/CMake/torque3d.cmake index 990030ec3..6337f35e9 100644 --- a/Tools/CMake/torque3d.cmake +++ b/Tools/CMake/torque3d.cmake @@ -38,10 +38,6 @@ if(UNIX) endif() - # for asm files - SET (CMAKE_ASM_NASM_OBJECT_FORMAT "elf") - ENABLE_LANGUAGE (ASM_NASM) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif()