I2375 added active voxels in volume render#1630
Conversation
| const VoxelBitSet& getVolumeRenderActiveVoxels() const { return volumeRenderActiveVoxels_; } | ||
| MRMESH_API void setVolumeRenderActiveVoxels( const VoxelBitSet& activeVoxels ); |
| volumeRenderActiveVoxels_.clear(); | ||
| auto newDims = activeBox_.size(); | ||
| volumeRenderActiveVoxels_.resize( newDims.x * newDims.y * newDims.z, true ); | ||
| dirty_ |= DIRTY_SELECTION; |
There was a problem hiding this comment.
why make it here? better in prepareDataForVolumeRendering
There was a problem hiding this comment.
we change active box, it can change box size, so if we try to get active voxels, we will get wrong data
source/MRMesh/MRObjectVoxels.cpp
Outdated
| volumeRenderActiveVoxels_.clear(); | ||
| volumeRenderActiveVoxels_.resize( vdbVolume_.dims.x * vdbVolume_.dims.y * vdbVolume_.dims.z, true ); |
There was a problem hiding this comment.
if we construct object after creating and try get active voxels, we don't expect empty bitset
source/MRMesh/MRObjectVoxels.cpp
Outdated
| volumeRenderActiveVoxels_.clear(); | ||
| volumeRenderActiveVoxels_.resize( vdbVolume_.dims.x * vdbVolume_.dims.y * vdbVolume_.dims.z, true ); |
| namespace MR | ||
| { | ||
| class RenderVolumeObject : public IRenderObject | ||
| class MRVIEWER_CLASS RenderVolumeObject : public IRenderObject |
There was a problem hiding this comment.
do we need export this class?
There was a problem hiding this comment.
why we don't need this (unlike others object classes)?
| protected: | ||
| Vector2i activeVoxelsTextureSize_; | ||
|
|
||
| MRVIEWER_API RenderBufferRef<unsigned> loadActiveVoxelsTextureBuffer_(); | ||
|
|
||
| GlTexture2 activeVoxelsTex_; | ||
| int maxTexSize_{ 0 }; |
| uint dimsXY = uint( dims.y * dims.x ); | ||
| uint dimsX = uint( dims.x ); |
There was a problem hiding this comment.
| uint dimsXY = uint( dims.y * dims.x ); | |
| uint dimsX = uint( dims.x ); | |
| uint volumeSize = uint( dims.z *dims.y * dims.x ); | |
| uint dimsXY = uint( dims.y*dims.x ); |
|
|
||
| { | ||
| ivec2 texSize = textureSize( activeVoxels, 0 ); | ||
| uint voxelId = uint( textCoord.z * dims.z ) * dimsXY + uint( textCoord.y * dims.y ) * dimsX + uint( textCoord.x * dims.x ); |
There was a problem hiding this comment.
| uint voxelId = uint( textCoord.z * dims.z ) * dimsXY + uint( textCoord.y * dims.y ) * dimsX + uint( textCoord.x * dims.x ); | |
| uint voxelId = uint( textCoord.z * volumeSize ) + uint( textCoord.y * dimsXY ) + uint( textCoord.x * dims.x ); |
There was a problem hiding this comment.
textCoord is not voxel center (textCoord = voxelCenter + smallShift)
so uint( textCoord.z * volumeSize ) have additional error
There was a problem hiding this comment.
there can be uint overflow for big volumes voxel index it makes sanse to calculate voxel index directly
No description provided.