DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ FilterObstructedObjectsByGrouping()

static void FilterObstructedObjectsByGrouping ( vector origin,
float range,
float distanceDelta,
array< Object > objects,
array< Object > obstructingObjects,
out array< Object > filteredObjects,
bool doDistanceCheck = false,
bool checkIfDistanceCanBeIgnored = false,
float maxDist = 0 )
staticprotected

group objects that are close to each other together

См. определение в файле MiscGameplayFunctions.c строка 1292

1293 {
1294 array<Object> vicinityObjects= new array<Object>;
1295 vicinityObjects.Copy(objects);
1296
1297 int i = 0;
1298 int j = 0;
1299 int k = 0;
1300 int mCount = vicinityObjects.Count();
1301
1302 if (!filteredObjects)
1303 filteredObjects = new array<Object>;
1304
1305 // Remove objects that are too far from the player anyways
1306 if ( doDistanceCheck )
1307 {
1308 for ( i = vicinityObjects.Count() - 1; i >= 0; --i )
1309 {
1310 Object obj = vicinityObjects[i];
1311 if ( obj && !CanIgnoreDistanceCheck( obj ) && vector.DistanceSq(origin, obj.GetPosition()) > maxDist * maxDist )
1312 vicinityObjects.Remove(i);
1313 }
1314 }
1315
1316 // Sort obstructingObjects to have the furthest one first
1317 array<Object> sortedObstructingObjects = new array<Object>;
1318 array<float> distanceHelper = new array<float>;
1319 array<float> distanceHelperUnsorted = new array<float>;
1320 float distance, dist1, dist2;
1321
1322 for ( i = 0; i < obstructingObjects.Count(); ++i )
1323 {
1324 distance = vector.DistanceSq(obstructingObjects[i].GetWorldPosition(), origin);
1325 distanceHelper.Insert(distance);
1326 }
1327
1328 distanceHelperUnsorted.Copy(distanceHelper);
1329 distanceHelper.Sort();
1330
1331 for ( i = distanceHelper.Count() - 1; i >= 0; --i )
1332 sortedObstructingObjects.Insert(obstructingObjects[distanceHelperUnsorted.Find(distanceHelper[i])]);
1333
1336 array<Object> group;
1337
1338 float cos = Math.Cos(90);
1339 float sin = Math.Sin(90);
1340
1341 // Iterate through sorted obstructingObjects
1342 for ( i = 0; i < sortedObstructingObjects.Count(); ++i )
1343 {
1344 Object obstrObj = sortedObstructingObjects[i];
1345 vector worldPos = obstrObj.GetWorldPosition();
1346 vector min, max;
1347 vector minMax[2];
1348 if ( obstrObj.GetCollisionBox(minMax) )
1349 {
1350 min = minMax[0];
1351 max = minMax[1];
1352 max = max * (obstrObj.GetOrientation() * range);
1353
1354 vector center, dx, dy, dz, half;
1355 center = (min + max) * 0.5;
1356 dz = obstrObj.GetOrientation();
1357 dx = vector.RotateAroundZero(dz, vector.Up, cos, sin);
1358 dy = vector.RotateAroundZero(dz, vector.Aside, cos, sin);
1359 half = (max - min) * 0.5;
1360 half = Vector(Math.AbsFloat(half[0]), Math.AbsFloat(half[1]), Math.AbsFloat(half[2]));
1361
1362 group = new array<Object>;
1363
1364 // Group objects within the above box
1365 for ( j = vicinityObjects.Count() - 1; j >= 0; --j )
1366 {
1367 Object vicObj = vicinityObjects[j];
1368 if ( vicObj )
1369 {
1370 vector d = vicObj.GetWorldPosition() - worldPos + center;
1371 if ( Math.AbsFloat(vector.Dot(d, dx)) <= half[0] && Math.AbsFloat(vector.Dot(d, dy)) <= half[1] && Math.AbsFloat(vector.Dot(d, dz)) <= half[2] )
1372 {
1373 group.Insert(vicObj);
1374 vicinityObjects.Remove(j);
1375 }
1376 }
1377 }
1378
1379 if ( group.Count() > 0 )
1380 tempGroups.Insert(group);
1381 }
1382 }
1383
1384 // Go through the objects grouped by obstruction to split them by distance too
1385 for ( i = 0; i < tempGroups.Count(); ++i )
1386 SplitArrayIntoGroupsByDistance(tempGroups[i], objectGroups, distanceDelta);
1387
1388 // Split initial groups by distance
1389 SplitArrayIntoGroupsByDistance(vicinityObjects, objectGroups, distanceDelta);
1390
1391 // Raycast accordingly to groups
1392 IsObjectObstructedCache cache = new IsObjectObstructedCache(origin, mCount);
1393 for ( i = 0; i < objectGroups.Count(); ++i )
1394 {
1395 array<Object> objectGroup = objectGroups[i];
1396 Object sampleObject = objectGroup[0];
1397
1398 if ( !IsObjectObstructedEx(sampleObject, cache) )
1399 filteredObjects.InsertAll(objectGroup);
1400
1401 cache.ClearCache();
1402 }
1403 }
static bool CanIgnoreDistanceCheck(Object obj)
Определения MiscGameplayFunctions.c:1286
void IsObjectObstructedCache(vector rayCastStart, int totalObjects)
Определения MiscGameplayFunctions.c:1937
static bool IsObjectObstructedEx(Object object, IsObjectObstructedCache cache, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
Определения MiscGameplayFunctions.c:1448
static void SplitArrayIntoGroupsByDistance(array< Object > objects, array< ref array< Object > > objectGroups, float squaredDistanceDelta)
Определения MiscGameplayFunctions.c:1405
Определения EnMath.c:7
Определения ObjectTyped.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static proto native float DistanceSq(vector v1, vector v2)
Returns the square distance between tips of two 3D vectors.
static const vector Aside
Определения EnConvert.c:108
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Определения EnConvert.c:271
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
Определения EnConvert.c:477
static const vector Up
Определения EnConvert.c:107
Определения EnConvert.c:106
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static proto float AbsFloat(float f)
Returns absolute value.

Перекрестные ссылки Math::AbsFloat(), vector::Aside, CanIgnoreDistanceCheck(), Math::Cos(), vector::DistanceSq(), vector::Dot(), IsObjectObstructedCache(), IsObjectObstructedEx(), vector::RotateAroundZero(), Math::Sin(), SplitArrayIntoGroupsByDistance(), vector::Up и Vector().