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

Method initRadiusSearch

Engine/source/scene/sceneContainer.cpp:1240–1284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1238}
1239
1240void SceneContainer::initRadiusSearch(const Point3F& searchPoint,
1241 const F32 searchRadius,
1242 const U32 searchMask)
1243{
1244 cleanupSearchVectors();
1245
1246 mSearchReferencePoint = searchPoint;
1247
1248 Box3F queryBox(searchPoint, searchPoint);
1249 queryBox.minExtents -= Point3F(searchRadius, searchRadius, searchRadius);
1250 queryBox.maxExtents += Point3F(searchRadius, searchRadius, searchRadius);
1251
1252 SimpleQueryList queryList;
1253 findObjects(queryBox, searchMask, SimpleQueryList::insertionCallback, &queryList);
1254
1255 F32 radiusSquared = searchRadius * searchRadius;
1256
1257 const F32* pPoint = &searchPoint.x;
1258 for (U32 i = 0; i < queryList.mList.size(); i++)
1259 {
1260 const F32* bMins;
1261 const F32* bMaxs;
1262 bMins = &queryList.mList[i]->getWorldBox().minExtents.x;
1263 bMaxs = &queryList.mList[i]->getWorldBox().maxExtents.x;
1264 F32 sum = 0;
1265 for (U32 j = 0; j < 3; j++)
1266 {
1267 if (pPoint[j] < bMins[j])
1268 sum += (pPoint[j] - bMins[j])*(pPoint[j] - bMins[j]);
1269 else if (pPoint[j] > bMaxs[j])
1270 sum += (pPoint[j] - bMaxs[j])*(pPoint[j] - bMaxs[j]);
1271 }
1272 if (sum < radiusSquared || queryList.mList[i]->isGlobalBounds())
1273 {
1274 mSearchList.push_back(new SimObjectPtr<SceneObject>);
1275 *(mSearchList.last()) = queryList.mList[i];
1276 }
1277 }
1278 if (mSearchList.size() != 0)
1279 {
1280 sgSortReferencePoint = mSearchReferencePoint;
1281 dQsort(mSearchList.address(), mSearchList.size(),
1282 sizeof(SimObjectPtr<SceneObject>*), cmpSearchPointers);
1283 }
1284}
1285
1286//-----------------------------------------------------------------------------
1287

Callers 2

sceneContainer.cppFile · 0.80
deal_area_damageMethod · 0.80

Calls 8

dQsortFunction · 0.85
isGlobalBoundsMethod · 0.80
Point3FClass · 0.70
sizeMethod · 0.45
getWorldBoxMethod · 0.45
push_backMethod · 0.45
lastMethod · 0.45
addressMethod · 0.45

Tested by

no test coverage detected