Converts all game, gui editor, and system classes to utilize assets

Processed core, tools and default modules to utilize assets
Converted all console types that were string based, such as TypeImageFilename to utilize const char*/the string table, which avoids a lot of type swapping shenanigans and avoids string corruption
Removed unneeded MainEditor mockup module
Removed some unused/duplicate image assets from the tools
This commit is contained in:
Areloch 2021-07-19 01:07:08 -05:00
parent 83b0432283
commit 5525f8ecdd
1708 changed files with 19619 additions and 4596 deletions

View file

@ -225,7 +225,6 @@ ConsoleDocClass( ExplosionData,
ExplosionData::ExplosionData()
{
dtsFileName = NULL;
particleDensity = 10;
particleRadius = 1.0f;
@ -238,7 +237,8 @@ ExplosionData::ExplosionData()
explosionScale.set(1.0f, 1.0f, 1.0f);
playSpeed = 1.0f;
explosionShape = NULL;
INIT_SHAPEASSET(ExplosionShape);
explosionAnimation = -1;
dMemset( emitterList, 0, sizeof( emitterList ) );
@ -305,7 +305,6 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game
Con::errorf("ExplosionData -- Clones are on the loose!");
#endif
dtsFileName = other.dtsFileName;
faceViewer = other.faceViewer;
particleDensity = other.particleDensity;
particleRadius = other.particleRadius;
@ -314,7 +313,7 @@ ExplosionData::ExplosionData(const ExplosionData& other, bool temp_clone) : Game
particleEmitterId = other.particleEmitterId; // -- for pack/unpack of particleEmitter ptr
explosionScale = other.explosionScale;
playSpeed = other.playSpeed;
explosionShape = other.explosionShape; // -- TSShape loaded using dtsFileName
CLONE_SHAPEASSET(ExplosionShape);
explosionAnimation = other.explosionAnimation; // -- from explosionShape sequence "ambient"
dMemcpy( emitterList, other.emitterList, sizeof( emitterList ) );
dMemcpy( emitterIDList, other.emitterIDList, sizeof( emitterIDList ) ); // -- for pack/unpack of emitterList ptrs
@ -392,10 +391,9 @@ ExplosionData* ExplosionData::cloneAndPerformSubstitutions(const SimObject* owne
void ExplosionData::initPersistFields()
{
addField( "explosionShape", TypeShapeFilename, Offset(dtsFileName, ExplosionData),
"@brief Optional DTS or DAE shape to place at the center of the explosion.\n\n"
"The <i>ambient</i> animation of this model will be played automatically at "
"the start of the explosion." );
INITPERSISTFIELD_SHAPEASSET(ExplosionShape, ExplosionData, "@brief Optional shape asset to place at the center of the explosion.\n\n"
"The <i>ambient</i> animation of this model will be played automatically at the start of the explosion.");
addField( "explosionScale", TypePoint3F, Offset(explosionScale, ExplosionData),
"\"X Y Z\" scale factor applied to the explosionShape model at the start "
"of the explosion." );
@ -656,7 +654,7 @@ void ExplosionData::packData(BitStream* stream)
{
Parent::packData(stream);
stream->writeString(dtsFileName);
PACKDATA_SHAPEASSET(ExplosionShape);
sfxWrite( stream, soundProfile );
if (stream->writeFlag(particleEmitter))
@ -759,7 +757,7 @@ void ExplosionData::unpackData(BitStream* stream)
{
Parent::unpackData(stream);
dtsFileName = stream->readSTString();
UNPACKDATA_SHAPEASSET(ExplosionShape);
sfxRead( stream, &soundProfile );
@ -874,22 +872,16 @@ bool ExplosionData::preload(bool server, String &errorStr)
Con::errorf(ConsoleLogEntry::General, "Error, unable to load particle emitter for explosion datablock");
}
if (dtsFileName && dtsFileName[0]) {
explosionShape = ResourceManager::get().load(dtsFileName);
if (!bool(explosionShape)) {
errorStr = String::ToString("ExplosionData: Couldn't load shape \"%s\"", dtsFileName);
return false;
}
if (mExplosionShapeAsset.notNull()) {
// Resolve animations
explosionAnimation = explosionShape->findSequence("ambient");
explosionAnimation = mExplosionShape->findSequence("ambient");
// Preload textures with a dummy instance...
TSShapeInstance* pDummy = new TSShapeInstance(explosionShape, !server);
TSShapeInstance* pDummy = new TSShapeInstance(mExplosionShape, !server);
delete pDummy;
} else {
explosionShape = NULL;
explosionAnimation = -1;
}
@ -1377,8 +1369,8 @@ bool Explosion::explode()
launchDebris( mInitialNormal );
spawnSubExplosions();
if (bool(mDataBlock->explosionShape) && mDataBlock->explosionAnimation != -1) {
mExplosionInstance = new TSShapeInstance(mDataBlock->explosionShape, true);
if (bool(mDataBlock->mExplosionShape) && mDataBlock->explosionAnimation != -1) {
mExplosionInstance = new TSShapeInstance(mDataBlock->mExplosionShape, true);
mExplosionThread = mExplosionInstance->addThread();
mExplosionInstance->setSequence(mExplosionThread, mDataBlock->explosionAnimation, 0);
@ -1388,7 +1380,7 @@ bool Explosion::explode()
mEndingMS = U32(mExplosionInstance->getScaledDuration(mExplosionThread) * 1000.0f);
mObjScale.convolve(mDataBlock->explosionScale);
mObjBox = mDataBlock->explosionShape->mBounds;
mObjBox = mDataBlock->mExplosionShape->mBounds;
resetWorldBox();
}

View file

@ -41,6 +41,8 @@
#include "lighting/lightInfo.h"
#endif
#include "T3D/assets/ShapeAsset.h"
class ParticleEmitter;
class ParticleEmitterData;
class TSThread;
@ -62,8 +64,6 @@ class ExplosionData : public GameBaseData {
};
public:
StringTableEntry dtsFileName;
bool faceViewer;
S32 particleDensity;
@ -76,7 +76,9 @@ class ExplosionData : public GameBaseData {
Point3F explosionScale;
F32 playSpeed;
Resource<TSShape> explosionShape;
DECLARE_SHAPEASSET(ExplosionData, ExplosionShape, onShapeChanged);
DECLARE_SHAPEASSET_SETGET(ExplosionData, ExplosionShape);
S32 explosionAnimation;
ParticleEmitterData* emitterList[EC_NUM_EMITTERS];
@ -137,6 +139,8 @@ public:
/*D*/ ~ExplosionData();
ExplosionData* cloneAndPerformSubstitutions(const SimObject*, S32 index=0);
virtual bool allowSubstitutions() const { return true; }
void onShapeChanged() {}
};

View file

@ -458,9 +458,9 @@ GroundCover::GroundCover()
mRandomSeed = 1;
initMaterialAsset(Material);
INIT_MATERIALASSET(Material);
mMaterialInst = NULL;
mMatInst = NULL;
mMatParams = NULL;
mTypeRectsParam = NULL;
mFadeParams = NULL;
@ -519,7 +519,8 @@ GroundCover::GroundCover()
mBillboardRects[i].point.set( 0.0f, 0.0f );
mBillboardRects[i].extent.set( 1.0f, 1.0f );
mShapeFilenames[i] = NULL;
INIT_SHAPEASSET_ARRAY(Shape, i);
mShapeInstances[i] = NULL;
mBillboardAspectScales[i] = 1.0f;
@ -530,7 +531,7 @@ GroundCover::GroundCover()
GroundCover::~GroundCover()
{
SAFE_DELETE( mMatInst );
SAFE_DELETE( mMaterialInst );
}
IMPLEMENT_CO_NETOBJECT_V1(GroundCover);
@ -539,7 +540,7 @@ void GroundCover::initPersistFields()
{
addGroup( "GroundCover General" );
scriptBindMaterialAsset(Material, GroundCover, "Material used by all GroundCover segments.");
INITPERSISTFIELD_MATERIALASSET(Material, GroundCover, "Material used by all GroundCover segments.");
addField( "radius", TypeF32, Offset( mRadius, GroundCover ), "Outer generation radius from the current camera position." );
addField( "dissolveRadius",TypeF32, Offset( mFadeRadius, GroundCover ), "This is less than or equal to radius and defines when fading of cover elements begins." );
@ -559,7 +560,8 @@ void GroundCover::initPersistFields()
addField( "billboardUVs", TypeRectUV, Offset( mBillboardRects, GroundCover ), MAX_COVERTYPES, "Subset material UV coordinates for this cover billboard." );
addField( "shapeFilename", TypeFilename, Offset( mShapeFilenames, GroundCover ), MAX_COVERTYPES, "The cover shape filename. [Optional]" );
INITPERSISTFIELD_SHAPEASSET_ARRAY(Shape, GroundCover, "The cover shape. [Optional]");
addField( "shapeFilename", TypeFilename, Offset( mShapeName, GroundCover ), MAX_COVERTYPES, "The cover shape filename. [Optional]", AbstractClassRep::FIELD_HideInInspectors );
addField( "layer", TypeTerrainMaterialName, Offset( mLayer, GroundCover ), MAX_COVERTYPES, "Terrain material name to limit coverage to, or blank to not limit." );
@ -710,7 +712,7 @@ U32 GroundCover::packUpdate( NetConnection *connection, U32 mask, BitStream *str
// TODO: We could probably optimize a few of these
// based on reasonable units at some point.
packMaterialAsset(connection, Material);
PACK_MATERIALASSET(connection, Material);
stream->write( mRadius );
stream->write( mZOffset );
@ -741,11 +743,11 @@ U32 GroundCover::packUpdate( NetConnection *connection, U32 mask, BitStream *str
stream->write( mMinSlope[i] );
stream->write( mMaxSlope[i] );
stream->writeFlag(mConformToNormal[i]);
stream->write(mMinRotX[i]);
stream->write(mMaxRotX[i]);
stream->write(mMinRotY[i]);
stream->write(mMaxRotY[i]);
stream->writeFlag(mConformToNormal[i]);
stream->write(mMinRotX[i]);
stream->write(mMaxRotX[i]);
stream->write(mMinRotY[i]);
stream->write(mMaxRotY[i]);
stream->write( mMinElevation[i] );
stream->write( mMaxElevation[i] );
@ -763,7 +765,7 @@ U32 GroundCover::packUpdate( NetConnection *connection, U32 mask, BitStream *str
stream->write( mBillboardRects[i].extent.x );
stream->write( mBillboardRects[i].extent.y );
stream->writeString( mShapeFilenames[i] );
PACK_SHAPEASSET_ARRAY(connection, Shape, i);
}
stream->writeFlag( mDebugRenderCells );
@ -781,7 +783,7 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
if (stream->readFlag())
{
unpackMaterialAsset(connection, Material);
UNPACK_MATERIALASSET(connection, Material);
stream->read( &mRadius );
stream->read( &mZOffset );
@ -812,11 +814,11 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
stream->read( &mMinSlope[i] );
stream->read( &mMaxSlope[i] );
mConformToNormal[i] = stream->readFlag();
stream->read(&mMinRotX[i]);
stream->read(&mMaxRotX[i]);
stream->read(&mMinRotY[i]);
stream->read(&mMaxRotY[i]);
mConformToNormal[i] = stream->readFlag();
stream->read(&mMinRotX[i]);
stream->read(&mMaxRotX[i]);
stream->read(&mMinRotY[i]);
stream->read(&mMaxRotY[i]);
stream->read( &mMinElevation[i] );
stream->read( &mMaxElevation[i] );
@ -834,7 +836,7 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
stream->read( &mBillboardRects[i].extent.x );
stream->read( &mBillboardRects[i].extent.y );
mShapeFilenames[i] = stream->readSTString();
UNPACK_SHAPEASSET_ARRAY(connection, Shape, i);
}
mDebugRenderCells = stream->readFlag();
@ -854,28 +856,8 @@ void GroundCover::unpackUpdate( NetConnection *connection, BitStream *stream )
void GroundCover::_initMaterial()
{
if (mMaterialAsset.notNull())
{
if (mMatInst && String(mMaterialAsset->getMaterialDefinitionName()).equal(mMatInst->getMaterial()->getName(), String::NoCase))
return;
SAFE_DELETE(mMatInst);
if (!Sim::findObject(mMaterialAsset->getMaterialDefinitionName(), mMaterial))
Con::errorf("GroundCover::_initMaterial - Material %s was not found.", mMaterialAsset->getMaterialDefinitionName());
if (mMaterial)
mMatInst = mMaterial->createMatInstance();
else
mMatInst = MATMGR->createMatInstance("WarningMaterial");
if (!mMatInst)
Con::errorf("GroundCover::_initMaterial - no Material called '%s'", mMaterialAsset->getMaterialDefinitionName());
}
else
{
if (!mMaterialInst)
return;
}
// Add our special feature that makes it all work...
FeatureSet features = MATMGR->getDefaultFeatures();
@ -883,10 +865,10 @@ void GroundCover::_initMaterial()
// Our feature requires a pointer back to this object
// to properly setup its shader consts.
mMatInst->setUserObject( this );
mMaterialInst->setUserObject( this );
// DO IT!
mMatInst->init( features, getGFXVertexFormat<GCVertex>() );
mMaterialInst->init( features, getGFXVertexFormat<GCVertex>() );
}
void GroundCover::_initShapes()
@ -895,25 +877,17 @@ void GroundCover::_initShapes()
for ( S32 i=0; i < MAX_COVERTYPES; i++ )
{
if ( !mShapeFilenames[i] || !mShapeFilenames[i][0] )
if ( mShapeAsset[i].isNull() || mShape[i] == nullptr)
continue;
// Load the shape.
Resource<TSShape> shape = ResourceManager::get().load(mShapeFilenames[i]);
if ( !(bool)shape )
if ( isClientObject() && !mShape[i]->preloadMaterialList(mShape[i].getPath()) && NetConnection::filesWereDownloaded() )
{
Con::warnf( "GroundCover::_initShapes() unable to load shape: %s", mShapeFilenames[i] );
continue;
}
if ( isClientObject() && !shape->preloadMaterialList(shape.getPath()) && NetConnection::filesWereDownloaded() )
{
Con::warnf( "GroundCover::_initShapes() material preload failed for shape: %s", mShapeFilenames[i] );
Con::warnf( "GroundCover::_initShapes() material preload failed for shape: %s", mShapeAssetId[i] );
continue;
}
// Create the shape instance.
mShapeInstances[i] = new TSShapeInstance( shape, isClientObject() );
mShapeInstances[i] = new TSShapeInstance(mShape[i], isClientObject() );
}
}
@ -982,16 +956,16 @@ void GroundCover::_initialize( U32 cellCount, U32 cellPlacementCount )
// Rebuild the texture aspect scales for each type.
F32 textureAspect = 1.0f;
if( mMatInst && mMatInst->isValid())
if( mMaterialInst && mMaterialInst->isValid())
{
Material* mat = dynamic_cast<Material*>(mMatInst->getMaterial());
Material* mat = dynamic_cast<Material*>(mMaterialInst->getMaterial());
if(mat)
{
GFXTexHandle tex;
if (!mat->mDiffuseMapFilename[0].isEmpty())
tex = GFXTexHandle(mat->mDiffuseMapFilename[0], &GFXStaticTextureSRGBProfile, "GroundCover texture aspect ratio check");
if (mat->mDiffuseMapName[0] != StringTable->EmptyString())
tex = GFXTexHandle(mat->mDiffuseMapName[0], &GFXStaticTextureSRGBProfile, "GroundCover texture aspect ratio check");
else if (!mat->mDiffuseMapAsset[0].isNull())
tex = mat->mDiffuseMapAsset[0]->getImage(GFXStaticTextureSRGBProfile);
tex = mat->mDiffuseMapAsset[0]->getTexture(&GFXStaticTextureSRGBProfile);
if(tex.isValid())
{
@ -1580,7 +1554,7 @@ void GroundCover::_updateCoverGrid( const Frustum &culler )
void GroundCover::prepRenderImage( SceneRenderState *state )
{
// Reset stats each time we hit the diffuse pass.
if (mMatInst == nullptr)
if (mMaterialInst == nullptr)
return;
if( state->isDiffusePass() )
@ -1617,7 +1591,7 @@ void GroundCover::prepRenderImage( SceneRenderState *state )
// Render billboards but not into shadow passes.
if ( !state->isShadowPass() && mMatInst->isValid() && !mDebugNoBillboards )
if ( !state->isShadowPass() && mMaterialInst->isValid() && !mDebugNoBillboards )
{
PROFILE_SCOPE( GroundCover_RenderBillboards );
@ -1692,7 +1666,7 @@ void GroundCover::prepRenderImage( SceneRenderState *state )
if ( mCuller.isCulled( cell->getRenderBounds() ) )
continue;
cell->renderBillboards( state, mMatInst, &mPrimBuffer );
cell->renderBillboards( state, mMaterialInst, &mPrimBuffer );
}
}

View file

@ -45,7 +45,7 @@
#include "shaderGen/shaderFeature.h"
#endif
#include "T3D/assets/MaterialAsset.h"
#include "T3D/assets/ShapeAsset.h"
class TerrainBlock;
class GroundCoverCell;
@ -266,9 +266,10 @@ protected:
static F32 smDensityScale;
static F32 smFadeScale;
DECLARE_NET_MATERIALASSET(GroundCover, Material, InitialUpdateMask);
Material* mMaterial;
BaseMatInstance *mMatInst;
BaseMatInstance* mMaterialInst;
DECLARE_MATERIALASSET(GroundCover, Material);
DECLARE_MATERIALASSET_NET_SETGET(GroundCover, Material, InitialUpdateMask);
GroundCoverShaderConstData mShaderConstData;
@ -339,7 +340,8 @@ protected:
RectF mBillboardRects[MAX_COVERTYPES];
/// The cover shape filenames.
StringTableEntry mShapeFilenames[MAX_COVERTYPES];
DECLARE_SHAPEASSET_ARRAY(GroundCover, Shape, MAX_COVERTYPES);
DECLARE_SHAPEASSET_ARRAY_NET_SETGET(GroundCover, Shape, -1);
/// The cover shape instances.
TSShapeInstance* mShapeInstances[MAX_COVERTYPES];

View file

@ -121,10 +121,10 @@ ParticleData::ParticleData()
animTexTiling.set(0,0); // tiling dimensions
animTexFramesString = NULL; // string of animation frame indices
animTexUVs = NULL; // array of tile vertex UVs
textureName = NULL; // texture filename
textureHandle = NULL; // loaded texture handle
textureExtName = NULL;
textureExtHandle = NULL;
INIT_IMAGEASSET(Texture);
INIT_IMAGEASSET(TextureExt);
constrain_pos = false;
start_angle = 0.0f;
angle_variance = 0.0f;
@ -203,11 +203,13 @@ void ParticleData::initPersistFields()
"animTexFrames = \"0-16 20 19 18 17 31-21\";\n"
"@endtsexample\n" );
addField( "textureName", TYPEID< StringTableEntry >(), Offset(textureName, ParticleData),
"Texture file to use for this particle." );
addField( "animTexName", TYPEID< StringTableEntry >(), Offset(textureName, ParticleData),
addProtectedField( "textureName", TYPEID< StringTableEntry >(), Offset(mTextureName, ParticleData), _setTextureData, defaultProtectedGetFn,
"Texture file to use for this particle.", AbstractClassRep::FIELD_HideInInspectors );
addField( "animTexName", TYPEID< StringTableEntry >(), Offset(mTextureName, ParticleData),
"@brief Texture file to use for this particle if animateTexture is true.\n\n"
"Deprecated. Use textureName instead." );
"Deprecated. Use textureName instead.", AbstractClassRep::FIELD_HideInInspectors);
INITPERSISTFIELD_IMAGEASSET(Texture, ParticleData, "Texture to use for this particle.");
// Interpolation variables
addField( "colors", TYPEID< LinearColorF >(), Offset(colors, ParticleData), PDC_NUM_KEYS,
@ -224,8 +226,9 @@ void ParticleData::initPersistFields()
"@brief Time keys used with the colors and sizes keyframes.\n\n"
"Values are from 0.0 (particle creation) to 1.0 (end of lifespace)." );
addGroup("AFX");
addField("textureExtName", TypeFilename, Offset(textureExtName, ParticleData));
addGroup("AFX");
addProtectedField("textureExtName", TypeFilename, Offset(mTextureExtName, ParticleData), _setTextureExtData, &defaultProtectedGetFn, "", AbstractClassRep::FIELD_HideInInspectors);
INITPERSISTFIELD_IMAGEASSET(TextureExt, ParticleData, "");
addField("constrainPos", TypeBool, Offset(constrain_pos, ParticleData));
addField("angle", TypeF32, Offset(start_angle, ParticleData));
addField("angleVariance", TypeF32, Offset(angle_variance, ParticleData));
@ -290,8 +293,8 @@ void ParticleData::packData(BitStream* stream)
stream->writeFloat( times[i], 8);
}
if (stream->writeFlag(textureName && textureName[0]))
stream->writeString(textureName);
//PACKDATA_IMAGEASSET(Texture);
for (i = 0; i < 4; i++)
mathWrite(*stream, texCoords[i]);
if (stream->writeFlag(animateTexture))
@ -303,8 +306,9 @@ void ParticleData::packData(BitStream* stream)
mathWrite(*stream, animTexTiling);
stream->writeInt(framesPerSec, 8);
}
if (stream->writeFlag(textureExtName && textureExtName[0]))
stream->writeString(textureExtName);
//PACKDATA_IMAGEASSET(TextureExt);
stream->writeFlag(constrain_pos);
stream->writeFloat(start_angle/360.0f, 11);
stream->writeFloat(angle_variance/180.0f, 10);
@ -373,7 +377,9 @@ void ParticleData::unpackData(BitStream* stream)
sizes[i] = stream->readFloat(16) * MaxParticleSize;
times[i] = stream->readFloat(8);
}
textureName = (stream->readFlag()) ? stream->readSTString() : 0;
//UNPACKDATA_IMAGEASSET(Texture);
for (i = 0; i < 4; i++)
mathRead(*stream, &texCoords[i]);
@ -384,7 +390,9 @@ void ParticleData::unpackData(BitStream* stream)
mathRead(*stream, &animTexTiling);
framesPerSec = stream->readInt(8);
}
textureExtName = (stream->readFlag()) ? stream->readSTString() : 0;
//UNPACKDATA_IMAGEASSET(Texture);
constrain_pos = stream->readFlag();
start_angle = 360.0f*stream->readFloat(11);
angle_variance = 180.0f*stream->readFloat(10);
@ -556,27 +564,6 @@ bool ParticleData::preload(bool server, String &errorStr)
bool error = false;
if(!server)
{
// Here we attempt to load the particle's texture if specified. An undefined
// texture is *not* an error since the emitter may provide one.
if (textureName && textureName[0])
{
textureHandle = GFXTexHandle(textureName, &GFXStaticTextureSRGBProfile, avar("%s() - textureHandle (line %d)", __FUNCTION__, __LINE__));
if (!textureHandle)
{
errorStr = String::ToString("Missing particle texture: %s", textureName);
error = true;
}
}
if (textureExtName && textureExtName[0])
{
textureExtHandle = GFXTexHandle(textureExtName, &GFXStaticTextureSRGBProfile, avar("%s() - textureExtHandle (line %d)", __FUNCTION__, __LINE__));
if (!textureExtHandle)
{
errorStr = String::ToString("Missing particle texture: %s", textureName);
error = true;
}
}
if (animateTexture)
{
// Here we parse animTexFramesString into byte-size frame numbers in animTexFrames.
@ -698,15 +685,14 @@ void ParticleData::initializeParticle(Particle* init, const Point3F& inheritVelo
bool ParticleData::reload(char errorBuffer[256])
{
bool error = false;
if (textureName && textureName[0])
StringTableEntry particleTex = getTexture();
if (!_setTexture(particleTex))
{
textureHandle = GFXTexHandle(textureName, &GFXStaticTextureSRGBProfile, avar("%s() - textureHandle (line %d)", __FUNCTION__, __LINE__));
if (!textureHandle)
{
dSprintf(errorBuffer, 256, "Missing particle texture: %s", textureName);
error = true;
}
}
dSprintf(errorBuffer, 256, "Missing particle texture: %s", particleTex);
}
/*
numFrames = 0;
for( S32 i=0; i<PDC_MAX_TEX; i++ )
@ -776,12 +762,14 @@ ParticleData::ParticleData(const ParticleData& other, bool temp_clone) : SimData
animTexTiling = other.animTexTiling;
animTexFramesString = other.animTexFramesString;
animTexFrames = other.animTexFrames; // -- parsed from animTexFramesString
textureName = other.textureName;
textureHandle = other.textureHandle;
CLONE_IMAGEASSET(Texture);
spinBias = other.spinBias;
randomizeSpinDir = other.randomizeSpinDir;
textureExtName = other.textureExtName;
textureExtHandle = other.textureExtHandle;
CLONE_IMAGEASSET(TextureExt);
constrain_pos = other.constrain_pos;
start_angle = other.start_angle;
angle_variance = other.angle_variance;
@ -815,3 +803,5 @@ void ParticleData::onPerformSubstitutions()
char errorBuffer[256];
reload(errorBuffer);
}
DEF_IMAGEASSET_BINDS(ParticleData, Texture);

View file

@ -35,6 +35,8 @@
#include "gfx/gfxTextureHandle.h"
#endif
#include "T3D/assets/ImageAsset.h"
#define MaxParticleSize 50.0
struct Particle;
@ -83,13 +85,16 @@ class ParticleData : public SimDataBlock
Point2I animTexTiling;
StringTableEntry animTexFramesString;
Vector<U8> animTexFrames;
StringTableEntry textureName;
GFXTexHandle textureHandle;
static bool protectedSetSizes( void *object, const char *index, const char *data );
static bool protectedSetTimes( void *object, const char *index, const char *data );
DECLARE_IMAGEASSET(ParticleData, Texture, onImageChanged, GFXStaticTextureSRGBProfile);
DECLARE_IMAGEASSET_SETGET(ParticleData, Texture);
public:
static bool protectedSetSizes(void* object, const char* index, const char* data);
static bool protectedSetTimes(void* object, const char* index, const char* data);
void onImageChanged() {}
public:
ParticleData();
~ParticleData();
@ -111,9 +116,10 @@ class ParticleData : public SimDataBlock
protected:
F32 spinBias;
bool randomizeSpinDir;
StringTableEntry textureExtName;
public:
GFXTexHandle textureExtHandle;
DECLARE_IMAGEASSET(ParticleData, TextureExt, onImageChanged, GFXStaticTextureSRGBProfile);
DECLARE_IMAGEASSET_SETGET(ParticleData, TextureExt);
bool constrain_pos;
F32 start_angle;
F32 angle_variance;

View file

@ -741,11 +741,11 @@ bool ParticleEmitterData::preload(bool server, String &errorStr)
// otherwise, check that all particles refer to the same texture
else if (particleDataBlocks.size() > 1)
{
StringTableEntry txr_name = particleDataBlocks[0]->textureName;
StringTableEntry txr_name = particleDataBlocks[0]->getTexture();
for (S32 i = 1; i < particleDataBlocks.size(); i++)
{
// warn if particle textures are inconsistent
if (particleDataBlocks[i]->textureName != txr_name)
if (particleDataBlocks[i]->getTexture() != txr_name)
{
Con::warnf(ConsoleLogEntry::General, "ParticleEmitterData(%s) particles reference different textures.", getName());
break;
@ -1225,7 +1225,7 @@ void ParticleEmitter::prepRenderImage(SceneRenderState* state)
if (mDataBlock->textureHandle)
ri->diffuseTex = &*(mDataBlock->textureHandle);
else
ri->diffuseTex = &*(part_list_head.next->dataBlock->textureHandle);
ri->diffuseTex = &*(part_list_head.next->dataBlock->getTextureResource());
ri->softnessDistance = mDataBlock->softnessDistance;

View file

@ -129,9 +129,12 @@ PrecipitationData::PrecipitationData()
{
soundProfile = NULL;
mDropName = StringTable->EmptyString();
INIT_IMAGEASSET(Drop);
mDropShaderName = StringTable->EmptyString();
mSplashName = StringTable->EmptyString();
INIT_IMAGEASSET(Splash);
mSplashShaderName = StringTable->EmptyString();
mDropsPerSide = 4;
@ -142,18 +145,32 @@ void PrecipitationData::initPersistFields()
{
addField( "soundProfile", TYPEID< SFXTrack >(), Offset(soundProfile, PrecipitationData),
"Looping SFXProfile effect to play while Precipitation is active." );
addField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData),
addProtectedField( "dropTexture", TypeFilename, Offset(mDropName, PrecipitationData), &_setDropData, &defaultProtectedGetFn,
"@brief Texture filename for drop particles.\n\n"
"The drop texture can contain several different drop sub-textures "
"arranged in a grid. There must be the same number of rows as columns. A "
"random frame will be chosen for each drop." );
"random frame will be chosen for each drop.", AbstractClassRep::FIELD_HideInInspectors );
INITPERSISTFIELD_IMAGEASSET(Drop, PrecipitationData, "@brief Texture for drop particles.\n\n"
"The drop texture can contain several different drop sub-textures "
"arranged in a grid. There must be the same number of rows as columns. A "
"random frame will be chosen for each drop.");
addField( "dropShader", TypeString, Offset(mDropShaderName, PrecipitationData),
"The name of the shader used for raindrops." );
addField( "splashTexture", TypeFilename, Offset(mSplashName, PrecipitationData),
addProtectedField("splashTexture", TypeFilename, Offset(mSplashName, PrecipitationData), &_setSplashData, &defaultProtectedGetFn,
"@brief Texture filename for splash particles.\n\n"
"The splash texture can contain several different splash sub-textures "
"arranged in a grid. There must be the same number of rows as columns. A "
"random frame will be chosen for each splash." );
"random frame will be chosen for each splash.", AbstractClassRep::FIELD_HideInInspectors);
INITPERSISTFIELD_IMAGEASSET(Splash, PrecipitationData, "@brief Texture for splash particles.\n\n"
"The splash texture can contain several different splash sub-textures "
"arranged in a grid. There must be the same number of rows as columns. A "
"random frame will be chosen for each splash.");
addField( "splashShader", TypeString, Offset(mSplashShaderName, PrecipitationData),
"The name of the shader used for splashes." );
addField( "dropsPerSide", TypeS32, Offset(mDropsPerSide, PrecipitationData),
@ -185,9 +202,12 @@ void PrecipitationData::packData(BitStream* stream)
sfxWrite( stream, soundProfile );
stream->writeString(mDropName);
PACKDATA_IMAGEASSET(Drop);
stream->writeString(mDropShaderName);
stream->writeString(mSplashName);
PACKDATA_IMAGEASSET(Splash);
stream->writeString(mSplashShaderName);
stream->write(mDropsPerSide);
stream->write(mSplashesPerSide);
@ -199,9 +219,12 @@ void PrecipitationData::unpackData(BitStream* stream)
sfxRead( stream, &soundProfile );
mDropName = stream->readSTString();
UNPACKDATA_IMAGEASSET(Drop);
mDropShaderName = stream->readSTString();
mSplashName = stream->readSTString();
UNPACKDATA_IMAGEASSET(Splash);
mSplashShaderName = stream->readSTString();
stream->read(&mDropsPerSide);
stream->read(&mSplashesPerSide);
@ -604,8 +627,8 @@ void Precipitation::initMaterials()
mDropShader = NULL;
mSplashShader = NULL;
if( dStrlen(pd->mDropName) > 0 && !mDropHandle.set(pd->mDropName, &GFXStaticTextureSRGBProfile, avar("%s() - mDropHandle (line %d)", __FUNCTION__, __LINE__)) )
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->mDropName);
if(pd->mDrop.isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getDrop());
if ( dStrlen(pd->mDropShaderName) > 0 )
{
@ -625,8 +648,8 @@ void Precipitation::initMaterials()
}
}
if( dStrlen(pd->mSplashName) > 0 && !mSplashHandle.set(pd->mSplashName, &GFXStaticTextureSRGBProfile, avar("%s() - mSplashHandle (line %d)", __FUNCTION__, __LINE__)) )
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->mSplashName);
if (pd->mSplash.isNull())
Con::warnf("Precipitation::initMaterials - failed to locate texture '%s'!", pd->getSplash());
if ( dStrlen(pd->mSplashShaderName) > 0 )
{

View file

@ -33,6 +33,8 @@
#include "renderInstance/renderPassManager.h"
#endif
#include "T3D/assets/ImageAsset.h"
class SFXTrack;
class SFXSource;
@ -45,9 +47,14 @@ class PrecipitationData : public GameBaseData
public:
SFXTrack* soundProfile;
StringTableEntry mDropName; ///< Texture filename for drop particles
DECLARE_IMAGEASSET(PrecipitationData, Drop, onDropChanged, GFXStaticTextureSRGBProfile); ///< Texture for drop particles
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Drop);
StringTableEntry mDropShaderName; ///< The name of the shader used for raindrops
StringTableEntry mSplashName; ///< Texture filename for splash particles
DECLARE_IMAGEASSET(PrecipitationData, Splash, onSplashChanged, GFXStaticTextureSRGBProfile); ///< Texture for splash particles
DECLARE_IMAGEASSET_SETGET(PrecipitationData, Splash);
StringTableEntry mSplashShaderName; ///< The name of the shader used for raindrops
S32 mDropsPerSide; ///< How many drops are on a side of the raindrop texture.
@ -59,6 +66,9 @@ class PrecipitationData : public GameBaseData
static void initPersistFields();
virtual void packData(BitStream* stream);
virtual void unpackData(BitStream* stream);
void onDropChanged() {}
void onSplashChanged() {}
};
struct Raindrop

View file

@ -93,9 +93,10 @@ SplashData::SplashData()
explosion = NULL;
explosionId = 0;
dMemset( textureName, 0, sizeof( textureName ) );
U32 i;
for (i = 0; i < NUM_TEX; i++)
INIT_IMAGEASSET_ARRAY(Texture, i);
for( i=0; i<NUM_TIME_KEYS; i++ )
times[i] = 1.0;
@ -125,7 +126,9 @@ SplashData::SplashData()
addField("acceleration", TypeF32, Offset(acceleration, SplashData), "Constant acceleration value to place upon the splash effect.\n");
addField("times", TypeF32, Offset(times, SplashData), NUM_TIME_KEYS, "Times to transition through the splash effect. Up to 4 allowed. Values are 0.0 - 1.0, and corrispond to the life of the particle where 0 is first created and 1 is end of lifespace.\n" );
addField("colors", TypeColorF, Offset(colors, SplashData), NUM_TIME_KEYS, "Color values to set the splash effect, rgba. Up to 4 allowed. Will transition through colors based on values set in the times value. Example: colors[0] = \"0.6 1.0 1.0 0.5\".\n" );
addField("texture", TypeFilename, Offset(textureName, SplashData), NUM_TEX, "Imagemap file to use as the texture for the splash effect.\n");
INITPERSISTFIELD_IMAGEASSET_ARRAY(Texture, NUM_TEX, SplashData, "Image to use as the texture for the splash effect.\n");
addField("texWrap", TypeF32, Offset(texWrap, SplashData), "Amount to wrap the texture around the splash ring, 0.0f - 1.0f.\n");
addField("texFactor", TypeF32, Offset(texFactor, SplashData), "Factor in which to apply the texture to the splash ring, 0.0f - 1.0f.\n");
addField("ejectionFreq", TypeF32, Offset(ejectionFreq, SplashData), "Frequency in which to emit splash rings.\n");
@ -198,7 +201,7 @@ void SplashData::packData(BitStream* stream)
for( i=0; i<NUM_TEX; i++ )
{
stream->writeString(textureName[i]);
PACKDATA_IMAGEASSET_ARRAY(Texture, i);
}
}
@ -252,7 +255,7 @@ void SplashData::unpackData(BitStream* stream)
for( i=0; i<NUM_TEX; i++ )
{
textureName[i] = stream->readSTString();
UNPACKDATA_IMAGEASSET_ARRAY(Texture, i);
}
}
@ -280,9 +283,9 @@ bool SplashData::preload(bool server, String &errorStr)
for( i=0; i<NUM_TEX; i++ )
{
if (textureName[i] && textureName[i][0])
if (mTexture[i].isNull())
{
textureHandle[i] = GFXTexHandle(textureName[i], &GFXStaticTextureSRGBProfile, avar("%s() - textureHandle[%d] (line %d)", __FUNCTION__, i, __LINE__) );
_setTexture(getTexture(i), i);
}
}
}

View file

@ -33,6 +33,8 @@
#include "gfx/gfxTextureHandle.h"
#include "T3D/assets/ImageAsset.h"
class ParticleEmitter;
class ParticleEmitterData;
class AudioProfile;
@ -116,8 +118,8 @@ public:
F32 times[ NUM_TIME_KEYS ];
LinearColorF colors[ NUM_TIME_KEYS ];
StringTableEntry textureName[NUM_TEX];
GFXTexHandle textureHandle[NUM_TEX];
DECLARE_IMAGEASSET_ARRAY(SplashData, Texture, GFXStaticTextureSRGBProfile, NUM_TEX);
DECLARE_IMAGEASSET_ARRAY_SETGET(SplashData, Texture)
ExplosionData* explosion;
S32 explosionId;