mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Shift tracking of dynamicObjects from strict child objects for Scenes, to tracking the objects but keeping them in the Cleanup Group to fix prefab loading behavior
Shifted to utilizing SimGroupInterator and persistenceManager to fix saving issues with SubScenes Shifted to utilizing SimGroupIterator for Scene saving to standardize and minimize object misses Changed prefab load file logic to add loaded child simgroup to rootscene for consistent tracking and avoiding conflicts with subScene's hijacking the ImmediateGroup var Reduced duplication of build<type>field callback for inspectors Added more standard field type lookups to inspector group when creating a field to avoid misses for types like 'F32' or similar. Folded the added-on MinSize/MaxSize/SimgroupSelect fields for SimGroup editing into a single compound field and fixed bugs with it's behavior so it works as expected now
This commit is contained in:
parent
484ece3d28
commit
10d1aeca1f
9 changed files with 221 additions and 128 deletions
|
|
@ -148,20 +148,32 @@ void Scene::removeObject(SimObject* object)
|
|||
Parent::removeObject(object);
|
||||
}
|
||||
|
||||
void Scene::addDynamicObject(SceneObject* object)
|
||||
void Scene::addDynamicObject(SimObject* object)
|
||||
{
|
||||
mDynamicObjects.push_back(object);
|
||||
|
||||
SimGroup* cleanupGroup;
|
||||
if(Sim::findObject("MissionCleanup", cleanupGroup))
|
||||
{
|
||||
cleanupGroup->addObject(object);
|
||||
}
|
||||
|
||||
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
|
||||
Parent::addObject(object);
|
||||
//Parent::addObject(object);
|
||||
}
|
||||
|
||||
void Scene::removeDynamicObject(SceneObject* object)
|
||||
void Scene::removeDynamicObject(SimObject* object)
|
||||
{
|
||||
mDynamicObjects.remove(object);
|
||||
|
||||
SimGroup* cleanupGroup;
|
||||
if (Sim::findObject("MissionCleanup", cleanupGroup))
|
||||
{
|
||||
cleanupGroup->removeObject(object);
|
||||
}
|
||||
|
||||
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
|
||||
Parent::removeObject(object);
|
||||
//Parent::removeObject(object);
|
||||
}
|
||||
|
||||
void Scene::interpolateTick(F32 delta)
|
||||
|
|
@ -242,7 +254,7 @@ void Scene::dumpUtilizedAssets()
|
|||
Con::printf("Dumping utilized assets in scene!");
|
||||
|
||||
Vector<StringTableEntry> utilizedAssetsList;
|
||||
for (U32 i = 0; i < mPermanentObjects.size(); i++)
|
||||
/*for (U32 i = 0; i < mPermanentObjects.size(); i++)
|
||||
{
|
||||
mPermanentObjects[i]->getUtilizedAssets(&utilizedAssetsList);
|
||||
}
|
||||
|
|
@ -250,7 +262,7 @@ void Scene::dumpUtilizedAssets()
|
|||
for (U32 i = 0; i < mDynamicObjects.size(); i++)
|
||||
{
|
||||
mDynamicObjects[i]->getUtilizedAssets(&utilizedAssetsList);
|
||||
}
|
||||
}*/
|
||||
|
||||
for (U32 i = 0; i < utilizedAssetsList.size(); i++)
|
||||
{
|
||||
|
|
@ -294,31 +306,16 @@ bool Scene::saveScene(StringTableEntry fileName)
|
|||
fileName = getOriginatingFile();
|
||||
}
|
||||
|
||||
//Inform our objects we're saving, so if they do any special stuff
|
||||
//they can do it before the actual write-out
|
||||
for (SimGroup::iterator itr = begin(); itr != end(); itr++)
|
||||
for (SimGroupIterator itr(this); *itr; ++itr)
|
||||
{
|
||||
SimGroup* sg = dynamic_cast<SimGroup*>(*itr);
|
||||
if (sg)
|
||||
if((*itr)->isMethod("onSaving"))
|
||||
{
|
||||
ConsoleValue vars[3];
|
||||
vars[2].setString(fileName);
|
||||
sg->callOnChildren("onSaving", 3, vars);
|
||||
}
|
||||
|
||||
SceneObject* sO = dynamic_cast<SceneObject*>(*itr);
|
||||
if (sO)
|
||||
{
|
||||
sO->onSaving_callback(fileName);
|
||||
Con::execute((*itr), 3, vars);
|
||||
}
|
||||
}
|
||||
|
||||
/*for (U32 i = 0; i < mPermanentObjects.size(); i++)
|
||||
{
|
||||
SceneObject* obj = mPermanentObjects[i];
|
||||
obj->onSaving_callback(fileName);
|
||||
}*/
|
||||
|
||||
//Inform our subscenes we're saving so they can do any
|
||||
//special work required as well
|
||||
for (U32 i = 0; i < mSubScenes.size(); i++)
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class Scene : public NetObject, public virtual ITickable
|
|||
|
||||
Vector<SubScene*> mSubScenes;
|
||||
|
||||
Vector<SceneObject*> mPermanentObjects;
|
||||
Vector<SceneObject*> mDynamicObjects;
|
||||
Vector<SimObject*> mPermanentObjects;
|
||||
Vector<SimObject*> mDynamicObjects;
|
||||
|
||||
S32 mSceneId;
|
||||
|
||||
|
|
@ -69,8 +69,8 @@ public:
|
|||
void addObject(SimObject* object) override;
|
||||
void removeObject(SimObject* object) override;
|
||||
|
||||
void addDynamicObject(SceneObject* object);
|
||||
void removeDynamicObject(SceneObject* object);
|
||||
void addDynamicObject(SimObject* object);
|
||||
void removeDynamicObject(SimObject* object);
|
||||
void clearDynamicObjects() { mDynamicObjects.clear(); }
|
||||
|
||||
void dumpUtilizedAssets();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "SubScene.h"
|
||||
|
||||
#include "gameMode.h"
|
||||
#include "console/persistenceManager.h"
|
||||
#include "console/script.h"
|
||||
#include "scene/sceneRenderState.h"
|
||||
#include "renderInstance/renderPassManager.h"
|
||||
|
|
@ -391,34 +392,28 @@ bool SubScene::save()
|
|||
if (mStartUnloadTimerMS != -1)
|
||||
mStartUnloadTimerMS = Sim::getCurrentTime();
|
||||
|
||||
PersistenceManager prMger;
|
||||
|
||||
StringTableEntry levelPath = mLevelAsset->getLevelPath();
|
||||
|
||||
for (SimGroup::iterator itr = begin(); itr != end(); itr++)
|
||||
FileStream fs;
|
||||
fs.open(levelPath, Torque::FS::File::Write);
|
||||
fs.close();
|
||||
|
||||
for (SimGroupIterator itr(this); *itr; ++itr)
|
||||
{
|
||||
//Inform our objects we're saving, so if they do any special stuff
|
||||
//they can do it before the actual write-out
|
||||
SimGroup* sg = dynamic_cast<SimGroup*>(*itr);
|
||||
if (sg)
|
||||
if ((*itr)->isMethod("onSaving"))
|
||||
{
|
||||
ConsoleValue vars[3];
|
||||
vars[2].setString(mLevelAssetId);
|
||||
sg->callOnChildren("onSaving", 3, vars);
|
||||
Con::execute((*itr), 3, vars);
|
||||
}
|
||||
|
||||
SceneObject* scO = dynamic_cast<SceneObject*>(*itr);
|
||||
if (scO)
|
||||
{
|
||||
scO->onSaving_callback(mLevelAssetId);
|
||||
}
|
||||
|
||||
SimObject* sO = static_cast<SimObject*>(*itr);
|
||||
if (!sO->save(levelPath))
|
||||
{
|
||||
Con::errorf("SubScene::save() - error, failed to write object %s to file: %s", sO->getIdString(), levelPath);
|
||||
return false;
|
||||
}
|
||||
prMger.setDirty((*itr), levelPath);
|
||||
}
|
||||
|
||||
prMger.saveDirty();
|
||||
|
||||
//process our gameModeList and write it out to the levelAsset for metadata stashing
|
||||
bool saveSuccess = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -371,6 +371,12 @@ void Prefab::_loadFile( bool addFileNotify )
|
|||
return;
|
||||
}
|
||||
|
||||
SimObjectPtr<Scene> rootScene = Scene::getRootScene();
|
||||
if(rootScene.isValid())
|
||||
{
|
||||
rootScene->addDynamicObject(group);
|
||||
}
|
||||
|
||||
if ( addFileNotify )
|
||||
Torque::FS::AddChangeNotification( mFilename, this, &Prefab::_onFileChanged );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue