mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Updated TSStatic to utilize the getShapeAsset utility functions, and shifted the loader logic to utilize ShapeAssets exclusively, having straight file names go through the utility function to find/process a relevent asset.
This commit is contained in:
parent
6ade6f08ce
commit
7029024b8e
5 changed files with 127 additions and 141 deletions
|
|
@ -300,6 +300,7 @@ bool ShapeAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAss
|
||||||
//If possible, see if we can run an in-place import and the get the asset from that
|
//If possible, see if we can run an in-place import and the get the asset from that
|
||||||
#if TORQUE_DEBUG
|
#if TORQUE_DEBUG
|
||||||
Con::warnf("ShapeAsset::getAssetByFilename - Attempted to in-place import a shapefile(%s) that had no associated asset", 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);
|
ConsoleValueRef result = Con::executef("importLooseFile", fileName, true);
|
||||||
|
|
||||||
|
|
@ -315,7 +316,6 @@ bool ShapeAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAss
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//Didn't work, so have us fall back to a placeholder asset
|
//Didn't work, so have us fall back to a placeholder asset
|
||||||
shapeAsset->setAssetId(StringTable->insert("Core_Rendering:noshape"));
|
shapeAsset->setAssetId(StringTable->insert("Core_Rendering:noshape"));
|
||||||
|
|
|
||||||
|
|
@ -101,9 +101,6 @@ ConsoleDocClass( TSStatic,
|
||||||
);
|
);
|
||||||
|
|
||||||
TSStatic::TSStatic()
|
TSStatic::TSStatic()
|
||||||
:
|
|
||||||
cubeDescId( 0 ),
|
|
||||||
reflectorDesc( NULL )
|
|
||||||
{
|
{
|
||||||
mNetFlags.set(Ghostable | ScopeAlways);
|
mNetFlags.set(Ghostable | ScopeAlways);
|
||||||
|
|
||||||
|
|
@ -171,7 +168,7 @@ void TSStatic::initPersistFields()
|
||||||
&TSStatic::_setShapeAsset, &defaultProtectedGetFn,
|
&TSStatic::_setShapeAsset, &defaultProtectedGetFn,
|
||||||
"The source shape asset.");
|
"The source shape asset.");
|
||||||
|
|
||||||
addProtectedField("shapeName", TypeShapeFilename, Offset( mShapeName, TSStatic ), &TSStatic::_setShape, &defaultProtectedGetFn,
|
addProtectedField("shapeName", TypeFilename, Offset( mShapeName, TSStatic ), &TSStatic::_setShape, &defaultProtectedGetFn,
|
||||||
"%Path and filename of the model file (.DTS, .DAE) to use for this TSStatic."/*, AbstractClassRep::FieldFlags::FIELD_HideInInspectors*/ );
|
"%Path and filename of the model file (.DTS, .DAE) to use for this TSStatic."/*, AbstractClassRep::FieldFlags::FIELD_HideInInspectors*/ );
|
||||||
|
|
||||||
endGroup("Shape");
|
endGroup("Shape");
|
||||||
|
|
@ -219,11 +216,6 @@ void TSStatic::initPersistFields()
|
||||||
|
|
||||||
endGroup("Rendering");
|
endGroup("Rendering");
|
||||||
|
|
||||||
addGroup( "Reflection" );
|
|
||||||
addField( "cubeReflectorDesc", TypeRealString, Offset( cubeDescName, TSStatic ),
|
|
||||||
"References a ReflectorDesc datablock that defines performance and quality properties for dynamic reflections.\n");
|
|
||||||
endGroup( "Reflection" );
|
|
||||||
|
|
||||||
addGroup("Collision");
|
addGroup("Collision");
|
||||||
|
|
||||||
addField( "collisionType", TypeTSMeshType, Offset( mCollisionType, TSStatic ),
|
addField( "collisionType", TypeTSMeshType, Offset( mCollisionType, TSStatic ),
|
||||||
|
|
@ -265,18 +257,26 @@ bool TSStatic::_setShape(void* obj, const char* index, const char* data)
|
||||||
{
|
{
|
||||||
TSStatic* ts = static_cast<TSStatic*>(obj);// ->setFile(FileName(data));
|
TSStatic* ts = static_cast<TSStatic*>(obj);// ->setFile(FileName(data));
|
||||||
|
|
||||||
//before we continue, lets hit up the Asset Database to see if this file is associated to an asset. If so, we grab the asset instead
|
if (ShapeAsset::getAssetByFilename(StringTable->insert(data), &ts->mShapeAsset))
|
||||||
AssetQuery query;
|
|
||||||
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, data);
|
|
||||||
if (foundAssetcount == 0)
|
|
||||||
{
|
{
|
||||||
//didn't find any assets. continue as normal
|
//Special exception case. If we've defaulted to the 'no shape' mesh, don't save it out, we'll retain the original ids/paths so it doesn't break
|
||||||
ts->mShapeName = StringTable->insert(data);
|
//the TSStatic
|
||||||
|
|
||||||
|
if (ts->mShapeAsset.getAssetId() != StringTable->insert("Core_Rendering:noshape"))
|
||||||
|
{
|
||||||
|
//ts->mShapeAssetId = ts->mShapeAsset.getAssetId();
|
||||||
|
ts->mShapeName = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
/*else
|
||||||
|
{
|
||||||
|
ts->mShapeAssetId = StringTable->EmptyString();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
ts->_createShape();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ts->setShapeAsset(query.mAssetList[0]);
|
ts->mShapeAsset = StringTable->EmptyString();
|
||||||
ts->mShapeName = StringTable->EmptyString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -284,9 +284,9 @@ bool TSStatic::_setShape(void* obj, const char* index, const char* data)
|
||||||
|
|
||||||
bool TSStatic::_setShapeAsset(void* obj, const char* index, const char* data)
|
bool TSStatic::_setShapeAsset(void* obj, const char* index, const char* data)
|
||||||
{
|
{
|
||||||
TSStatic* ts = static_cast<TSStatic*>(obj);// ->setFile(FileName(data));
|
TSStatic* ts = static_cast<TSStatic*>(obj);
|
||||||
|
|
||||||
ts->setShapeAsset(StringTable->insert(data));
|
ts->setShapeAsset(data);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -366,14 +366,6 @@ bool TSStatic::onAdd()
|
||||||
|
|
||||||
addToScene();
|
addToScene();
|
||||||
|
|
||||||
if ( isClientObject() )
|
|
||||||
{
|
|
||||||
mCubeReflector.unregisterReflector();
|
|
||||||
|
|
||||||
if ( reflectorDesc )
|
|
||||||
mCubeReflector.registerReflector( this, reflectorDesc );
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateShouldTick();
|
_updateShouldTick();
|
||||||
|
|
||||||
// Accumulation and environment mapping
|
// Accumulation and environment mapping
|
||||||
|
|
@ -387,10 +379,23 @@ bool TSStatic::onAdd()
|
||||||
|
|
||||||
bool TSStatic::setShapeAsset(const StringTableEntry shapeAssetId)
|
bool TSStatic::setShapeAsset(const StringTableEntry shapeAssetId)
|
||||||
{
|
{
|
||||||
mShapeAssetId = shapeAssetId;
|
if (ShapeAsset::getAssetById(StringTable->insert(shapeAssetId), &mShapeAsset))
|
||||||
|
{
|
||||||
|
//Special exception case. If we've defaulted to the 'no shape' mesh, don't save it out, we'll retain the original ids/paths so it doesn't break
|
||||||
|
//the TSStatic
|
||||||
|
if (mShapeAsset.getAssetId() != StringTable->insert("Core_Rendering:noshape"))
|
||||||
|
{
|
||||||
|
mShapeName = StringTable->EmptyString();
|
||||||
|
}
|
||||||
|
|
||||||
_createShape();
|
_createShape();
|
||||||
return true;
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TSStatic::_createShape()
|
bool TSStatic::_createShape()
|
||||||
|
|
@ -403,54 +408,30 @@ bool TSStatic::_createShape()
|
||||||
SAFE_DELETE( mPhysicsRep );
|
SAFE_DELETE( mPhysicsRep );
|
||||||
SAFE_DELETE( mShapeInstance );
|
SAFE_DELETE( mShapeInstance );
|
||||||
mAmbientThread = NULL;
|
mAmbientThread = NULL;
|
||||||
mShape = NULL;
|
|
||||||
|
|
||||||
if (mShapeAssetId != StringTable->EmptyString())
|
if (mShapeAsset.isNull())
|
||||||
{
|
{
|
||||||
mShapeAsset = mShapeAssetId;
|
Con::errorf("[TSStatic] Failed to load shape asset.");
|
||||||
|
return false;
|
||||||
if (mShapeAsset.isNull())
|
|
||||||
{
|
|
||||||
Con::errorf("[TSStatic] Failed to load shape asset.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mShape = mShapeAsset->getShapeResource();
|
|
||||||
|
|
||||||
if(!mShape)
|
|
||||||
{
|
|
||||||
Con::errorf("TSStatic::_createShape() - Shape Asset had no valid shape!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!mShapeName || mShapeName[0] == '\0')
|
|
||||||
{
|
|
||||||
Con::errorf("TSStatic::_createShape() - No shape name!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mShapeHash = _StringTable::hashString(mShapeName);
|
|
||||||
|
|
||||||
mShape = ResourceManager::get().load(mShapeName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( bool(mShape) == false )
|
if(!mShapeAsset->getShapeResource())
|
||||||
{
|
{
|
||||||
Con::errorf( "TSStatic::_createShape() - Unable to load shape: %s", mShapeName );
|
Con::errorf("TSStatic::_createShape() - Shape Asset had no valid shape!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isClientObject() &&
|
if ( isClientObject() &&
|
||||||
!mShape->preloadMaterialList(mShape.getPath()) &&
|
!mShapeAsset->getShapeResource()->preloadMaterialList(mShapeAsset->getShapeFile()) &&
|
||||||
NetConnection::filesWereDownloaded() )
|
NetConnection::filesWereDownloaded() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mObjBox = mShape->mBounds;
|
TSShape* shape = mShapeAsset->getShapeResource();
|
||||||
|
|
||||||
|
mObjBox = shape->mBounds;
|
||||||
resetWorldBox();
|
resetWorldBox();
|
||||||
|
|
||||||
mShapeInstance = new TSShapeInstance( mShape, isClientObject() );
|
mShapeInstance = new TSShapeInstance(shape, isClientObject() );
|
||||||
if (isClientObject())
|
if (isClientObject())
|
||||||
{
|
{
|
||||||
mShapeInstance->cloneMaterialList();
|
mShapeInstance->cloneMaterialList();
|
||||||
|
|
@ -468,7 +449,7 @@ bool TSStatic::_createShape()
|
||||||
prepCollision();
|
prepCollision();
|
||||||
|
|
||||||
// Find the "ambient" animation if it exists
|
// Find the "ambient" animation if it exists
|
||||||
S32 ambientSeq = mShape->findSequence("ambient");
|
S32 ambientSeq = shape->findSequence("ambient");
|
||||||
|
|
||||||
if ( ambientSeq > -1 && !mAmbientThread )
|
if ( ambientSeq > -1 && !mAmbientThread )
|
||||||
mAmbientThread = mShapeInstance->addThread();
|
mAmbientThread = mShapeInstance->addThread();
|
||||||
|
|
@ -476,18 +457,8 @@ bool TSStatic::_createShape()
|
||||||
if ( mAmbientThread )
|
if ( mAmbientThread )
|
||||||
mShapeInstance->setSequence( mAmbientThread, ambientSeq, 0);
|
mShapeInstance->setSequence( mAmbientThread, ambientSeq, 0);
|
||||||
|
|
||||||
// Resolve CubeReflectorDesc.
|
|
||||||
if ( cubeDescName.isNotEmpty() )
|
|
||||||
{
|
|
||||||
Sim::findObject( cubeDescName, reflectorDesc );
|
|
||||||
}
|
|
||||||
else if( cubeDescId > 0 )
|
|
||||||
{
|
|
||||||
Sim::findObject( cubeDescId, reflectorDesc );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set up the material slot vars for easy manipulation
|
//Set up the material slot vars for easy manipulation
|
||||||
S32 materialCount = mShape->materialList->getMaterialNameList().size(); //mMeshAsset->getMaterialCount();
|
S32 materialCount = shape->materialList->getMaterialNameList().size(); //mMeshAsset->getMaterialCount();
|
||||||
|
|
||||||
if (isServerObject())
|
if (isServerObject())
|
||||||
{
|
{
|
||||||
|
|
@ -495,7 +466,7 @@ bool TSStatic::_createShape()
|
||||||
|
|
||||||
for (U32 i = 0; i < materialCount; i++)
|
for (U32 i = 0; i < materialCount; i++)
|
||||||
{
|
{
|
||||||
StringTableEntry materialname = StringTable->insert(mShape->materialList->getMaterialName(i).c_str());
|
StringTableEntry materialname = StringTable->insert(shape->materialList->getMaterialName(i).c_str());
|
||||||
|
|
||||||
dSprintf(matFieldName, 128, "MaterialSlot%d", i);
|
dSprintf(matFieldName, 128, "MaterialSlot%d", i);
|
||||||
StringTableEntry matFld = StringTable->insert(matFieldName);
|
StringTableEntry matFld = StringTable->insert(matFieldName);
|
||||||
|
|
@ -572,22 +543,24 @@ void TSStatic::prepCollision()
|
||||||
mLOSDetails.clear();
|
mLOSDetails.clear();
|
||||||
mConvexList->nukeList();
|
mConvexList->nukeList();
|
||||||
|
|
||||||
|
TSShape* shape = mShapeAsset->getShapeResource();
|
||||||
|
|
||||||
if ( mCollisionType == CollisionMesh || mCollisionType == VisibleMesh )
|
if ( mCollisionType == CollisionMesh || mCollisionType == VisibleMesh )
|
||||||
{
|
{
|
||||||
mShape->findColDetails( mCollisionType == VisibleMesh, &mCollisionDetails, &mLOSDetails );
|
shape->findColDetails( mCollisionType == VisibleMesh, &mCollisionDetails, &mLOSDetails );
|
||||||
if ( mDecalType == mCollisionType )
|
if ( mDecalType == mCollisionType )
|
||||||
{
|
{
|
||||||
mDecalDetailsPtr = &mCollisionDetails;
|
mDecalDetailsPtr = &mCollisionDetails;
|
||||||
}
|
}
|
||||||
else if ( mDecalType == CollisionMesh || mDecalType == VisibleMesh )
|
else if ( mDecalType == CollisionMesh || mDecalType == VisibleMesh )
|
||||||
{
|
{
|
||||||
mShape->findColDetails( mDecalType == VisibleMesh, &mDecalDetails, 0 );
|
shape->findColDetails( mDecalType == VisibleMesh, &mDecalDetails, 0 );
|
||||||
mDecalDetailsPtr = &mDecalDetails;
|
mDecalDetailsPtr = &mDecalDetails;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( mDecalType == CollisionMesh || mDecalType == VisibleMesh )
|
else if ( mDecalType == CollisionMesh || mDecalType == VisibleMesh )
|
||||||
{
|
{
|
||||||
mShape->findColDetails( mDecalType == VisibleMesh, &mDecalDetails, 0 );
|
shape->findColDetails( mDecalType == VisibleMesh, &mDecalDetails, 0 );
|
||||||
mDecalDetailsPtr = &mDecalDetails;
|
mDecalDetailsPtr = &mDecalDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -601,16 +574,18 @@ void TSStatic::_updatePhysics()
|
||||||
if ( !PHYSICSMGR || mCollisionType == None )
|
if ( !PHYSICSMGR || mCollisionType == None )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
TSShape* shape = mShapeAsset->getShapeResource();
|
||||||
|
|
||||||
PhysicsCollision *colShape = NULL;
|
PhysicsCollision *colShape = NULL;
|
||||||
if ( mCollisionType == Bounds )
|
if ( mCollisionType == Bounds )
|
||||||
{
|
{
|
||||||
MatrixF offset( true );
|
MatrixF offset( true );
|
||||||
offset.setPosition( mShape->center );
|
offset.setPosition(shape->center );
|
||||||
colShape = PHYSICSMGR->createCollision();
|
colShape = PHYSICSMGR->createCollision();
|
||||||
colShape->addBox( getObjBox().getExtents() * 0.5f * mObjScale, offset );
|
colShape->addBox( getObjBox().getExtents() * 0.5f * mObjScale, offset );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
colShape = mShape->buildColShape( mCollisionType == VisibleMesh, getScale() );
|
colShape = shape->buildColShape( mCollisionType == VisibleMesh, getScale() );
|
||||||
|
|
||||||
if ( colShape )
|
if ( colShape )
|
||||||
{
|
{
|
||||||
|
|
@ -643,8 +618,6 @@ void TSStatic::onRemove()
|
||||||
mShapeInstance = NULL;
|
mShapeInstance = NULL;
|
||||||
|
|
||||||
mAmbientThread = NULL;
|
mAmbientThread = NULL;
|
||||||
if ( isClientObject() )
|
|
||||||
mCubeReflector.unregisterReflector();
|
|
||||||
|
|
||||||
Parent::onRemove();
|
Parent::onRemove();
|
||||||
}
|
}
|
||||||
|
|
@ -800,12 +773,6 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
||||||
|
|
||||||
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
|
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
|
||||||
|
|
||||||
// If we're currently rendering our own reflection we
|
|
||||||
// don't want to render ourselves into it.
|
|
||||||
if ( mCubeReflector.isRendering() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
if ( mForceDetail == -1 )
|
if ( mForceDetail == -1 )
|
||||||
mShapeInstance->setDetailFromDistance( state, dist * invScale );
|
mShapeInstance->setDetailFromDistance( state, dist * invScale );
|
||||||
else
|
else
|
||||||
|
|
@ -822,9 +789,6 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
||||||
rdata.setFadeOverride( 1.0f );
|
rdata.setFadeOverride( 1.0f );
|
||||||
rdata.setOriginSort( mUseOriginSort );
|
rdata.setOriginSort( mUseOriginSort );
|
||||||
|
|
||||||
if ( mCubeReflector.isEnabled() )
|
|
||||||
rdata.setCubemap( mCubeReflector.getCubemap() );
|
|
||||||
|
|
||||||
// Acculumation
|
// Acculumation
|
||||||
rdata.setAccuTex(mAccuTex);
|
rdata.setAccuTex(mAccuTex);
|
||||||
|
|
||||||
|
|
@ -852,20 +816,6 @@ void TSStatic::prepRenderImage( SceneRenderState* state )
|
||||||
mat.scale( mObjScale );
|
mat.scale( mObjScale );
|
||||||
GFX->setWorldMatrix( mat );
|
GFX->setWorldMatrix( mat );
|
||||||
|
|
||||||
if ( state->isDiffusePass() && mCubeReflector.isEnabled() && mCubeReflector.getOcclusionQuery() )
|
|
||||||
{
|
|
||||||
RenderPassManager *pass = state->getRenderPass();
|
|
||||||
OccluderRenderInst *ri = pass->allocInst<OccluderRenderInst>();
|
|
||||||
|
|
||||||
ri->type = RenderPassManager::RIT_Occluder;
|
|
||||||
ri->query = mCubeReflector.getOcclusionQuery();
|
|
||||||
mObjToWorld.mulP( mObjBox.getCenter(), &ri->position );
|
|
||||||
ri->scale.set( mObjBox.getExtents() );
|
|
||||||
ri->orientation = pass->allocUniqueXform( mObjToWorld );
|
|
||||||
ri->isSphere = false;
|
|
||||||
state->getRenderPass()->addInst( ri );
|
|
||||||
}
|
|
||||||
|
|
||||||
mShapeInstance->animate();
|
mShapeInstance->animate();
|
||||||
if(mShapeInstance)
|
if(mShapeInstance)
|
||||||
{
|
{
|
||||||
|
|
@ -969,8 +919,8 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||||
|
|
||||||
if (stream->writeFlag(mask & AdvancedStaticOptionsMask))
|
if (stream->writeFlag(mask & AdvancedStaticOptionsMask))
|
||||||
{
|
{
|
||||||
stream->writeString(mShapeAssetId);
|
if(mShapeAsset->isAssetValid())
|
||||||
stream->writeString(mShapeName);
|
stream->writeString(mShapeAsset.getAssetId());
|
||||||
|
|
||||||
stream->write((U32)mDecalType);
|
stream->write((U32)mDecalType);
|
||||||
|
|
||||||
|
|
@ -1002,11 +952,6 @@ U32 TSStatic::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
|
||||||
if ( mLightPlugin )
|
if ( mLightPlugin )
|
||||||
retMask |= mLightPlugin->packUpdate(this, AdvancedStaticOptionsMask, con, mask, stream);
|
retMask |= mLightPlugin->packUpdate(this, AdvancedStaticOptionsMask, con, mask, stream);
|
||||||
|
|
||||||
if( stream->writeFlag( reflectorDesc != NULL ) )
|
|
||||||
{
|
|
||||||
stream->writeRangedU32( reflectorDesc->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast );
|
|
||||||
}
|
|
||||||
|
|
||||||
stream->write(mOverrideColor);
|
stream->write(mOverrideColor);
|
||||||
|
|
||||||
if (stream->writeFlag(mask & MaterialMask))
|
if (stream->writeFlag(mask & MaterialMask))
|
||||||
|
|
@ -1081,9 +1026,7 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
stream->readString(buffer);
|
stream->readString(buffer);
|
||||||
mShapeAssetId = StringTable->insert(buffer);
|
mShapeAsset = StringTable->insert(buffer);
|
||||||
|
|
||||||
mShapeName = stream->readSTString();
|
|
||||||
|
|
||||||
stream->read((U32*)&mDecalType);
|
stream->read((U32*)&mDecalType);
|
||||||
|
|
||||||
|
|
@ -1118,11 +1061,6 @@ void TSStatic::unpackUpdate(NetConnection *con, BitStream *stream)
|
||||||
mLightPlugin->unpackUpdate(this, con, stream);
|
mLightPlugin->unpackUpdate(this, con, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( stream->readFlag() )
|
|
||||||
{
|
|
||||||
cubeDescId = stream->readRangedU32( DataBlockObjectIdFirst, DataBlockObjectIdLast );
|
|
||||||
}
|
|
||||||
|
|
||||||
stream->read(&mOverrideColor);
|
stream->read(&mOverrideColor);
|
||||||
|
|
||||||
if (stream->readFlag())
|
if (stream->readFlag())
|
||||||
|
|
@ -1418,6 +1356,16 @@ void TSStatic::buildConvex(const Box3F& box, Convex* convex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Resource<TSShape> TSStatic::getShape() const
|
||||||
|
{
|
||||||
|
if (mShapeAsset->isAssetValid())
|
||||||
|
{
|
||||||
|
return mShapeAsset->getShapeResource();
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
SceneObject* TSStaticPolysoupConvex::smCurObject = NULL;
|
SceneObject* TSStaticPolysoupConvex::smCurObject = NULL;
|
||||||
|
|
||||||
TSStaticPolysoupConvex::TSStaticPolysoupConvex()
|
TSStaticPolysoupConvex::TSStaticPolysoupConvex()
|
||||||
|
|
@ -1586,7 +1534,7 @@ U32 TSStatic::getNumDetails()
|
||||||
|
|
||||||
void TSStatic::updateMaterials()
|
void TSStatic::updateMaterials()
|
||||||
{
|
{
|
||||||
if (mChangingMaterials.empty() || !mShape)
|
if (mChangingMaterials.empty() || !mShapeAsset->getShapeResource())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TSMaterialList* pMatList = mShapeInstance->getMaterialList();
|
TSMaterialList* pMatList = mShapeInstance->getMaterialList();
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,6 @@
|
||||||
#ifndef _TSSHAPE_H_
|
#ifndef _TSSHAPE_H_
|
||||||
#include "ts/tsShape.h"
|
#include "ts/tsShape.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _REFLECTOR_H_
|
|
||||||
#include "scene/reflector.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _ASSET_PTR_H_
|
#ifndef _ASSET_PTR_H_
|
||||||
#include "assets/assetPtr.h"
|
#include "assets/assetPtr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -179,18 +174,12 @@ protected:
|
||||||
/// Start or stop processing ticks depending on our state.
|
/// Start or stop processing ticks depending on our state.
|
||||||
void _updateShouldTick();
|
void _updateShouldTick();
|
||||||
|
|
||||||
String cubeDescName;
|
|
||||||
U32 cubeDescId;
|
|
||||||
ReflectorDesc *reflectorDesc;
|
|
||||||
CubeReflector mCubeReflector;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
Convex *mConvexList;
|
Convex *mConvexList;
|
||||||
|
|
||||||
StringTableEntry mShapeName;
|
StringTableEntry mShapeName;
|
||||||
U32 mShapeHash;
|
U32 mShapeHash;
|
||||||
Resource<TSShape> mShape;
|
|
||||||
Vector<S32> mCollisionDetails;
|
Vector<S32> mCollisionDetails;
|
||||||
Vector<S32> mLOSDetails;
|
Vector<S32> mLOSDetails;
|
||||||
TSShapeInstance *mShapeInstance;
|
TSShapeInstance *mShapeInstance;
|
||||||
|
|
@ -261,7 +250,7 @@ public:
|
||||||
|
|
||||||
bool allowPlayerStep() const { return mAllowPlayerStep; }
|
bool allowPlayerStep() const { return mAllowPlayerStep; }
|
||||||
|
|
||||||
Resource<TSShape> getShape() const { return mShape; }
|
Resource<TSShape> getShape() const;
|
||||||
StringTableEntry getShapeFileName() { return mShapeName; }
|
StringTableEntry getShapeFileName() { return mShapeName; }
|
||||||
void setShapeFileName(StringTableEntry shapeName) { mShapeName = shapeName; }
|
void setShapeFileName(StringTableEntry shapeName) { mShapeName = shapeName; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,29 @@ function findImageFile(%path, %materialName, %type)
|
||||||
return %path @ "/" @ %materialName @ ".tif";
|
return %path @ "/" @ %materialName @ ".tif";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAssetTypeByFilename(%filePath)
|
||||||
|
{
|
||||||
|
%fileExt = fileExt( %filePath );
|
||||||
|
|
||||||
|
//add it to our array!
|
||||||
|
if(isImageFormat(%fileExt))
|
||||||
|
return "ImageAsset";
|
||||||
|
else if( isShapeFormat(%fileExt))
|
||||||
|
return "ShapeAsset";
|
||||||
|
else if( isSoundFormat(%fileExt))
|
||||||
|
return "SoundAsset";
|
||||||
|
else if( %fileExt $= ".cs" || %fileExt $= ".cs.dso" )
|
||||||
|
return "ScriptAsset";
|
||||||
|
else if( %fileExt $= ".gui" || %fileExt $= ".gui.dso" )
|
||||||
|
return "GUIAsset";
|
||||||
|
else if (%fileExt $= ".zip")
|
||||||
|
return "zip";
|
||||||
|
else if( %fileExt $= "")
|
||||||
|
return "folder";
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
function AssetBrowser::onBeginDropFiles( %this )
|
function AssetBrowser::onBeginDropFiles( %this )
|
||||||
{
|
{
|
||||||
if(!AssetBrowser.isAwake())
|
if(!AssetBrowser.isAwake())
|
||||||
|
|
@ -405,20 +428,43 @@ function ImportAssetWindow::reloadImportOptionConfigs(%this)
|
||||||
//
|
//
|
||||||
function importLooseFile(%filePath, %forceAutoImport)
|
function importLooseFile(%filePath, %forceAutoImport)
|
||||||
{
|
{
|
||||||
|
%assetType = getAssetTypeByFilename(%filePath);
|
||||||
|
|
||||||
if(%forceAutoImport)
|
if(%forceAutoImport)
|
||||||
{
|
{
|
||||||
//If we're attempting to fast-track the import, check that that's even an option
|
//If we're attempting to fast-track the import, check that that's even an option
|
||||||
if(ImportAssetWindow.importConfigsList.count() == 0 ||
|
if(ImportAssetWindow.importConfigsList.count() == 0 ||
|
||||||
EditorSettings.value("Assets/AssetImporDefaultConfig") $= "" ||
|
EditorSettings.value("Assets/AssetImporDefaultConfig") $= "" ||
|
||||||
EditorSettings.value("Assets/AutoImport", false) == false)
|
EditorSettings.value("Assets/AutoImport", false) == false)
|
||||||
|
{
|
||||||
|
MessageBoxOK("Unable to AutoImport", "Attempted to import a loose file " @ %filePath @ " with AutoImport but was unable to either due to lacking a valid import config, or the editor settings are not set to auto import.");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(%assetType $= "folder" || %assetType $= "zip")
|
||||||
|
{
|
||||||
|
MessageBoxOK("Unable to AutoImport", "Unable to auto import folders or zips at this time");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(%assetType $= "")
|
||||||
|
{
|
||||||
|
MessageBoxOK("Unable to AutoImport", "Unable to auto import unknown file type for file " @ %filePath);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%assetItem = AssetBrowser.addImportingAsset("ImageAsset", %filePath, "", "");
|
|
||||||
|
%assetItem = AssetBrowser.addImportingAsset(%assetType, %filePath, "", "");
|
||||||
ImportAssetItems.add(%assetItem);
|
ImportAssetItems.add(%assetItem);
|
||||||
|
|
||||||
if(%forceAutoImport)
|
if(%forceAutoImport)
|
||||||
{
|
{
|
||||||
AssetImportTargetModule.text = AssetBrowser.dirHandler.getModuleFromAddress(filePath(%filePath)).ModuleId;
|
%targetModule = AssetBrowser.dirHandler.getModuleFromAddress(filePath(%filePath)).ModuleId;
|
||||||
|
AssetImportTargetModule.text = %targetModule;
|
||||||
|
|
||||||
|
%assetItem.moduleName = %targetModule;
|
||||||
|
|
||||||
|
AssetBrowser.dirHandler.currentAddress = filePath(%filePath);
|
||||||
|
|
||||||
//skip the refresh delay, we'll force it here
|
//skip the refresh delay, we'll force it here
|
||||||
ImportAssetWindow.doRefresh();
|
ImportAssetWindow.doRefresh();
|
||||||
|
|
|
||||||
|
|
@ -158,10 +158,13 @@ function AssetBrowser::importShapeAsset(%this, %assetItem)
|
||||||
%assetImportSuccessful = TAMLWrite(%newAsset, %assetPath @ %assetName @ ".asset.taml");
|
%assetImportSuccessful = TAMLWrite(%newAsset, %assetPath @ %assetName @ ".asset.taml");
|
||||||
|
|
||||||
//and copy the file into the relevent directory
|
//and copy the file into the relevent directory
|
||||||
%doOverwrite = !AssetBrowser.isAssetReImport;
|
if(filePath(%filePath) !$= filePath(%assetFullPath))
|
||||||
if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
|
|
||||||
{
|
{
|
||||||
error("Unable to import asset: " @ %filePath);
|
%doOverwrite = !AssetBrowser.isAssetReImport;
|
||||||
|
if(!pathCopy(%filePath, %assetFullPath, %doOverwrite))
|
||||||
|
{
|
||||||
|
error("Unable to import asset: " @ %filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
%constructor = ShapeEditor.findConstructor( %assetFullPath );
|
%constructor = ShapeEditor.findConstructor( %assetFullPath );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue