Torque3D/Engine/source/T3D/prefab.h
Areloch adec6e7c74 Adds load status to MaterialAsset for if the Script file itself has been loaded, but the material itself hasn't yet been processed.
Fixed String -> StringTableEntry conversion in prefab file to correct corruption when setting the filename
Cleaned up message spam from the MaterialSlot fields on TSStatics
Added getter/setters for terrain file and assets
Removed unneeded exec of tools profiles for MainMenuGUI
Add logic to remove creators section of AB if in select mode
Fixed misc. messageBox invokes that were erroneously converted to 'toolsMessageBox'
Fix classname for NotesObject in AB Creator Entry
Fix issue where ConvexShapeEditor toolbar would hide after being seen once
Changed keybind for quick AB access from 'space' to 'shift space' to avoid input issues when typing in fields in some cases
Fixed default image assignments for River objects on foam/ripple/depth
Added handling for Material, Sound and Shape asset fields in Object Builder, and updated various objectBuilder class entries to utilize them now.
Updated various fields' defaults for ObjectBuilder to utilize correct assetId's
Fixed editor SceneTree tooltips for TSShape and GroundCovert to correctly reference assets as needed
Added logic to properly check terrain asset validity when prompting to save changes, which would break saving actions before
Added menubar items in the Object category to take control and release control of control objects quickly for testing
2021-09-19 01:01:47 -05:00

172 lines
4.9 KiB
C++

//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _PREFAB_H_
#define _PREFAB_H_
#ifndef _SCENEOBJECT_H_
#include "scene/sceneObject.h"
#endif
#ifndef _PATH_H_
#include "core/util/path.h"
#endif
#ifndef _UNDO_H_
#include "util/undo.h"
#endif
#ifndef _TDICTIONARY_H_
#include "core/util/tDictionary.h"
#endif
class BaseMatInstance;
class Prefab : public SceneObject
{
typedef SceneObject Parent;
enum MaskBits
{
TransformMask = Parent::NextFreeMask << 0,
FileMask = Parent::NextFreeMask << 1,
NextFreeMask = Parent::NextFreeMask << 2
};
public:
Prefab();
virtual ~Prefab();
DECLARE_CONOBJECT(Prefab);
static void initPersistFields();
// SimObject
virtual bool onAdd();
virtual void onRemove();
virtual void onEditorEnable();
virtual void onEditorDisable();
virtual void inspectPostApply();
// NetObject
U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
void unpackUpdate( NetConnection *conn, BitStream *stream );
// SceneObject
virtual void setTransform( const MatrixF &mat );
virtual void setScale(const VectorF & scale);
// Prefab
/// If the passed object is a child of any Prefab return that Prefab.
/// Note that this call is only valid if the editor is open and when
/// passed server-side objects.
static Prefab* getPrefabByChild( SimObject *child );
/// Returns false if the passed object is of a type that is not allowed
/// as a child within a Prefab.
static bool isValidChild( SimObject *child, bool logWarnings );
///
void render( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
///
void setFile(StringTableEntry file );
/// Removes all children from this Prefab and puts them into a SimGroup
/// which is added to the Scene and returned to the caller.
SimGroup* explode();
bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere);
bool buildExportPolyList(ColladaUtils::ExportData* exportData, const Box3F &box, const SphereF &);
virtual void getUtilizedAssets(Vector<StringTableEntry>* usedAssetsList);
protected:
void _closeFile( bool removeFileNotify );
void _loadFile( bool addFileNotify );
void _updateChildTransform( SceneObject* child );
void _updateChildren();
void _onFileChanged( const Torque::Path &path );
static bool protectedSetFile( void *object, const char *index, const char *data );
/// @name Callbacks
/// @{
DECLARE_CALLBACK( void, onLoad, ( SimGroup *children ) );
/// @}
protected:
/// Prefab file which defines our children objects.
StringTableEntry mFilename;
/// Group which holds all children objects.
SimObjectPtr<SimGroup> mChildGroup;
/// Structure to keep track of child object initial transform and scale
struct Transform
{
MatrixF mat;
VectorF scale;
Transform() : mat(true), scale(Point3F::One) { }
Transform( const MatrixF& m, const VectorF& s ) : mat(m), scale(s) { }
};
typedef Map<SimObjectId,Transform> ChildToMatMap;
/// Lookup from a child object's id to its transform in
/// this Prefab's object space.
ChildToMatMap mChildMap;
typedef Map<SimObjectId,SimObjectId> ChildToPrefabMap;
/// Lookup from a SimObject to its parent Prefab if it has one.
static ChildToPrefabMap smChildToPrefabMap;
};
class ExplodePrefabUndoAction : public UndoAction
{
typedef UndoAction Parent;
friend class WorldEditor;
public:
ExplodePrefabUndoAction( Prefab *prefab );
// UndoAction
virtual void undo();
virtual void redo();
protected:
SimGroup *mGroup;
SimObjectId mPrefabId;
};
#endif // _PREFAB_H_