17#ifndef AGX_PHYSISCS_HIERARCHICAL_GRID_UTIL_H
18#define AGX_PHYSISCS_HIERARCHICAL_GRID_UTIL_H
30#define NUM_ITERATION_ZONE_JOBS 2
32namespace agx {
namespace Physics {
namespace HierarchicalGrid {
177 template <
typename ZoneDataT>
180 return contactZone.particleParticleContacts[zoneIndex].size() +
181 contactZone.particleGeometryContacts[zoneIndex].size() +
182 contactZone.geometryGeometryContacts[zoneIndex].size();
185 template <
typename ZonePtrT>
221 Vec3i shiftedOffset = offset + 1;
222 Index neighborIndex = (
Index)((shiftedOffset[0] * 9) + (shiftedOffset[1] * 3) + shiftedOffset[2]);
224 return neighborIndex;
230 Vec2i shiftedOffset = offset + 1;
231 Index neighborIndex = (
Index)((shiftedOffset[0] * 2) + shiftedOffset[1]);
233 return neighborIndex;
240 return (
UInt)(offset[0]+1) <= 2 && (
UInt)(offset[1]+1) <= 2 && (
UInt)(offset[2]+1) <= 2;
245 return (
UInt)(offset[0]+1) <= 2 && (
UInt)(offset[1]+1) <= 2;
252 for (
UInt i = 0; i < level; ++i)
257 cellIndex = cell.parent[cellIndex];
272 minCellIndex = cellIndex1;
277 minCellIndex = cellIndex2;
288 return (
UInt(1) << numBits) -
UInt(1);
301 Vec3i offset =
Vec3i(zoneId[0] & 0x1, zoneId[1] & 0x1, zoneId[2] & 0x1);
312 Index dominantCellIndex = zoneType1 > zoneType2 ? cellIndex1 : cellIndex2;
314 Vec3i zoneId1 = cell.id[dominantCellIndex];
317 zoneId1[0] >>= tierAccumulation;
318 zoneId1[1] >>= tierAccumulation;
319 zoneId1[2] >>= tierAccumulation;
321 zoneId2[0] >>= tierAccumulation;
322 zoneId2[1] >>= tierAccumulation;
323 zoneId2[2] >>= tierAccumulation;
325 Vec3i boundaryId = zoneId1 + zoneId2;
333 UInt cornerShift =
UInt(1) << (tierAccumulation-1);
334 Vec3i cornerId1 = cell.id[cellIndex1] + cornerShift;
335 Vec3i cornerId2 = cell.id[cellIndex2] + cornerShift;
337 cornerId1[0] >>= tierAccumulation;
338 cornerId1[1] >>= tierAccumulation;
339 cornerId1[2] >>= tierAccumulation;
341 cornerId2[0] >>= tierAccumulation;
342 cornerId2[1] >>= tierAccumulation;
343 cornerId2[2] >>= tierAccumulation;
345 if (cornerId1 == cornerId2)
348 return cornerId1 + cornerId2 - 1;
358 Vec3i offset = cell.id[cellIndex1] - cell.id[cellIndex2];
360 if ((offset[0] & offset[1] & offset[2] & 0x1) && zoneType1 ==
ZONE_EDGE && zoneType2 ==
ZONE_EDGE && cell.zoneType[cellIndex1] != cell.zoneType[cellIndex2] * -1)
362 std::cout <<
"detected special edge/edge diagonal, cell1: " << cell.id[cellIndex1] <<
", cell2: " << cell.id[cellIndex2] << std::endl;
367 Vec3i cornerId1 = cell.id[cellIndex1] + dir1 + dir2;
368 Vec3i cornerId2 = cell.id[cellIndex2] + dir1 + dir2;
373 cornerId1[0] >>= tierAccumulation;
374 cornerId1[1] >>= tierAccumulation;
375 cornerId1[2] >>= tierAccumulation;
377 cornerId2[0] >>= tierAccumulation;
378 cornerId2[1] >>= tierAccumulation;
379 cornerId2[2] >>= tierAccumulation;
381 return cornerId1 + cornerId2;
389 return cell.id[parentIndex1] + cell.id[parentIndex2];
406 zoneType += (
id[0] == mask ? 18 : (
id[0] == 0 ? 0 : 9));
407 zoneType += (
id[1] == mask ? 6 : (
id[1] == 0 ? 0 : 3));
408 zoneType += (
id[2] == mask ? 2 : (
id[2] == 0 ? 0 : 1));
411 return (
UInt8)zoneType;
#define AGXPHYSICS_EXPORT
Data storage for a collection of entity instances of a specified EntityModel.
agxData::EntityData * getData()
AGXPHYSICS_EXPORT const char * getZoneCategoryName(Index category)
AGXPHYSICS_EXPORT NeighborCellPath __private_NeighborPathTable[8][32]
AGXPHYSICS_EXPORT bool isNeighborOffset(const Vec3i &offset)
AGXPHYSICS_EXPORT ZoneCategory calculateZoneCategory(const Vec3i &zoneId)
const Vec3i __private_neighborTable[]
AGXPHYSICS_EXPORT Index alignCellTiers(CellData &cell, Index tier1, Index tier2, Index &cellIndex1, Index &cellIndex2)
Align cell indices to the same tier.
UInt countNumContacts(ZoneDataT &contactZone, Index zoneIndex)
AGXPHYSICS_EXPORT Index calculateNeighborIndex(const Vec3i &offset)
AGXPHYSICS_EXPORT UInt8 calculateZoneType(Vec3i id, UInt tierAccumulation)
Calculates which one of the 27 internal zones the cell is part of.
AGXPHYSICS_EXPORT const Vec2i * getNeighborTable2d()
AGXPHYSICS_EXPORT const UInt8 * getNeighborPathOrderTable(size_t childIndex)
const ZoneCategory __private_categoryTable[]
AGXPHYSICS_EXPORT UInt8 __private_NeighborPathOrderTable[8][32]
AGXPHYSICS_EXPORT ZoneCategory getZoneCategory(Index zoneType)
AGXPHYSICS_EXPORT const NeighborCellPath * getNeighborPathTable(size_t childIndex)
AGXPHYSICS_EXPORT Vec3i calculateBoundaryZoneId(CellData &cell, Index cellIndex1, Index cellIndex2, UInt tierAccumulation)
Corners and edges are extended to make all edges independent of each other, and the same for all face...
AGXPHYSICS_EXPORT const Vec2i & getNeighborOffset2d(Index index)
ZoneCategory
The 27 internal zones are following categories (box features) and counts: Internal: 1 Face: 6 Edge: 1...
AGXPHYSICS_EXPORT const Vec3i * getNeighborTable()
AGXPHYSICS_EXPORT Index getParentCell(CellData &cell, Index cellIndex, UInt level)
Return the parent cell N tiers above the specified cell.
UInt generateBitMask(UInt numBits)
AGXPHYSICS_EXPORT const Vec3i & getNeighborOffset(Index index)
The following ordering of neighbor coordinates is used for all cell/zone interactions.
const Vec2i __private_neighborTable_2D[]
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AGXCORE_EXPORT const InvalidIndexStruct InvalidIndex
UInt8 neighborParentIndex