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

Method findObjects

Engine/source/scene/sceneContainer.cpp:414–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412//-----------------------------------------------------------------------------
413
414void SceneContainer::findObjects(const Box3F& box, U32 mask, FindCallback callback, void *key)
415{
416 PROFILE_SCOPE(ContainerFindObjects_Box);
417
418 // If we're searching for just water, just physical zones, or
419 // just water and physical zones then use the optimized path.
420 if ( mask == WaterObjectType ||
421 mask == PhysicalZoneObjectType ||
422 mask == (WaterObjectType|PhysicalZoneObjectType) )
423 {
424 _findSpecialObjects( mWaterAndZones, box, mask, callback, key );
425 return;
426 }
427 else if( mask == TerrainObjectType )
428 {
429 _findSpecialObjects( mTerrains, box, mask, callback, key );
430 return;
431 }
432
433 AssertFatal( !mSearchInProgress, "SceneContainer::findObjects - Container queries are not re-entrant" );
434 mSearchInProgress = true;
435
436 U32 minX, maxX, minY, maxY;
437 getBinRange(box.minExtents.x, box.maxExtents.x, minX, maxX);
438 getBinRange(box.minExtents.y, box.maxExtents.y, minY, maxY);
439 mCurrSeqKey++;
440 for (U32 i = minY; i <= maxY; i++)
441 {
442 U32 insertY = i % csmNumBins;
443 U32 base = insertY * csmNumBins;
444 for (U32 j = minX; j <= maxX; j++)
445 {
446 U32 insertX = j % csmNumBins;
447
448 SceneObjectRef* chain = mBinArray[base + insertX].nextInBin;
449 while (chain)
450 {
451 if (chain->object->getContainerSeqKey() != mCurrSeqKey)
452 {
453 chain->object->setContainerSeqKey(mCurrSeqKey);
454
455 if ((chain->object->getTypeMask() & mask) != 0 &&
456 chain->object->isCollisionEnabled())
457 {
458 if (chain->object->getWorldBox().isOverlapped(box) || chain->object->isGlobalBounds())
459 {
460 (*callback)(chain->object,key);
461 }
462 }
463 }
464 chain = chain->nextInBin;
465 }
466 }
467 }
468 SceneObjectRef* chain = mOverflowBin.nextInBin;
469 while (chain)
470 {
471 if (chain->object->getContainerSeqKey() != mCurrSeqKey)

Callers 15

onCameraScopeQueryMethod · 0.80
scopeSceneMethod · 0.80
initMethod · 0.80
pointInWaterMethod · 0.80
updateWorkingListMethod · 0.80
addToExistingObjectsMethod · 0.80
lightMethod · 0.80
buildPartitionMethod · 0.80
updateContainerMethod · 0.80
processTickMethod · 0.80
pointInWaterMethod · 0.80

Calls 9

getContainerSeqKeyMethod · 0.80
setContainerSeqKeyMethod · 0.80
getTypeMaskMethod · 0.80
isCollisionEnabledMethod · 0.80
isGlobalBoundsMethod · 0.80
isOverlappedMethod · 0.60
getWorldBoxMethod · 0.45
getBoundsMethod · 0.45
isCulledMethod · 0.45

Tested by

no test coverage detected