Adds test shapes of Kork and SpaceOrc

Sidestep of memleak from CSF at the moment
Minor fixes and corrections with asset importing and loose files
WIP of updated options menu
This commit is contained in:
Areloch 2019-05-28 17:24:29 -05:00
parent 98c4606b3c
commit ae857faae2
40 changed files with 765 additions and 182 deletions

View file

@ -149,12 +149,12 @@ void ImageAsset::loadImage()
void ImageAsset::initializeAsset()
{
loadImage();
setImageFileName(mImageFileName);
}
void ImageAsset::onAssetRefresh()
{
loadImage();
setImageFileName(mImageFileName);
}
void ImageAsset::setImageFileName(const char* pScriptFile)
@ -162,16 +162,16 @@ void ImageAsset::setImageFileName(const char* pScriptFile)
// Sanity!
AssertFatal(pScriptFile != NULL, "Cannot use a NULL image file.");
// Fetch image file.
pScriptFile = StringTable->insert(pScriptFile);
// Ignore no change,
if (pScriptFile == mImageFileName)
return;
// Update.
mImageFileName = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
// Refresh the asset.
refreshAsset();
loadImage();
}
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.")
{
return object->getImageFileName();
}

View file

@ -71,7 +71,7 @@ public:
bool isValid() { return mIsValidImage; }
GFXTexHandle* getImage() { return &mImage; }
GFXTexHandle getImage() { return mImage; }
protected:
virtual void initializeAsset(void);

View file

