DayZ 1.28
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 строка 1299

1300 {
1301 array<Object> vicinityObjects= new array<Object>;
1302 vicinityObjects.Copy(objects);
1303
1304 int i = 0;
1305 int j = 0;
1306 int k = 0;
1307 int mCount = vicinityObjects.Count();
1308
1309 if (!filteredObjects)
1310 filteredObjects = new array<Object>;
1311
1312 // Remove objects that are too far from the player anyways
1313 if ( doDistanceCheck )
1314 {
1315 for ( i = vicinityObjects.Count() - 1; i >= 0; --i )
1316 {
1317 Object obj = vicinityObjects[i];
1318 if ( obj && !CanIgnoreDistanceCheck( obj ) && vector.DistanceSq(origin, obj.GetPosition()) > maxDist * maxDist )
1319 vicinityObjects.Remove(i);
1320 }
1321 }
1322
1323 // Sort obstructingObjects to have the furthest one first
1324 array<Object> sortedObstructingObjects = new array<Object>;
1325 array<float> distanceHelper = new array<float>;
1326 array<float> distanceHelperUnsorted = new array<float>;
1327 float distance, dist1, dist2;
1328
1329 for ( i = 0; i < obstructingObjects.Count(); ++i )
1330 {
1331 distance = vector.DistanceSq(obstructingObjects[i].GetWorldPosition(), origin);
1332 distanceHelper.Insert(distance);
1333 }
1334
1335 distanceHelperUnsorted.Copy(distanceHelper);
1336 distanceHelper.Sort();
1337
1338 for ( i = distanceHelper.Count() - 1; i >= 0; --i )
1339 sortedObstructingObjects.Insert(obstructingObjects[distanceHelperUnsorted.Find(distanceHelper[i])]);
1340
1343 array<Object> group;
1344
1345 float cos = Math.Cos(90);
1346 float sin = Math.Sin(90);
1347
1348 // Iterate through sorted obstructingObjects
1349 for ( i = 0; i < sortedObstructingObjects.Count(); ++i )
1350 {
1351 Object obstrObj = sortedObstructingObjects[i];
1352 vector worldPos = obstrObj.GetWorldPosition();
1353 vector min, max;
1354 vector minMax[2];
1355 if ( obstrObj.GetCollisionBox(minMax) )
1356 {
1357 min = minMax[0];
1358 max = minMax[1];
1359 max = max * (obstrObj.GetOrientation() * range);
1360
1361 vector center, dx, dy, dz, half;
1362 center = (min + max) * 0.5;
1363 dz = obstrObj.GetOrientation();
1364 dx = vector.RotateAroundZero(dz, vector.Up, cos, sin);
1365 dy = vector.RotateAroundZero(dz, vector.Aside, cos, sin);
1366 half = (max - min) * 0.5;
1367 half = Vector(Math.AbsFloat(half[0]), Math.AbsFloat(half[1]), Math.AbsFloat(half[2]));
1368
1369 group = new array<Object>;
1370
1371 // Group objects within the above box
1372 for ( j = vicinityObjects.Count() - 1; j >= 0; --j )
1373 {
1374 Object vicObj = vicinityObjects[j];
1375 if ( vicObj )
1376 {
1377 vector d = vicObj.GetWorldPosition() - worldPos + center;
1378 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] )
1379 {
1380 group.Insert(vicObj);
1381 vicinityObjects.Remove(j);
1382 }
1383 }
1384 }
1385
1386 if ( group.Count() > 0 )
1387 tempGroups.Insert(group);
1388 }
1389 }
1390
1391 // Go through the objects grouped by obstruction to split them by distance too
1392 for ( i = 0; i < tempGroups.Count(); ++i )
1393 SplitArrayIntoGroupsByDistance(tempGroups[i], objectGroups, distanceDelta);
1394
1395 // Split initial groups by distance
1396 SplitArrayIntoGroupsByDistance(vicinityObjects, objectGroups, distanceDelta);
1397
1398 // Raycast accordingly to groups
1399 IsObjectObstructedCache cache = new IsObjectObstructedCache(origin, mCount);
1400 for ( i = 0; i < objectGroups.Count(); ++i )
1401 {
1402 array<Object> objectGroup = objectGroups[i];
1403 Object sampleObject = objectGroup[0];
1404
1405 if ( !IsObjectObstructedEx(sampleObject, cache) )
1406 filteredObjects.InsertAll(objectGroup);
1407
1408 cache.ClearCache();
1409 }
1410 }
static bool CanIgnoreDistanceCheck(Object obj)
Определения MiscGameplayFunctions.c:1293
void IsObjectObstructedCache(vector rayCastStart, int totalObjects)
Определения MiscGameplayFunctions.c:1944
static bool IsObjectObstructedEx(Object object, IsObjectObstructedCache cache, bool doDistanceCheck=false, vector distanceCheckPos="0 0 0", float maxDist=0)
Определения MiscGameplayFunctions.c:1455
static void SplitArrayIntoGroupsByDistance(array< Object > objects, array< ref array< Object > > objectGroups, float squaredDistanceDelta)
Определения MiscGameplayFunctions.c:1412
Определения 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().