mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 04:50:31 +00:00
Added ImageAsset type mode for cubemaps.
Added new inspector type TypeShapeAssetId which is processed as a assetId string instead of an AssetPtr. Added utility function to ShapeAsset to getAssetIdByFilename, which lets you find - if any exist - the asset that utilizes a given loose file. If it doesn't find one, it can attempt to run an auto-import if the editor settings allow, then proceed. Fixed callback of the shapeAsset inspector fields so the Open in Shape Editor correctly binds the asset's shape to the editor for modification. Added function to open a shapeAssetId in the shape editor to facilitate the above. Added additional check to findShapeConstructor to look up the full path of the shape in the cases where a full path is provided instead of a local path. This prevents the shapeConstructor from not finding shapes that absolutely exist. Added beginnings of Datablock representation in Asset Browser. Fixed a few minor issues with asset auto import causing false positive errors, preventing Import or erroneous logging. Fixed issue where editing of asset import configs didn't save. Fixed logic of materials in asset browser so they will open in the material editor as expected. Re-enabled AutoImport of assets editor setting by default.
This commit is contained in:
parent
72b489fe25
commit
157b114ec7
15 changed files with 1057 additions and 686 deletions
|
|
@ -97,6 +97,7 @@ ImplementEnumType(ImageAssetType,
|
|||
{ ImageAsset::Glow, "Glow", "" },
|
||||
{ ImageAsset::Particle, "Particle", "" },
|
||||
{ ImageAsset::Decal, "Decal", "" },
|
||||
{ ImageAsset::Cubemap, "Cubemap", "" },
|
||||
|
||||
EndImplementEnumType;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ public:
|
|||
Glow = 7,
|
||||
Particle = 8,
|
||||
Decal = 9,
|
||||
Cubemap = 10,
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ IMPLEMENT_CONOBJECT(ShapeAsset);
|
|||
|
||||
ConsoleType(assetIdString, TypeShapeAssetPtr, String, ASSET_ID_FIELD_PREFIX)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleGetType(TypeShapeAssetPtr)
|
||||
{
|
||||
// Fetch asset Id.
|
||||
|
|
@ -60,9 +58,38 @@ ConsoleGetType(TypeShapeAssetPtr)
|
|||
return (*((AssetPtr<ShapeAsset>*)dptr)).getAssetId();
|
||||
}
|
||||
|
||||
ConsoleSetType(TypeShapeAssetPtr)
|
||||
{
|
||||
// Was a single argument specified?
|
||||
if (argc == 1)
|
||||
{
|
||||
// Yes, so fetch field value.
|
||||
const char* pFieldValue = argv[0];
|
||||
|
||||
// Fetch asset Id.
|
||||
StringTableEntry* assetId = (StringTableEntry*)(dptr);
|
||||
|
||||
// Update asset value.
|
||||
*assetId = StringTable->insert(pFieldValue);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Warn.
|
||||
Con::warnf("(TypeAssetId) - Cannot set multiple args to a single asset.");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ConsoleSetType(TypeShapeAssetPtr)
|
||||
ConsoleType(assetIdString, TypeShapeAssetId, String, ASSET_ID_FIELD_PREFIX)
|
||||
|
||||
ConsoleGetType(TypeShapeAssetId)
|
||||
{
|
||||
// Fetch asset Id.
|
||||
return *((const char**)(dptr));
|
||||
}
|
||||
|
||||
ConsoleSetType(TypeShapeAssetId)
|
||||
{
|
||||
// Was a single argument specified?
|
||||
if (argc == 1)
|
||||
|
|
@ -334,14 +361,55 @@ bool ShapeAsset::getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAss
|
|||
}
|
||||
}
|
||||
|
||||
StringTableEntry ShapeAsset::getAssetIdByFilename(StringTableEntry fileName)
|
||||
{
|
||||
StringTableEntry shapeAssetId = StringTable->EmptyString();
|
||||
|
||||
AssetQuery query;
|
||||
S32 foundAssetcount = AssetDatabase.findAssetLooseFile(&query, fileName);
|
||||
if (foundAssetcount == 0)
|
||||
{
|
||||
//Didn't find any assets
|
||||
//If possible, see if we can run an in-place import and the get the asset from that
|
||||
#if TORQUE_DEBUG
|
||||
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())
|
||||
{
|
||||
StringTableEntry resultingAssetId = StringTable->insert(Con::getVariable("$importedLooseFileAsset"));
|
||||
|
||||
if (resultingAssetId != StringTable->EmptyString())
|
||||
{
|
||||
shapeAssetId = resultingAssetId;
|
||||
return shapeAssetId;
|
||||
}
|
||||
}
|
||||
|
||||
//Didn't work, so have us fall back to a placeholder asset
|
||||
shapeAssetId = StringTable->insert("Core_Rendering:noshape");
|
||||
}
|
||||
else
|
||||
{
|
||||
//acquire and bind the asset, and return it out
|
||||
shapeAssetId = query.mAssetList[0];
|
||||
}
|
||||
|
||||
return shapeAssetId;
|
||||
}
|
||||
|
||||
bool ShapeAsset::getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset)
|
||||
{
|
||||
shapeAsset->setAssetId(assetId);
|
||||
(*shapeAsset) = assetId;
|
||||
|
||||
if (!shapeAsset->isNull())
|
||||
return true;
|
||||
|
||||
//Didn't work, so have us fall back to a placeholder asset
|
||||
shapeAsset->setAssetId(StringTable->insert("Core_Rendering:noshape"));
|
||||
StringTableEntry noShapeId = StringTable->insert("Core_Rendering:noshape");
|
||||
shapeAsset->setAssetId(noShapeId);
|
||||
|
||||
if (!shapeAsset->isNull())
|
||||
return true;
|
||||
|
|
@ -460,7 +528,7 @@ GuiControl* GuiInspectorTypeShapeAssetPtr::constructEditControl()
|
|||
// Create "Open in ShapeEditor" button
|
||||
mShapeEdButton = new GuiBitmapButtonCtrl();
|
||||
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "ShapeEditorPlugin.openShapeAsset(%d.getText());", retCtrl->getId());
|
||||
dSprintf(szBuffer, sizeof(szBuffer), "ShapeEditorPlugin.openShapeAssetId(%d.getText());", retCtrl->getId());
|
||||
mShapeEdButton->setField("Command", szBuffer);
|
||||
|
||||
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
|
||||
|
|
@ -502,3 +570,18 @@ bool GuiInspectorTypeShapeAssetPtr::updateRects()
|
|||
|
||||
return resized;
|
||||
}
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiInspectorTypeShapeAssetId);
|
||||
|
||||
ConsoleDocClass(GuiInspectorTypeShapeAssetId,
|
||||
"@brief Inspector field type for Shapes\n\n"
|
||||
"Editor use only.\n\n"
|
||||
"@internal"
|
||||
);
|
||||
|
||||
void GuiInspectorTypeShapeAssetId::consoleInit()
|
||||
{
|
||||
Parent::consoleInit();
|
||||
|
||||
ConsoleBaseType::getType(TypeShapeAssetId)->setInspectorFieldType("GuiInspectorTypeShapeAssetId");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,8 +129,11 @@ public:
|
|||
inline StringTableEntry getShapeConstructorFile(void) const { return mConstructorFileName; };
|
||||
|
||||
static bool getAssetByFilename(StringTableEntry fileName, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
static StringTableEntry getAssetIdByFilename(StringTableEntry fileName);
|
||||
static bool getAssetById(StringTableEntry assetId, AssetPtr<ShapeAsset>* shapeAsset);
|
||||
|
||||
static StringTableEntry getNoShapeAssetId() { return StringTable->insert("Core_Rendering:noshape"); }
|
||||
|
||||
protected:
|
||||
virtual void onAssetRefresh(void);
|
||||
|
||||
|
|
@ -143,6 +146,7 @@ protected:
|
|||
};
|
||||
|
||||
DefineConsoleType(TypeShapeAssetPtr, S32)
|
||||
DefineConsoleType(TypeShapeAssetId, String)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// TypeAssetId GuiInspectorField Class
|
||||
|
|
@ -161,5 +165,14 @@ public:
|
|||
virtual bool updateRects();
|
||||
};
|
||||
|
||||
class GuiInspectorTypeShapeAssetId : public GuiInspectorTypeShapeAssetPtr
|
||||
{
|
||||
typedef GuiInspectorTypeShapeAssetPtr Parent;
|
||||
public:
|
||||
|
||||
DECLARE_CONOBJECT(GuiInspectorTypeShapeAssetId);
|
||||
static void consoleInit();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -38,11 +38,16 @@
|
|||
#include "core/resource.h"
|
||||
#endif
|
||||
#ifndef _NETSTRINGTABLE_H_
|
||||
#include "sim/netStringTable.h"
|
||||
#include "sim/netStringTable.h"
|
||||
#endif
|
||||
#ifndef _TSSHAPE_H_
|
||||
#include "ts/tsShape.h"
|
||||
#endif
|
||||
|
||||
#ifndef _REFLECTOR_H_
|
||||
#include "scene/reflector.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ASSET_PTR_H_
|
||||
#include "assets/assetPtr.h"
|
||||
#endif
|
||||
|
|
@ -71,7 +76,7 @@ public:
|
|||
Point3F verts[4];
|
||||
PlaneF normal;
|
||||
S32 idx;
|
||||
TSMesh *mesh;
|
||||
TSMesh* mesh;
|
||||
|
||||
static SceneObject* smCurObject;
|
||||
|
||||
|
|
@ -81,7 +86,7 @@ public:
|
|||
Box3F getBoundingBox() const;
|
||||
Box3F getBoundingBox(const MatrixF& mat, const Point3F& scale) const;
|
||||
|
||||
void getFeatures(const MatrixF& mat,const VectorF& n, ConvexFeature* cf);
|
||||
void getFeatures(const MatrixF& mat, const VectorF& n, ConvexFeature* cf);
|
||||
|
||||
// This returns a list of convex faces to collide against
|
||||
void getPolyList(AbstractPolyList* list);
|
||||
|
|
@ -98,25 +103,25 @@ class TSStatic : public SceneObject
|
|||
|
||||
static U32 smUniqueIdentifier;
|
||||
|
||||
enum MaskBits
|
||||
enum MaskBits
|
||||
{
|
||||
TransformMask = Parent::NextFreeMask << 0,
|
||||
AdvancedStaticOptionsMask = Parent::NextFreeMask << 1,
|
||||
UpdateCollisionMask = Parent::NextFreeMask << 2,
|
||||
SkinMask = Parent::NextFreeMask << 3,
|
||||
MaterialMask = Parent::NextFreeMask << 4,
|
||||
NextFreeMask = Parent::NextFreeMask << 5
|
||||
TransformMask = Parent::NextFreeMask << 0,
|
||||
AdvancedStaticOptionsMask = Parent::NextFreeMask << 1,
|
||||
UpdateCollisionMask = Parent::NextFreeMask << 2,
|
||||
SkinMask = Parent::NextFreeMask << 3,
|
||||
MaterialMask = Parent::NextFreeMask << 4,
|
||||
NextFreeMask = Parent::NextFreeMask << 5
|
||||
};
|
||||
|
||||
public:
|
||||
void setAlphaFade(bool enable, F32 start, F32 end, bool inverse)
|
||||
{
|
||||
mUseAlphaFade = enable;
|
||||
mAlphaFadeStart = start;
|
||||
mAlphaFadeEnd = end;
|
||||
mInvertAlphaFade = inverse;
|
||||
mUseAlphaFade = enable;
|
||||
mAlphaFadeStart = start;
|
||||
mAlphaFadeEnd = end;
|
||||
mInvertAlphaFade = inverse;
|
||||
}
|
||||
|
||||
|
||||
/// The different types of mesh data types
|
||||
enum MeshType
|
||||
{
|
||||
|
|
@ -125,7 +130,7 @@ public:
|
|||
CollisionMesh = 2, ///< Specifically designated collision meshes
|
||||
VisibleMesh = 3 ///< Rendered mesh polygons
|
||||
};
|
||||
|
||||
|
||||
protected:
|
||||
bool mUseAlphaFade;
|
||||
F32 mAlphaFadeStart;
|
||||
|
|
@ -148,41 +153,47 @@ protected:
|
|||
|
||||
// Collision
|
||||
void prepCollision();
|
||||
bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
|
||||
bool castRayRendered(const Point3F &start, const Point3F &end, RayInfo* info);
|
||||
bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere);
|
||||
bool buildExportPolyList(ColladaUtils::ExportData* exportData, const Box3F &box, const SphereF &);
|
||||
bool castRay(const Point3F& start, const Point3F& end, RayInfo* info);
|
||||
bool castRayRendered(const Point3F& start, const Point3F& end, RayInfo* info);
|
||||
bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere);
|
||||
bool buildExportPolyList(ColladaUtils::ExportData* exportData, const Box3F& box, const SphereF&);
|
||||
void buildConvex(const Box3F& box, Convex* convex);
|
||||
|
||||
bool setShapeAsset(const StringTableEntry shapeAssetId);
|
||||
|
||||
bool _createShape();
|
||||
|
||||
|
||||
void _updatePhysics();
|
||||
|
||||
void _renderNormals( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
|
||||
void _renderNormals(ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat);
|
||||
|
||||
void _onResourceChanged( const Torque::Path &path );
|
||||
void _onResourceChanged(const Torque::Path& path);
|
||||
|
||||
// ProcessObject
|
||||
virtual void processTick( const Move *move );
|
||||
virtual void interpolateTick( F32 delta );
|
||||
virtual void advanceTime( F32 dt );
|
||||
virtual void processTick(const Move* move);
|
||||
virtual void interpolateTick(F32 delta);
|
||||
virtual void advanceTime(F32 dt);
|
||||
|
||||
virtual void onDynamicModified(const char* slotName, const char* newValue);
|
||||
|
||||
/// Start or stop processing ticks depending on our state.
|
||||
void _updateShouldTick();
|
||||
|
||||
String cubeDescName;
|
||||
U32 cubeDescId;
|
||||
ReflectorDesc* reflectorDesc;
|
||||
CubeReflector mCubeReflector;
|
||||
|
||||
protected:
|
||||
|
||||
Convex *mConvexList;
|
||||
Convex* mConvexList;
|
||||
|
||||
StringTableEntry mShapeName;
|
||||
U32 mShapeHash;
|
||||
Resource<TSShape> mShape;
|
||||
Vector<S32> mCollisionDetails;
|
||||
Vector<S32> mLOSDetails;
|
||||
TSShapeInstance *mShapeInstance;
|
||||
TSShapeInstance* mShapeInstance;
|
||||
|
||||
AssetPtr<ShapeAsset> mShapeAsset;
|
||||
StringTableEntry mShapeAssetId;
|
||||
|
|
@ -191,7 +202,7 @@ protected:
|
|||
String mAppliedSkinName;
|
||||
|
||||
bool mPlayAmbient;
|
||||
TSThread* mAmbientThread;
|
||||
TSThread* mAmbientThread;
|
||||
|
||||
/// The type of mesh data to return for collision queries.
|
||||
MeshType mCollisionType;
|
||||
|
|
@ -209,7 +220,7 @@ protected:
|
|||
/// model instead of the nearest point of the bounds.
|
||||
bool mUseOriginSort;
|
||||
|
||||
PhysicsBody *mPhysicsRep;
|
||||
PhysicsBody* mPhysicsRep;
|
||||
|
||||
LinearColorF mOverrideColor;
|
||||
|
||||
|
|
@ -224,36 +235,36 @@ public:
|
|||
|
||||
DECLARE_CONOBJECT(TSStatic);
|
||||
static void initPersistFields();
|
||||
static bool _setShape(void* obj, const char* index, const char* data);
|
||||
static bool _setShapeAsset(void* obj, const char* index, const char* data);
|
||||
static bool _setFieldSkin( void *object, const char* index, const char* data );
|
||||
static const char *_getFieldSkin( void *object, const char *data );
|
||||
static bool _setShapeName(void* obj, const char* index, const char* data);
|
||||
static bool _setFieldSkin(void* object, const char* index, const char* data);
|
||||
static const char* _getFieldSkin(void* object, const char* data);
|
||||
|
||||
// Skinning
|
||||
void setSkinName( const char *name );
|
||||
void setSkinName(const char* name);
|
||||
void reSkin();
|
||||
|
||||
// NetObject
|
||||
U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
|
||||
void unpackUpdate( NetConnection *conn, BitStream *stream );
|
||||
U32 packUpdate(NetConnection* conn, U32 mask, BitStream* stream);
|
||||
void unpackUpdate(NetConnection* conn, BitStream* stream);
|
||||
|
||||
// SceneObject
|
||||
void setTransform( const MatrixF &mat );
|
||||
void setTransform(const MatrixF& mat);
|
||||
void onScaleChanged();
|
||||
void prepRenderImage( SceneRenderState *state );
|
||||
void prepRenderImage(SceneRenderState* state);
|
||||
void inspectPostApply();
|
||||
virtual void onMount( SceneObject *obj, S32 node );
|
||||
virtual void onUnmount( SceneObject *obj, S32 node );
|
||||
virtual void onMount(SceneObject* obj, S32 node);
|
||||
virtual void onUnmount(SceneObject* obj, S32 node);
|
||||
|
||||
/// The type of mesh data use for collision queries.
|
||||
MeshType getCollisionType() const { return mCollisionType; }
|
||||
|
||||
bool allowPlayerStep() const { return mAllowPlayerStep; }
|
||||
|
||||
Resource<TSShape> getShape() const;
|
||||
StringTableEntry getShapeFileName() { return mShapeName; }
|
||||
Resource<TSShape> getShape() const { return mShape; }
|
||||
StringTableEntry getShapeFileName() { return mShapeName; }
|
||||
void setShapeFileName(StringTableEntry shapeName) { mShapeName = shapeName; }
|
||||
|
||||
|
||||
TSShapeInstance* getShapeInstance() const { return mShapeInstance; }
|
||||
|
||||
U32 getNumDetails();
|
||||
|
|
@ -267,10 +278,10 @@ public:
|
|||
void updateMaterials();
|
||||
|
||||
private:
|
||||
virtual void onStaticModified(const char* slotName, const char*newValue = NULL);
|
||||
virtual void onStaticModified(const char* slotName, const char* newValue = NULL);
|
||||
protected:
|
||||
Vector<S32> mDecalDetails;
|
||||
Vector<S32>* mDecalDetailsPtr;
|
||||
Vector<S32>* mDecalDetailsPtr;
|
||||
public:
|
||||
bool mIgnoreZodiacs;
|
||||
bool mHasGradients;
|
||||
|
|
@ -283,7 +294,7 @@ private:
|
|||
};
|
||||
|
||||
typedef TSStatic::MeshType TSMeshType;
|
||||
DefineEnumType( TSMeshType );
|
||||
DefineEnumType(TSMeshType);
|
||||
|
||||
#endif // _H_TSSTATIC
|
||||
|
||||
|
|
|
|||
|
|
@ -390,7 +390,11 @@ TSShapeConstructor* TSShapeConstructor::findShapeConstructor(const FileName& pat
|
|||
for (S32 i = 0; i < group->size(); i++)
|
||||
{
|
||||
TSShapeConstructor* tss = dynamic_cast<TSShapeConstructor*>( group->at(i) );
|
||||
if ( tss->mShapePath.equal( path, String::NoCase ) )
|
||||
FileName shapePath = tss->mShapePath;
|
||||
|
||||
char buf[1024];
|
||||
FileName fullShapePath = Platform::makeFullPathName(shapePath, buf, sizeof(buf));
|
||||
if (shapePath.equal( path, String::NoCase ) || fullShapePath.equal(path, String::NoCase))
|
||||
return tss;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue