mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-08 23:10:36 +00:00
Initial implementation of the Scene object for handling scenes/levels in a more consistent and deliberate way.
This commit is contained in:
parent
e0627973fb
commit
1c2f90a190
37 changed files with 509 additions and 140 deletions
|
|
@ -38,6 +38,7 @@
|
|||
#include "scene/sceneRenderState.h"
|
||||
#include "renderInstance/renderBinManager.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(EditTSCtrl);
|
||||
ConsoleDocClass( EditTSCtrl,
|
||||
|
|
@ -795,15 +796,15 @@ void EditTSCtrl::_renderScene( ObjectRenderInst*, SceneRenderState *state, BaseM
|
|||
GFXTransformSaver saver;
|
||||
|
||||
// render through console callbacks
|
||||
SimSet * missionGroup = static_cast<SimSet*>(Sim::findObject("MissionGroup"));
|
||||
if(missionGroup)
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if(scene)
|
||||
{
|
||||
mConsoleRendering = true;
|
||||
|
||||
// [ rene, 27-Jan-10 ] This calls onEditorRender on the server objects instead
|
||||
// of on the client objects which seems a bit questionable to me.
|
||||
|
||||
for(SimSetIterator itr(missionGroup); *itr; ++itr)
|
||||
for(SimSetIterator itr(scene); *itr; ++itr)
|
||||
{
|
||||
SceneObject* object = dynamic_cast< SceneObject* >( *itr );
|
||||
if( object && object->isRenderEnabled() && !object->isHidden() )
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@
|
|||
#include "T3D/portal.h"
|
||||
#include "math/mPolyhedron.impl.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( GuiConvexEditorCtrl );
|
||||
|
||||
ConsoleDocClass( GuiConvexEditorCtrl,
|
||||
|
|
@ -121,12 +123,12 @@ bool GuiConvexEditorCtrl::onWake()
|
|||
if ( !Parent::onWake() )
|
||||
return false;
|
||||
|
||||
SimGroup *missionGroup;
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( !scene )
|
||||
return true;
|
||||
|
||||
SimGroup::iterator itr = missionGroup->begin();
|
||||
for ( ; itr != missionGroup->end(); itr++ )
|
||||
SimGroup::iterator itr = scene->begin();
|
||||
for ( ; itr != scene->end(); itr++ )
|
||||
{
|
||||
if ( dStrcmp( (*itr)->getClassName(), "ConvexShape" ) == 0 )
|
||||
{
|
||||
|
|
@ -166,8 +168,8 @@ void GuiConvexEditorCtrl::setVisible( bool val )
|
|||
mSavedGizmoFlags = -1;
|
||||
}
|
||||
|
||||
SimGroup* misGroup;
|
||||
if (Sim::findObject("MissionGroup", misGroup))
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (scene != nullptr)
|
||||
{
|
||||
//Make our proxy objects "real" again
|
||||
for (U32 i = 0; i < mProxyObjects.size(); ++i)
|
||||
|
|
@ -184,7 +186,7 @@ void GuiConvexEditorCtrl::setVisible( bool val )
|
|||
|
||||
SceneObject* polyObj = createPolyhedralObject(mProxyObjects[i].targetObjectClass.c_str(), mProxyObjects[i].shapeProxy);
|
||||
|
||||
misGroup->addObject(polyObj);
|
||||
scene->addObject(polyObj);
|
||||
|
||||
//Now, remove the convex proxy
|
||||
mProxyObjects[i].shapeProxy->deleteObject();
|
||||
|
|
@ -222,19 +224,19 @@ void GuiConvexEditorCtrl::setVisible( bool val )
|
|||
updateGizmoPos();
|
||||
mSavedGizmoFlags = mGizmoProfile->flags;
|
||||
|
||||
SimGroup* misGroup;
|
||||
if (Sim::findObject("MissionGroup", misGroup))
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (scene != nullptr)
|
||||
{
|
||||
for (U32 c = 0; c < misGroup->size(); ++c)
|
||||
for (U32 c = 0; c < scene->size(); ++c)
|
||||
{
|
||||
bool isTrigger = (misGroup->at(c)->getClassName() == StringTable->insert("Trigger"));
|
||||
bool isZone = (misGroup->at(c)->getClassName() == StringTable->insert("Zone"));
|
||||
bool isPortal = (misGroup->at(c)->getClassName() == StringTable->insert("Portal"));
|
||||
bool isOccluder = (misGroup->at(c)->getClassName() == StringTable->insert("OcclusionVolume"));
|
||||
bool isTrigger = (scene->at(c)->getClassName() == StringTable->insert("Trigger"));
|
||||
bool isZone = (scene->at(c)->getClassName() == StringTable->insert("Zone"));
|
||||
bool isPortal = (scene->at(c)->getClassName() == StringTable->insert("Portal"));
|
||||
bool isOccluder = (scene->at(c)->getClassName() == StringTable->insert("OcclusionVolume"));
|
||||
|
||||
if (isZone || isPortal || isOccluder)
|
||||
{
|
||||
SceneObject* sceneObj = static_cast<SceneObject*>(misGroup->at(c));
|
||||
SceneObject* sceneObj = static_cast<SceneObject*>(scene->at(c));
|
||||
if (!sceneObj)
|
||||
{
|
||||
Con::errorf("WorldEditor::createConvexShapeFrom - Invalid object");
|
||||
|
|
@ -1350,9 +1352,9 @@ void GuiConvexEditorCtrl::setupShape( ConvexShape *shape )
|
|||
shape->registerObject();
|
||||
updateShape( shape );
|
||||
|
||||
SimGroup *group;
|
||||
if ( Sim::findObject( "missionGroup", group ) )
|
||||
group->addObject( shape );
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( scene )
|
||||
scene->addObject( shape );
|
||||
}
|
||||
|
||||
void GuiConvexEditorCtrl::updateShape( ConvexShape *shape, S32 offsetFace )
|
||||
|
|
@ -1929,10 +1931,8 @@ ConvexEditorTool::EventResult ConvexEditorCreateTool::on3DMouseUp( const Gui3DMo
|
|||
}
|
||||
else if ( mStage == 0 )
|
||||
{
|
||||
SimGroup *mg;
|
||||
Sim::findObject( "MissionGroup", mg );
|
||||
|
||||
mg->addObject( mNewConvex );
|
||||
SimGroup *scene = Scene::getRootScene();
|
||||
scene->addObject( mNewConvex );
|
||||
|
||||
mStage = -1;
|
||||
|
||||
|
|
@ -2128,9 +2128,9 @@ ConvexShape* ConvexEditorCreateTool::extrudeShapeFromFace( ConvexShape *inShape,
|
|||
newShape->registerObject();
|
||||
mEditor->updateShape( newShape );
|
||||
|
||||
SimGroup *group;
|
||||
if ( Sim::findObject( "missionGroup", group ) )
|
||||
group->addObject( newShape );
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( scene )
|
||||
scene->addObject( newShape );
|
||||
|
||||
return newShape;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "gui/worldEditor/terrainActions.h"
|
||||
#include "terrain/terrMaterial.h"
|
||||
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(TerrainEditor);
|
||||
|
||||
|
|
@ -2405,10 +2405,10 @@ void TerrainEditor::reorderMaterial( S32 index, S32 orderPos )
|
|||
|
||||
DefineEngineMethod( TerrainEditor, attachTerrain, void, (const char * terrain), (""), "(TerrainBlock terrain)")
|
||||
{
|
||||
SimSet * missionGroup = dynamic_cast<SimSet*>(Sim::findObject("MissionGroup"));
|
||||
if (!missionGroup)
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (!scene)
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: no mission group found");
|
||||
Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: no scene found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2417,7 +2417,7 @@ DefineEngineMethod( TerrainEditor, attachTerrain, void, (const char * terrain),
|
|||
// attach to first found terrainBlock
|
||||
if (dStrcmp (terrain,"")==0)
|
||||
{
|
||||
for(SimSetIterator itr(missionGroup); *itr; ++itr)
|
||||
for(SimSetIterator itr(scene); *itr; ++itr)
|
||||
{
|
||||
TerrainBlock* terrBlock = dynamic_cast<TerrainBlock*>(*itr);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@
|
|||
|
||||
#include "tools/editorTool.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( WorldEditor );
|
||||
|
||||
ConsoleDocClass( WorldEditor,
|
||||
|
|
@ -455,19 +457,20 @@ bool WorldEditor::pasteSelection( bool dropSel )
|
|||
return false;
|
||||
}
|
||||
|
||||
SimGroup *missionGroup = NULL;
|
||||
SimGroup *targetGroup = NULL;
|
||||
if( isMethod( "getNewObjectGroup" ) )
|
||||
{
|
||||
const char* targetGroupName = Con::executef( this, "getNewObjectGroup" );
|
||||
if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, missionGroup ) )
|
||||
if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, targetGroup) )
|
||||
Con::errorf( "WorldEditor::pasteSelection() - no SimGroup called '%s'", targetGroupName );
|
||||
}
|
||||
|
||||
if( !missionGroup )
|
||||
if( !targetGroup)
|
||||
{
|
||||
if( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
targetGroup = Scene::getRootScene();
|
||||
if( !targetGroup)
|
||||
{
|
||||
Con::errorf( "WorldEditor::pasteSelection() - MissionGroup not found" );
|
||||
Con::errorf( "WorldEditor::pasteSelection() - Scene not found" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -481,8 +484,8 @@ bool WorldEditor::pasteSelection( bool dropSel )
|
|||
if ( !obj )
|
||||
continue;
|
||||
|
||||
if ( missionGroup )
|
||||
missionGroup->addObject( obj );
|
||||
if (targetGroup)
|
||||
targetGroup->addObject( obj );
|
||||
|
||||
action->addObject( obj );
|
||||
|
||||
|
|
@ -594,7 +597,7 @@ void WorldEditor::hideObject(SceneObject* serverObj, bool hide)
|
|||
|
||||
void WorldEditor::hideSelection(bool hide)
|
||||
{
|
||||
SimGroup* pGroup = dynamic_cast<SimGroup*>(Sim::findObject("MissionGroup"));
|
||||
Scene* scene = Scene::getRootScene();
|
||||
|
||||
// set server/client objects hide field
|
||||
for(U32 i = 0; i < mSelected->size(); i++)
|
||||
|
|
@ -605,7 +608,7 @@ void WorldEditor::hideSelection(bool hide)
|
|||
|
||||
// Prevent non-mission group objects (i.e. Player) from being hidden.
|
||||
// Otherwise it is difficult to show them again.
|
||||
if(!serverObj->isChildOfGroup(pGroup))
|
||||
if(!serverObj->isChildOfGroup(scene))
|
||||
continue;
|
||||
|
||||
hideObject(serverObj, hide);
|
||||
|
|
@ -2437,7 +2440,7 @@ void WorldEditor::renderScene( const RectI &updateRect )
|
|||
}
|
||||
|
||||
// Render the paths
|
||||
renderPaths(Sim::findObject("MissionGroup"));
|
||||
renderPaths(Scene::getRootScene());
|
||||
|
||||
// walk selected
|
||||
Selection* selection = getActiveSelectionSet();
|
||||
|
|
@ -3653,10 +3656,10 @@ void WorldEditor::makeSelectionPrefab( const char *filename )
|
|||
return;
|
||||
}
|
||||
|
||||
SimGroup *missionGroup;
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( !scene)
|
||||
{
|
||||
Con::errorf( "WorldEditor::makeSelectionPrefab - Could not find MissionGroup." );
|
||||
Con::errorf( "WorldEditor::makeSelectionPrefab - Could not find root Scene." );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3746,7 +3749,7 @@ void WorldEditor::makeSelectionPrefab( const char *filename )
|
|||
fabMat.inverse();
|
||||
fab->setTransform( fabMat );
|
||||
fab->registerObject();
|
||||
missionGroup->addObject( fab );
|
||||
scene->addObject( fab );
|
||||
|
||||
// Select it, mark level as dirty.
|
||||
clearSelection();
|
||||
|
|
@ -3812,10 +3815,10 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
return;
|
||||
}
|
||||
|
||||
SimGroup *missionGroup;
|
||||
if (!Sim::findObject("MissionGroup", missionGroup))
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (!scene)
|
||||
{
|
||||
Con::errorf("WorldEditor::makeSelectionAMesh - Could not find MissionGroup.");
|
||||
Con::errorf("WorldEditor::makeSelectionAMesh - Could not find root Scene.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3965,7 +3968,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
fabMat.inverse();
|
||||
ts->setTransform(fabMat);
|
||||
ts->registerObject();
|
||||
missionGroup->addObject(ts);
|
||||
scene->addObject(ts);
|
||||
|
||||
// Select it, mark level as dirty.
|
||||
clearSelection();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue