VOXELRENDER: prevent scheduling empty volumes for mesh extraction
parent
057f35b12c
commit
141e5ebd5a
|
@ -44,12 +44,15 @@ RawVolume::RawVolume(const RawVolume& copy) :
|
|||
core_memcpy((void*)_data, (void*)copy._data, size);
|
||||
}
|
||||
|
||||
RawVolume::RawVolume(const RawVolume& src, const Region& region) : _region(region) {
|
||||
RawVolume::RawVolume(const RawVolume& src, const Region& region, bool *onlyAir) : _region(region) {
|
||||
setBorderValue(src.borderValue());
|
||||
_borderVoxel = src._borderVoxel;
|
||||
if (!src.region().containsRegion(_region)) {
|
||||
_region.cropTo(src._region);
|
||||
}
|
||||
if (onlyAir) {
|
||||
*onlyAir = true;
|
||||
}
|
||||
const size_t size = width() * height() * depth() * sizeof(Voxel);
|
||||
_data = (Voxel *)core_malloc(size);
|
||||
if (src.region() == _region) {
|
||||
|
@ -82,6 +85,10 @@ RawVolume::RawVolume(const RawVolume& src, const Region& region) : _region(regio
|
|||
const int tgtindex = tgtStrideLocal + tgtZPos * tgtZStride;
|
||||
const int srcindex = srcStrideLocal + srcZPos * srcZStride;
|
||||
_data[tgtindex] = src._data[srcindex];
|
||||
if (onlyAir && !voxel::isAir(_data[tgtindex].getMaterial())) {
|
||||
*onlyAir = false;
|
||||
onlyAir = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
RawVolume(const RawVolume* copy);
|
||||
RawVolume(const RawVolume& copy);
|
||||
RawVolume(RawVolume&& move) noexcept;
|
||||
RawVolume(const RawVolume& copy, const Region& region);
|
||||
RawVolume(const RawVolume& copy, const Region& region, bool *onlyAir = nullptr);
|
||||
|
||||
static RawVolume* createRaw(const Voxel* data, const voxel::Region& region) {
|
||||
return new RawVolume(data, region);
|
||||
|
|
|
@ -149,7 +149,11 @@ bool RawVolumeRenderer::scheduleExtractions(size_t maxExtraction) {
|
|||
}
|
||||
const voxel::RawVolume *volume = _state[idx]._rawVolume;
|
||||
const voxel::Region& finalRegion = _extractRegions[i].region;
|
||||
voxel::RawVolume copy(volume, voxel::Region(finalRegion.getLowerCorner() - 2, finalRegion.getUpperCorner() + 2));
|
||||
bool onlyAir = true;
|
||||
voxel::RawVolume copy(volume, voxel::Region(finalRegion.getLowerCorner() - 2, finalRegion.getUpperCorner() + 2), &onlyAir);
|
||||
if (onlyAir) {
|
||||
continue;
|
||||
}
|
||||
const glm::ivec3& mins = finalRegion.getLowerCorner();
|
||||
_threadPool.enqueue([movedCopy = core::move(copy), mins, idx, finalRegion, this] () {
|
||||
++_runningExtractorTasks;
|
||||
|
|
Loading…
Reference in New Issue