MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _zoneInsert

Method _zoneInsert

Engine/source/scene/zones/sceneZoneSpaceManager.cpp:599–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597//-----------------------------------------------------------------------------
598
599void SceneZoneSpaceManager::_zoneInsert( SceneObject* object, bool queryListInitialized )
600{
601 PROFILE_SCOPE( SceneZoneSpaceManager_zoneInsert );
602
603 AssertFatal( object->mNumCurrZones == 0, "SceneZoneSpaceManager::_zoneInsert - Object already in zone list" );
604 AssertFatal( object->getContainer() != NULL, "SceneZoneSpaceManager::_zoneInsert - Object must be in scene" );
605 AssertFatal( !dynamic_cast< SceneRootZone* >( object ), "SceneZoneSpaceManager::_zoneInsert - Must not be called on SceneRootZone" );
606
607 // If all we have is a single zone in the scene, then it must
608 // be the outdoor zone. Simply assign the object to it. Also do this
609 // if the object has global bounds on since we always assign these to
610 // just the outdoor zone. Finally, also do it for all object types that
611 // we want to restrict to the outdoor zone.
612
613 if( mNumActiveZones == 1 || object->isGlobalBounds() || object->getTypeMask() & OUTDOOR_OBJECT_TYPEMASK )
614 _addToOutdoorZone( object );
615 else
616 {
617 // Otherwise find all zones spaces that intersect with the object's
618 // world box.
619
620 if( !queryListInitialized )
621 _queryZoneSpaces( object->getWorldBox() );
622
623 // Go through the zone spaces and link all zones that the object
624 // overlaps.
625
626 bool outsideIncluded = true;
627 const U32 numZoneSpaces = mZoneSpacesQueryList.size();
628 for( U32 i = 0; i < numZoneSpaces; ++ i )
629 {
630 SceneZoneSpace* zoneSpace = dynamic_cast< SceneZoneSpace* >( mZoneSpacesQueryList[ i ] );
631 if( !zoneSpace )
632 continue;
633
634 AssertFatal( zoneSpace != getRootZone(), "SceneZoneSpaceManager::_zoneInsert - SceneRootZone returned by zone space query" );
635
636 // If we are inserting a zone space, then the query will turn up
637 // the object itself at some point. Skip it.
638
639 if( zoneSpace == object )
640 continue;
641
642 // Find the zones that the object overlaps within
643 // the zone space.
644
645 U32 numZones = 0;
646 U32 zones[ SceneObject::MaxObjectZones ];
647
648 bool overlapsOutside = zoneSpace->getOverlappingZones( object, zones, numZones );
649 AssertFatal( numZones != 0 || overlapsOutside,
650 "SceneZoneSpaceManager::_zoneInsert - Object must be fully contained in one or more zones or intersect the outside zone" );
651
652 outsideIncluded &= overlapsOutside; // Only include outside if *none* of the zones fully contains the object.
653
654 // Link the object to the zones.
655
656 for( U32 n = 0; n < numZones; ++ n )

Callers

nothing calls this directly

Calls 7

isGlobalBoundsMethod · 0.80
getTypeMaskMethod · 0.80
_onZoneAddObjectMethod · 0.80
getContainerMethod · 0.45
getWorldBoxMethod · 0.45
sizeMethod · 0.45
getOverlappingZonesMethod · 0.45

Tested by

no test coverage detected