Torque3D/Engine/source/T3D/zone.cpp

171 lines
6.4 KiB
C++
Raw Normal View History

2012-09-19 15:15:01 +00:00
//-----------------------------------------------------------------------------
// 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.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "T3D/zone.h"
#include "console/consoleTypes.h"
#include "console/engineAPI.h"
#include "scene/mixin/sceneAmbientSoundObject.impl.h"
#include "scene/mixin/scenePolyhedralObject.impl.h"
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
#include "scene/sceneManager.h"
2020-01-17 03:07:37 +00:00
#include "gui/worldEditor/worldEditor.h"
2012-09-19 15:15:01 +00:00
IMPLEMENT_CO_NETOBJECT_V1( Zone );
ConsoleDocClass( Zone,
"@brief An object that represents an interior space.\n\n"
"A zone is an invisible volume that encloses an interior space. All objects that have "
"their world space axis-aligned bounding boxes (AABBs) intersect the zone's volume are "
"assigned to the zone. This assignment happens automatically as objects are placed "
"and transformed. Also, assignment is not exclusive meaning that an object can be assigned "
"to many zones at the same time if it intersects all of them.\n\n"
"In itself, the volume of a zone is fully sealed off from the outside. This means that while "
"viewing the scene from inside the volume, only objects assigned to the zone are rendered while "
"when viewing the scene from outside the volume, objects <em>exclusively</em> only assigned the "
"zone are not rendered.\n\n"
"Usually, you will want to connect zones to each other by means of portals. A portal overlapping "
"with a zone \n\n"
"@tsexample\n"
"// Example declaration of a Zone. This creates a box-shaped zone.\n"
"new Zone( TestZone )\n"
"{\n"
" position = \"3.61793 -1.01945 14.7442\";\n"
" rotation = \"1 0 0 0\";\n"
" scale = \"10 10 10\";\n"
"};\n"
"@endtsexample\n\n"
"@section Zone_zoneGroups Zone Groups\n\n"
"Normally, Zones will not connect to each other when they overlap. This means that if viewing "
"the scene from one zone, the contents of the other zone will not be visible except when there "
"is a portal connecting the zones. However, sometimes it is convenient to represent a single interior "
"space through a combination of Zones so that when any of these zones is visible, all other zones "
"that are part of the same interior space are visible. This is possible by employing \"zone groups\".\n\n"
"@see Portal\n"
"@ingroup enviroMisc\n"
);
//-----------------------------------------------------------------------------
void Zone::consoleInit()
{
// Disable rendering of zones by default.
getStaticClassRep()->mIsRenderEnabled = false;
}
2022-06-13 17:38:08 +00:00
#ifdef TORQUE_TOOLS
2020-01-17 03:07:37 +00:00
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;
Zone* zoneClient = (Zone*)getClientObject();
if (zoneClient)
2020-01-17 03:07:37 +00:00
{
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)
2020-01-17 03:07:37 +00:00
{
SceneObject* obj = (SceneObject*)iter->getServerObject();
bool fullyEnclosed = true;
2020-01-17 03:07:37 +00:00
for (SceneObject::ObjectZonesIterator zoneIter(obj); zoneIter.isValid(); ++zoneIter)
{
Updated Assimp Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
2020-03-19 14:47:38 +00:00
if (*zoneIter != zoneId)
2020-01-17 03:07:37 +00:00
fullyEnclosed = false;
}
if (fullyEnclosed)
sql.insertObject(obj);
2020-01-17 03:07:37 +00:00
}
}
2020-01-17 03:07:37 +00:00
}
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);
}
}
}
2022-06-13 17:38:08 +00:00
#endif
2012-09-19 15:15:01 +00:00
//=============================================================================
// Console API.
//=============================================================================
// MARK: ---- Console API ----
//-----------------------------------------------------------------------------
DefineEngineMethod( Zone, getZoneId, S32, (),,
"Get the unique numeric ID of the zone in its scene.\n\n"
"@return The ID of the zone." )
{
return object->getZoneRangeStart();
}
//-----------------------------------------------------------------------------
DefineEngineMethod( Zone, dumpZoneState, void, ( bool updateFirst ), ( true ),
"Dump a list of all objects assigned to the zone to the console as well as a list "
"of all connected zone spaces.\n\n"
"@param updateFirst Whether to update the contents of the zone before dumping. Since zoning states of "
"objects are updated on demand, the zone contents can be outdated." )
{
object->dumpZoneState( updateFirst );
}
2022-06-13 17:38:08 +00:00
#ifdef TORQUE_TOOLS
2020-01-17 03:07:37 +00:00
DefineEngineMethod(Zone, selectWithin, void, () ,,
"select a list of all objects assigned to the zone")
{
object->selectWithin();
}
2022-06-13 17:38:08 +00:00
#endif