@ -121,12 +121,17 @@ void MaterialAsset::initializeAsset()
compileShader();
if (!Platform::isFullPath(mScriptFile))
mScriptFile = getOwned() ? expandAssetFilePath(mScriptFile) : mScriptFile;
if (Platform::isFile(mScriptFile))
Con::executeFile(mScriptFile, false, false);
}
void MaterialAsset::onAssetRefresh()
{
mScriptFile = expandAssetFilePath(mScriptFile);
if (Platform::isFile(mScriptFile))
Con::executeFile(mScriptFile, false, false);
@ -151,12 +156,8 @@ void MaterialAsset::setScriptFile(const char* pScriptFile)
// Fetch image file.
pScriptFile = StringTable->insert(pScriptFile);
// Ignore no change,
if (pScriptFile == mScriptFile)
return;
// Update.
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : StringTable->insert(pScriptFile);
mScriptFile = getOwned() ? expandAssetFilePath(pScriptFile) : pScriptFile;
// Refresh the asset.
refreshAsset();

View file

@ -944,7 +944,12 @@ void GroundCover::_initialize( U32 cellCount, U32 cellPlacementCount )
Material* mat = dynamic_cast<Material*>(mMatInst->getMaterial());
if(mat)
{
GFXTexHandle tex(mat->mDiffuseMapFilename[0], &GFXStaticTextureSRGBProfile, "GroundCover texture aspect ratio check" );
GFXTexHandle tex;
if (!mat->mDiffuseMapFilename[0].isEmpty())
tex = GFXTexHandle(mat->mDiffuseMapFilename[0], &GFXStaticTextureSRGBProfile, "GroundCover texture aspect ratio check");
else if (!mat->mDiffuseMapAsset[0].isNull())
tex = mat->mDiffuseMapAsset[0]->getImage();
if(tex.isValid())
{
U32 w = tex.getWidth();

View file

@ -4523,7 +4523,7 @@ void GuiTreeViewCtrl::reparentItems(Vector<Item*> selectedItems, Item* newParent
// update the parent's children
// check if we an only child
if (item->mParent->mChild == item)
if (item->mParent && item->mParent->mChild == item)
{
if (item->mNext)
item->mParent->mChild = item->mNext;
@ -4805,7 +4805,7 @@ void GuiTreeViewCtrl::reparentItems(Vector<Item*> selectedItems, Item* newParent
if (item->isInspectorData())
{
if (item->getObject() && oldParent->getObject() && item->mParent->getObject())
if (item->getObject() && (oldParent && oldParent->getObject()) && item->mParent->getObject())
onReparent_callback(
item->getObject()->getId(),
oldParent->getObject()->getId(),

View file

@ -116,6 +116,7 @@ Material::Material()
{
mDiffuse[i].set( 1.0f, 1.0f, 1.0f, 1.0f );
mDiffuseMapSRGB[i] = true;
mDiffuseMapAsset[i] = StringTable->EmptyString();
mSmoothness[i] = 0.0f;
mMetalness[i] = 0.0f;
@ -172,8 +173,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();
}
dMemset(mCellIndex, 0, sizeof(mCellIndex));
@ -235,6 +238,9 @@ void Material::initPersistFields()
addField("diffuseMap", TypeImageFilename, Offset(mDiffuseMapFilename, Material), MAX_STAGES,
"The diffuse color texture map." );
addField("diffuseMapAsset", TypeImageAssetPtr, Offset(mDiffuseMapAsset, Material), MAX_STAGES,
"The diffuse color texture map." );
addField("diffuseMapSRGB", TypeBool, Offset(mDiffuseMapSRGB, Material), MAX_STAGES,
"Enable sRGB for the diffuse color texture map.");
@ -636,7 +642,7 @@ void Material::_mapMaterial()
// If mapTo not defined in script, try to use the base texture name instead
if( mMapTo.isEmpty() )
{
if ( mDiffuseMapFilename[0].isEmpty() )
if ( mDiffuseMapFilename[0].isEmpty() && mDiffuseMapAsset->isNull())
return;
else
@ -652,6 +658,10 @@ void Material::_mapMaterial()
// use everything after the last slash
mMapTo = mDiffuseMapFilename[0].substr(slashPos+1, mDiffuseMapFilename[0].length() - slashPos - 1);
}
else if (!mDiffuseMapAsset->isNull())
{
mMapTo = mDiffuseMapAsset[0]->getImageFileName();
}
}
}

View file

@ -45,6 +45,13 @@
#include "shaderGen/customShaderFeature.h"
#endif
#ifndef IMAGE_ASSET_H
#include "T3D/assets/ImageAsset.h"
#endif
#ifndef _ASSET_PTR_H_
#include "assets/assetPtr.h"
#endif
class CubemapData;
class SFXTrack;
struct SceneData;
@ -203,6 +210,8 @@ public:
// Data
//-----------------------------------------------------------------------
FileName mDiffuseMapFilename[MAX_STAGES];
StringTableEntry mDiffuseMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mDiffuseMapAsset[MAX_STAGES];
bool mDiffuseMapSRGB[MAX_STAGES]; // SRGB diffuse
bool mAccuEnabled[MAX_STAGES];
F32 mAccuScale[MAX_STAGES];
@ -211,24 +220,44 @@ public:
F32 mAccuCoverage[MAX_STAGES];
F32 mAccuSpecular[MAX_STAGES];
FileName mOverlayMapFilename[MAX_STAGES];
StringTableEntry mOverlayMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mOverlayMapAsset[MAX_STAGES];
FileName mLightMapFilename[MAX_STAGES];
StringTableEntry mLightMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mLightMapAsset[MAX_STAGES];
FileName mToneMapFilename[MAX_STAGES];
StringTableEntry mToneMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mToneMapAsset[MAX_STAGES];
FileName mDetailMapFilename[MAX_STAGES];
StringTableEntry mDetailMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mDetailMapAsset[MAX_STAGES];
FileName mNormalMapFilename[MAX_STAGES];
StringTableEntry mNormalMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mNormalMapAsset[MAX_STAGES];
bool mIsSRGb[MAX_STAGES];
bool mInvertSmoothness[MAX_STAGES];
FileName mSpecularMapFilename[MAX_STAGES];
StringTableEntry mSpecularMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mSpecularMapAsset[MAX_STAGES];
FileName mRoughMapFilename[MAX_STAGES];
StringTableEntry mRoughMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mRoughMapAsset[MAX_STAGES];
F32 mSmoothnessChan[MAX_STAGES];
FileName mAOMapFilename[MAX_STAGES];
StringTableEntry mAOMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mAOMapAsset[MAX_STAGES];
F32 mAOChan[MAX_STAGES];
FileName mMetalMapFilename[MAX_STAGES];
StringTableEntry mMetalMapAssetId[MAX_STAGES];
AssetPtr<ImageAsset> mMetalMapAsset[MAX_STAGES];
F32 mMetalChan[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<ImageAsset> mDetailNormalMapAsset[MAX_STAGES];
/// The strength scalar for the detail normal map.
F32 mDetailNormalMapStrength[MAX_STAGES];

View file

@ -409,6 +409,16 @@ void ProcessedMaterial::_setStageData()
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
}
}
else if (!mMaterial->mDiffuseMapAsset[i].isNull())
{
mStages[i].setTex(MFT_DiffuseMap, mMaterial->mDiffuseMapAsset[i]->getImage());
if (!mStages[i].getTex(MFT_DiffuseMap))
{
// Load a debug texture to make it clear to the user
// that the texture for this stage was missing.
mStages[i].setTex(MFT_DiffuseMap, _createTexture(GFXTextureManager::getMissingTexturePath().c_str(), &GFXStaticTextureSRGBProfile));
}
}
// OverlayMap
if (mMaterial->mOverlayMapFilename[i].isNotEmpty())