Merge branch 'alpha40_zonePicker' of https://github.com/Azaezel/Torque3D into Preview4_0

This commit is contained in:
Areloch 2020-03-03 10:47:28 -06:00
commit f30aed628f
2 changed files with 68 additions and 2 deletions

View file

@ -28,6 +28,8 @@
#include "scene/mixin/sceneAmbientSoundObject.impl.h"
#include "scene/mixin/scenePolyhedralObject.impl.h"
#include "gui/worldEditor/worldEditor.h"
IMPLEMENT_CO_NETOBJECT_V1( Zone );
@ -80,6 +82,62 @@ void Zone::consoleInit()
getStaticClassRep()->mIsRenderEnabled = false;
}
void Zone::initPersistFields()
{
addProtectedField("selectAll", TypeBool, Offset(mSelecting, Zone),
&_doSelect, &defaultProtectedGetFn, "Select all in this zone", AbstractClassRep::FieldFlags::FIELD_ComponentInspectors);
Parent::initPersistFields();
}
bool Zone::_doSelect(void* object, const char* index, const char* data)
{
Zone* zone = reinterpret_cast<Zone*>(object);
zone->selectWithin();
return false;
}
void Zone::selectWithin()
{
SimpleQueryList sql;
//getContainer()->polyhedronFindObjects(getPolyhedron(), 0xFFFFFFFF, SimpleQueryList::insertionCallback, &sql);
//replace the above with this once we stort out how to look up the managed zoneID from the insatnce itself
Zone* zoneClient = (Zone*)getClientObject();
SceneZoneSpaceManager* zoneManager = zoneClient->getSceneManager()->getZoneManager();
if (zoneManager)
{
for (U32 zoneId = zoneClient->mZoneRangeStart; zoneId < zoneClient->mZoneRangeStart + zoneClient->mNumZones; ++zoneId)
for (SceneZoneSpaceManager::ZoneContentIterator iter(zoneManager, zoneId, false); iter.isValid(); ++iter)
{
SceneObject* obj = (SceneObject*)iter->getServerObject();
bool fullyEnclosed = true;
for (SceneObject::ObjectZonesIterator zoneIter(obj); zoneIter.isValid(); ++zoneIter)
{
if (*zoneIter != zoneId);
fullyEnclosed = false;
}
if (fullyEnclosed)
sql.insertObject(obj);
}
}
WorldEditor* wedit;
if (Sim::findObject("EWorldEditor", wedit))
{
wedit->clearSelection();
wedit->selectObject(this);
for (SceneObject** i = sql.mList.begin(); i != sql.mList.end(); i++)
{
wedit->selectObject(*i);
}
}
}
//=============================================================================
// Console API.
//=============================================================================
@ -104,3 +162,9 @@ DefineEngineMethod( Zone, dumpZoneState, void, ( bool updateFirst ), ( true ),
{
object->dumpZoneState( updateFirst );
}
DefineEngineMethod(Zone, selectWithin, void, () ,,
"select a list of all objects assigned to the zone")
{
object->selectWithin();
}

View file

@ -45,9 +45,11 @@
class Zone : public SceneAmbientSoundObject< ScenePolyhedralZone >
{
public:
bool mSelecting = false;
static void initPersistFields();
static bool _doSelect(void* object, const char* index, const char* data);
typedef SceneAmbientSoundObject< ScenePolyhedralZone > Parent;
void selectWithin();
protected:
// SceneVolume.