MUDA
Loading...
Searching...
No Matches
muda::spatial_hash::SparseSpatialHash< Hash > Class Template Reference

Public Member Functions

 SparseSpatialHash (muda::Stream &stream=muda::Stream::Default())
 
template<typename Pred = DefaultPredication>
void detect (CBufferView< BoundingSphere > spheres, DeviceBuffer< CollisionPair > &collisionPairs, Pred &&pred={})
 Detect collision pairs from bounding spheres. Note that:
 
template<typename Pred = DefaultPredication>
void detect (int level, CBufferView< BoundingSphere > spheres, DeviceBuffer< CollisionPair > &collisionPairs, Pred &&pred={})
 Detect collision pairs from bounding spheres at a specific level (level >= 0). This is used for hierarchical spatial hashing collision detection. Its user's responsibility to set level value to a bounding sphere. Normally, higher level means larger bounding sphere. Users should decide a proper range of radius for each level, like:
 

Member Function Documentation

◆ detect() [1/2]

template<typename Hash = Morton<uint32_t>>
template<typename Pred = DefaultPredication>
void muda::spatial_hash::SparseSpatialHash< Hash >::detect ( CBufferView< BoundingSphere spheres,
DeviceBuffer< CollisionPair > &  collisionPairs,
Pred &&  pred = {} 
)
inline

Detect collision pairs from bounding spheres. Note that:

  • The collision pairs are unique but not sorted.
  • All (i,j) pairs in collisionPairs satisfy i < j.
Parameters
[in]spheresbounding spheres
[out]collisionPairsoutput collision pairs
[in]predpredication function. f: __device__ (int i, int j) -> bool. If pred(i,j) is true, then the collision pair (i,j) is recorded, else the collision pair is discarded.
See also
DefaultPredication

◆ detect() [2/2]

template<typename Hash = Morton<uint32_t>>
template<typename Pred = DefaultPredication>
void muda::spatial_hash::SparseSpatialHash< Hash >::detect ( int  level,
CBufferView< BoundingSphere spheres,
DeviceBuffer< CollisionPair > &  collisionPairs,
Pred &&  pred = {} 
)
inline

Detect collision pairs from bounding spheres at a specific level (level >= 0). This is used for hierarchical spatial hashing collision detection. Its user's responsibility to set level value to a bounding sphere. Normally, higher level means larger bounding sphere. Users should decide a proper range of radius for each level, like:

if (r < r0) s.level = 0;
else if (r < r1) s.level = 1;
else s.level = 2;
...
Definition bounding_volume.h:9

Note that:

  • For a level L, any bounding spheres has a level <= L will be taken into account.
  • The collision pairs are unique but not sorted.
  • All (i,j) pairs in collisionPairs satisfy i < j.
  • The collisionPairs will be appended with new collision pairs (not cleared).

Typical usage:

// Your code to fill spheres with proper level
// ...
for (int level = 0; level < level_count; ++level)
{
detect(level, spheres, collisionPairs);
}
A std::vector like wrapper of cuda device memory, allows user to:
Definition device_buffer.h:46
void detect(CBufferView< BoundingSphere > spheres, DeviceBuffer< CollisionPair > &collisionPairs, Pred &&pred={})
Detect collision pairs from bounding spheres. Note that:
Definition sparse_spatial_hash.h:41
Parameters
[in]levelthe hierarchy level we want to detect
[in]spheresbounding spheres
[out]collisionPairsappended output collision pairs
[in]predpredication function. f: __device__ (int i, int j) -> bool. If pred(i,j) is true, then the collision pair (i,j) is recorded, else the collision pair is discarded.
See also
DefaultPredication

The documentation for this class was generated from the following file: