mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
corrected and implemented a usage of shapeasset macros (and stray membervars touched). todo: shapebaseimage, debris.
This commit is contained in:
parent
52ecd8bb0f
commit
516a05301f
|
|
@ -57,7 +57,9 @@
|
|||
#ifdef TORQUE_TOOLS
|
||||
#include "gui/editor/guiInspectorTypes.h"
|
||||
#endif
|
||||
|
||||
#ifndef _BITSTREAM_H_
|
||||
#include "core/stream/bitStream.h"
|
||||
#endif
|
||||
//-----------------------------------------------------------------------------
|
||||
class ShapeAsset : public AssetBase
|
||||
{
|
||||
|
|
@ -207,19 +209,19 @@ public:
|
|||
|
||||
#define assetText(x,suff) std::string(std::string(#x) + std::string(#suff)).c_str()
|
||||
|
||||
#define initShapeAsset(name) m##name##Filename = StringTable->EmptyString(); m##name##AssetId = StringTable->EmptyString(); m##name##Asset = NULL;
|
||||
#define initShapeAsset(name) m##name##Name = StringTable->EmptyString(); m##name##AssetId = StringTable->EmptyString(); m##name##Asset = NULL;
|
||||
#define cloneShapeAsset(name) m##name##Name = other.m##name##Name; m##name##AssetId = other.m##name##AssetId; m##name##Asset = other.m##name##Asset;
|
||||
#define bindShapeAsset(name) if (m##name##AssetId != StringTable->EmptyString()) m##name##Asset = m##name##AssetId;
|
||||
|
||||
#define scriptBindShapeAsset(name, consoleClass, docs) addProtectedField(assetText(name, File), TypeShapeFilename, Offset(m##name##Filename, consoleClass), consoleClass::_set##name##Filename, & defaultProtectedGetFn, assetText(name, docs)); \
|
||||
#define scriptBindShapeAsset(name, consoleClass, docs) addProtectedField(assetText(name, File), TypeShapeFilename, Offset(m##name##Name, consoleClass), consoleClass::_set##name##Filename, & defaultProtectedGetFn, assetText(name, docs)); \
|
||||
addProtectedField(assetText(name, Asset), TypeShapeAssetId, Offset(m##name##AssetId, consoleClass), consoleClass::_set##name##Asset, & defaultProtectedGetFn, assetText(name, asset reference.));
|
||||
|
||||
#define DECLARE_SHAPEASSET(className,name) protected: \
|
||||
StringTableEntry m##name##Filename;\
|
||||
#define DECLARE_SHAPEASSET(className,name)\
|
||||
StringTableEntry m##name##Name;\
|
||||
StringTableEntry m##name##AssetId;\
|
||||
AssetPtr<ShapeAsset> m##name##Asset;\
|
||||
public: \
|
||||
const StringTableEntry& get##name() const { return m##name##Filename; }\
|
||||
void set##name(FileName _in) { m##name##Filename = _in; }\
|
||||
const StringTableEntry& get##name() const { return m##name##Name; }\
|
||||
void set##name(FileName _in) { m##name##Name = _in; }\
|
||||
const AssetPtr<ShapeAsset> & get##name##Asset() const { return m##name##Asset; }\
|
||||
void set##name##Asset(AssetPtr<ShapeAsset>_in) { m##name##Asset = _in; }\
|
||||
static bool _set##name##Filename(void* obj, const char* index, const char* data)\
|
||||
|
|
@ -233,7 +235,7 @@ static bool _set##name##Filename(void* obj, const char* index, const char* data)
|
|||
{\
|
||||
if (assetId == StringTable->insert("Core_Rendering:noShape"))\
|
||||
{\
|
||||
shape->m##name##Filename = data;\
|
||||
shape->m##name##Name = data;\
|
||||
shape->m##name##AssetId = StringTable->EmptyString();\
|
||||
\
|
||||
return true;\
|
||||
|
|
@ -241,7 +243,7 @@ static bool _set##name##Filename(void* obj, const char* index, const char* data)
|
|||
else\
|
||||
{\
|
||||
shape->m##name##AssetId = assetId;\
|
||||
shape->m##name##Filename = StringTable->EmptyString();\
|
||||
shape->m##name##Name = StringTable->EmptyString();\
|
||||
\
|
||||
return false;\
|
||||
}\
|
||||
|
|
@ -262,12 +264,28 @@ static bool _set##name##Asset(void* obj, const char* index, const char* data)\
|
|||
if (ShapeAsset::getAssetById(shape->m##name##AssetId, &shape->m##name##Asset))\
|
||||
{\
|
||||
if (shape->m##name##Asset.getAssetId() != StringTable->insert("Core_Rendering:noShape"))\
|
||||
shape->m##name##Filename = StringTable->EmptyString();\
|
||||
\
|
||||
shape->setMaskBits(-1);\
|
||||
shape->m##name##Name = StringTable->EmptyString();\
|
||||
return true;\
|
||||
}\
|
||||
return false;\
|
||||
}\
|
||||
void className::pack##name##Asset(BitStream *stream)\
|
||||
{\
|
||||
if (stream->writeFlag(m##name##Asset.notNull()))\
|
||||
stream->writeString(m##name##Asset.getAssetId());\
|
||||
else\
|
||||
stream->writeString(m##name##Name);\
|
||||
}\
|
||||
void className::unpack##name##Asset(BitStream *stream)\
|
||||
{\
|
||||
if (stream->readFlag())\
|
||||
{\
|
||||
m##name##AssetId = stream->readSTString();\
|
||||
ShapeAsset::getAssetById(m##name##AssetId, &m##name##Asset);\
|
||||
m##name##Name = m##name##Asset->getShapeFilename(); \
|
||||
}\
|
||||
else\
|
||||
m##name##Name = stream->readSTString();\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ bool RigidShapeData::preload(bool server, String &errorStr)
|
|||
if (!collisionDetails.size() || collisionDetails[0] == -1)
|
||||
{
|
||||
Con::errorf("RigidShapeData::preload failed: Rigid shapes must define a collision-1 detail");
|
||||
errorStr = String::ToString("RigidShapeData: Couldn't load shape \"%s\"",shapeName);
|
||||
errorStr = String::ToString("RigidShapeData: Couldn't load shape \"%s\"", mShapeName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,9 +157,6 @@ ShapeBaseData::ShapeBaseData()
|
|||
shadowMaxVisibleDistance( 80.0f ),
|
||||
shadowProjectionDistance( 10.0f ),
|
||||
shadowSphereAdjust( 1.0f ),
|
||||
shapeName( StringTable->EmptyString() ),
|
||||
shapeAsset(StringTable->EmptyString()),
|
||||
shapeAssetId(StringTable->EmptyString()),
|
||||
cloakTexName( StringTable->EmptyString() ),
|
||||
cubeDescId( 0 ),
|
||||
reflectorDesc( NULL ),
|
||||
|
|
@ -199,7 +196,8 @@ ShapeBaseData::ShapeBaseData()
|
|||
isInvincible( false ),
|
||||
renderWhenDestroyed( true ),
|
||||
inheritEnergyFromMount( false )
|
||||
{
|
||||
{
|
||||
initShapeAsset(Shape);
|
||||
dMemset( mountPointNode, -1, sizeof( S32 ) * SceneObject::NumMountPoints );
|
||||
remap_txr_tags = NULL;
|
||||
remap_buffer = NULL;
|
||||
|
|
@ -213,10 +211,8 @@ ShapeBaseData::ShapeBaseData(const ShapeBaseData& other, bool temp_clone) : Game
|
|||
shadowMaxVisibleDistance = other.shadowMaxVisibleDistance;
|
||||
shadowProjectionDistance = other.shadowProjectionDistance;
|
||||
shadowSphereAdjust = other.shadowSphereAdjust;
|
||||
shapeName = other.shapeName;
|
||||
shapeAsset = other.shapeAsset;
|
||||
shapeAssetId = other.shapeAssetId;
|
||||
cloakTexName = other.cloakTexName;
|
||||
cloneShapeAsset(Shape);
|
||||
cubeDescName = other.cubeDescName;
|
||||
cubeDescId = other.cubeDescId;
|
||||
reflectorDesc = other.reflectorDesc;
|
||||
|
|
@ -361,26 +357,26 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
|
|||
}
|
||||
|
||||
//Legacy catch
|
||||
if (shapeName != StringTable->EmptyString())
|
||||
if (mShapeName != StringTable->EmptyString())
|
||||
{
|
||||
shapeAssetId = ShapeAsset::getAssetIdByFilename(shapeName);
|
||||
mShapeAssetId = ShapeAsset::getAssetIdByFilename(mShapeName);
|
||||
}
|
||||
U32 assetState = ShapeAsset::getAssetById(shapeAssetId, &shapeAsset);
|
||||
U32 assetState = ShapeAsset::getAssetById(mShapeAssetId, &mShapeAsset);
|
||||
if (ShapeAsset::Failed != assetState)
|
||||
{
|
||||
//only clear the legacy direct file reference if everything checks out fully
|
||||
if (assetState == ShapeAsset::Ok)
|
||||
{
|
||||
shapeName = StringTable->EmptyString();
|
||||
mShapeName = StringTable->EmptyString();
|
||||
}
|
||||
else Con::warnf("Warning: ShapeBaseData::preload-%s", ShapeAsset::getAssetErrstrn(assetState).c_str());
|
||||
S32 i;
|
||||
|
||||
// Resolve shapename
|
||||
mShape = shapeAsset->getShapeResource();
|
||||
mShape = mShapeAsset->getShapeResource();
|
||||
if (bool(mShape) == false)
|
||||
{
|
||||
errorStr = String::ToString("ShapeBaseData: Couldn't load shape \"%s\"",shapeName);
|
||||
errorStr = String::ToString("ShapeBaseData: Couldn't load shape \"%s\"",mShapeName);
|
||||
return false;
|
||||
}
|
||||
if(!server && !mShape->preloadMaterialList(mShape.getPath()) && NetConnection::filesWereDownloaded())
|
||||
|
|
@ -388,13 +384,13 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
|
|||
|
||||
if(computeCRC)
|
||||
{
|
||||
Con::printf("Validation required for shape: %s", shapeName);
|
||||
Con::printf("Validation required for shape: %s", mShapeName);
|
||||
|
||||
Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode(mShape.getPath());
|
||||
|
||||
if (!fileRef)
|
||||
{
|
||||
errorStr = String::ToString("ShapeBaseData: Couldn't load shape \"%s\"",shapeName);
|
||||
errorStr = String::ToString("ShapeBaseData: Couldn't load shape \"%s\"", mShapeName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -402,7 +398,7 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
|
|||
mCRC = fileRef->getChecksum();
|
||||
else if(mCRC != fileRef->getChecksum())
|
||||
{
|
||||
errorStr = String::ToString("Shape \"%s\" does not match version on server.",shapeName);
|
||||
errorStr = String::ToString("Shape \"%s\" does not match version on server.", mShapeName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -424,13 +420,13 @@ bool ShapeBaseData::preload(bool server, String &errorStr)
|
|||
if (!mShape->mBounds.isContained(collisionBounds.last()))
|
||||
{
|
||||
if (!silent_bbox_check)
|
||||
Con::warnf("Warning: shape %s collision detail %d (Collision-%d) bounds exceed that of shape.", shapeName, collisionDetails.size() - 1, collisionDetails.last());
|
||||
Con::warnf("Warning: shape %s collision detail %d (Collision-%d) bounds exceed that of shape.", mShapeName, collisionDetails.size() - 1, collisionDetails.last());
|
||||
collisionBounds.last() = mShape->mBounds;
|
||||
}
|
||||
else if (collisionBounds.last().isValidBox() == false)
|
||||
{
|
||||
if (!silent_bbox_check)
|
||||
Con::errorf("Error: shape %s-collision detail %d (Collision-%d) bounds box invalid!", shapeName, collisionDetails.size() - 1, collisionDetails.last());
|
||||
Con::errorf("Error: shape %s-collision detail %d (Collision-%d) bounds box invalid!", mShapeName, collisionDetails.size() - 1, collisionDetails.last());
|
||||
collisionBounds.last() = mShape->mBounds;
|
||||
}
|
||||
|
||||
|
|
@ -590,10 +586,10 @@ void ShapeBaseData::initPersistFields()
|
|||
|
||||
addGroup( "Render" );
|
||||
|
||||
addField("shapeAsset", TypeShapeAssetId, Offset(shapeAssetId, ShapeBaseData),
|
||||
addField("shapeAsset", TypeShapeAssetId, Offset(mShapeAssetId, ShapeBaseData),
|
||||
"The source shape asset.");
|
||||
|
||||
addField( "shapeFile", TypeShapeFilename, Offset(shapeName, ShapeBaseData),
|
||||
addField( "shapeFile", TypeShapeFilename, Offset(mShapeName, ShapeBaseData),
|
||||
"The DTS or DAE model to use for this object." );
|
||||
|
||||
endGroup( "Render" );
|
||||
|
|
@ -798,14 +794,7 @@ void ShapeBaseData::packData(BitStream* stream)
|
|||
stream->write(shadowSphereAdjust);
|
||||
|
||||
|
||||
if (stream->writeFlag(shapeAsset.notNull()))
|
||||
{
|
||||
stream->writeString(shapeAsset.getAssetId());
|
||||
}
|
||||
else
|
||||
{
|
||||
stream->writeString(shapeName);
|
||||
}
|
||||
packShapeAsset(stream);
|
||||
|
||||
stream->writeString(cloakTexName);
|
||||
if(stream->writeFlag(mass != gShapeBaseDataProto.mass))
|
||||
|
|
@ -884,16 +873,7 @@ void ShapeBaseData::unpackData(BitStream* stream)
|
|||
stream->read(&shadowSphereAdjust);
|
||||
|
||||
|
||||
if (stream->readFlag())
|
||||
{
|
||||
shapeAssetId = stream->readSTString();
|
||||
ShapeAsset::getAssetById(shapeAssetId, &shapeAsset);
|
||||
shapeName = shapeAsset->getShapeFilename();
|
||||
}
|
||||
else
|
||||
{
|
||||
shapeName = stream->readSTString();
|
||||
}
|
||||
unpackShapeAsset(stream);
|
||||
|
||||
cloakTexName = stream->readSTString();
|
||||
if(stream->readFlag())
|
||||
|
|
|
|||
|
|
@ -538,11 +538,7 @@ public:
|
|||
F32 shadowProjectionDistance;
|
||||
F32 shadowSphereAdjust;
|
||||
|
||||
|
||||
StringTableEntry shapeName;
|
||||
|
||||
AssetPtr<ShapeAsset> shapeAsset;
|
||||
StringTableEntry shapeAssetId;
|
||||
DECLARE_SHAPEASSET(ShapeBaseData, Shape);
|
||||
|
||||
StringTableEntry cloakTexName;
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ bool VehicleData::preload(bool server, String &errorStr)
|
|||
if (!collisionDetails.size() || collisionDetails[0] == -1)
|
||||
{
|
||||
Con::errorf("VehicleData::preload failed: Vehicle models must define a collision-1 detail");
|
||||
errorStr = String::ToString("VehicleData: Couldn't load shape \"%s\"",shapeName);
|
||||
errorStr = String::ToString("VehicleData: Couldn't load shape \"%s\"", mShapeName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public:
|
|||
virtual U32 packUpdate(NetConnection*, U32, BitStream*);
|
||||
virtual void unpackUpdate(NetConnection*, BitStream*);
|
||||
|
||||
const char* getShapeFileName() const { return mDataBlock->shapeName; }
|
||||
const char* getShapeFileName() const { return mDataBlock->mShapeName; }
|
||||
void setVisibility(bool flag) { mIs_visible = flag; }
|
||||
|
||||
DECLARE_CONOBJECT(afxStaticShape);
|
||||
|
|
|
|||
Loading…
Reference in a new issue