Voxels.h 673 Bytes
Newer Older
Nianchen Deng's avatar
sync    
Nianchen Deng committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once
#include "../utils/common.h"

class Voxels {
public:
    Voxels(const std::string &path);

    int nVoxels() const { return _voxels->n(); }

    int nCorners() const { return _corners->n(); }

    int nGrids() const { return _steps[0] * _steps[1] * _steps[2]; }

    glm::vec3 voxelSize() const { return (_bbox[1] - _bbox[0]) / (glm::vec3)_steps; }

    void toVoxelIndices(sptr<CudaArray<int>> gi, sptr<CudaArray<int>> o_vi) const;

private:
    glm::vec3 _bbox[2];
    glm::ivec3 _steps;
    sptr<CudaArray<glm::vec3>> _voxels;
    sptr<CudaArray<int>> _cornerIndices;
    sptr<CudaArray<glm::vec3>> _corners;
    sptr<CudaArray<int>> _voxelIndicesInGrid;
};