The HashSpace class.
More...
#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/spatial/al_HashSpace.hpp>
|
| HashSpace (uint32_t resolution=5, uint32_t numObjects=0) |
|
uint32_t | dim () const |
| the dimension of the space per axis:
|
|
uint32_t | maxRadius () const |
| the maximum valid radius to query (half the dimension):
|
|
void | numObjects (int numObjects) |
| get/set the number of objects:
|
|
uint32_t | numObjects () const |
|
Object & | object (uint32_t i) |
| get the object at a given index:
|
|
HashSpace & | move (uint32_t objectId, double x, double y, double z) |
| set the position of an object:
|
|
template<typename T > |
HashSpace & | move (uint32_t objectId, Vec< 3, T > pos) |
|
HashSpace & | remove (uint32_t objectId) |
|
double | wrap (double x) const |
| wrap an absolute position within the space:
|
|
template<typename T > |
Vec< 3, T > | wrap (Vec< 3, T > v) const |
|
double | wrapRelative (double x) const |
|
template<typename T > |
Vec< 3, T > | wrapRelative (Vec< 3, T > v) const |
|
|
static uint32_t | invalidHash () |
| an invalid voxel index used to indicate non-membership
|
|
|
uint32_t | distanceSquared (double a1, double a2, double a3) const |
|
uint32_t | hash (unsigned x, unsigned y, unsigned z) const |
|
template<typename T > |
uint32_t | hash (Vec< 3, T > v) const |
|
uint32_t | hash (uint32_t x, uint32_t y, uint32_t z, uint32_t offset) const |
|
template<typename T > |
uint32_t | hash (Vec< 3, T > v, uint32_t offset) const |
|
uint32_t | hashx (uint32_t v) const |
|
uint32_t | hashy (uint32_t v) const |
|
uint32_t | hashz (uint32_t v) const |
|
Vec3i | unhash (uint32_t h) const |
|
uint32_t | unhashx (uint32_t h) const |
|
uint32_t | unhashy (uint32_t h) const |
|
uint32_t | unhashz (uint32_t h) const |
|
|
static double | wrap (double x, double mod) |
|
static double | wrap (double x, double lo, double hi) |
|
|
uint32_t | mShift |
|
uint32_t | mShift2 |
|
uint32_t | mDim |
|
uint32_t | mDim2 |
|
uint32_t | mDim3 |
|
uint32_t | mWrap |
|
uint32_t | mWrap3 |
|
int | mDimHalf |
|
uint32_t | mMaxD2 |
|
uint32_t | mMaxHalfD2 |
|
std::vector< Object > | mObjects |
| the array of objects
|
|
std::vector< Voxel > | mVoxels |
| the array of voxels (indexed by hashed location)
|
|
std::vector< uint32_t > | mVoxelIndices |
| a baked array of voxel indices sorted by distance
|
|
std::vector< uint32_t > | mDistanceToVoxelIndices |
| a baked array mapping distance to mVoxelIndices offsets
|
|
std::vector< uint32_t > | mVoxelIndicesToDistance |
|
The HashSpace class.
HashSpace is a way to detect object collisions using a voxel grid The grid has a given resolution (no. voxel cells per side)
It is optimized for densely packed points and querying for nearest neighbors within given radii (results will be roughly sorted by distance).
Definition at line 76 of file al_HashSpace.hpp.
◆ HashSpace()
al::HashSpace::HashSpace |
( |
uint32_t |
resolution = 5 , |
|
|
uint32_t |
numObjects = 0 |
|
) |
| |
Construct a HashSpace locations will range from [0..2^resolution)
resolution can be 1 to 10; the dim is 2^resolution i.e. 2..1024 (the limit is 10 so that the hash can fit inside a uint32_t integer) default 5 implies 32 units per side
- Parameters
-
resolution | determines the number of voxels as 2^resolution per axis |
numObjects | set how many Object slots to initally allocate |
◆ remove()
HashSpace & al::HashSpace::remove |
( |
uint32_t |
objectId | ) |
|
|
inline |
this removes the object from voxels/queries, but does not destroy it the objectId can be reused later via move()
Definition at line 507 of file al_HashSpace.hpp.
◆ wrapRelative()
double al::HashSpace::wrapRelative |
( |
double |
x | ) |
const |
|
inline |
wrap a relative vector within the space: use this when computing the vector between objects to properly take into account toroidal wrapping
Definition at line 264 of file al_HashSpace.hpp.
The documentation for this class was generated from the following file: