mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-07 09:00:06 +02:00
Fix for clearing empty nodes.
This commit is contained in:
parent
34cba5c031
commit
ef0a400dcb
1 changed files with 41 additions and 37 deletions
|
@ -1049,18 +1049,13 @@ int HeightfieldClearFetchVisitor::visit(MetavoxelInfo& info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if all is gone, clear the node
|
// if all is gone, clear the node
|
||||||
if (!foundNonZero) {
|
if (foundNonZero) {
|
||||||
info.outputValues[0] = AttributeValue(_outputs.at(0),
|
HeightfieldHeightDataPointer newHeightPointer(new HeightfieldHeightData(contents));
|
||||||
encodeInline<HeightfieldHeightDataPointer>(HeightfieldHeightDataPointer()));
|
info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline<HeightfieldHeightDataPointer>(newHeightPointer));
|
||||||
info.outputValues[1] = AttributeValue(_outputs.at(1),
|
|
||||||
encodeInline<HeightfieldColorDataPointer>(HeightfieldColorDataPointer()));
|
|
||||||
info.outputValues[2] = AttributeValue(_outputs.at(2),
|
|
||||||
encodeInline<HeightfieldMaterialDataPointer>(HeightfieldMaterialDataPointer()));
|
|
||||||
return STOP_RECURSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
HeightfieldHeightDataPointer newHeightPointer(new HeightfieldHeightData(contents));
|
} else {
|
||||||
info.outputValues[0] = AttributeValue(_outputs.at(0), encodeInline<HeightfieldHeightDataPointer>(newHeightPointer));
|
info.outputValues[0] = AttributeValue(_outputs.at(0));
|
||||||
|
}
|
||||||
|
|
||||||
// allow a border for what we clear in terms of color/material
|
// allow a border for what we clear in terms of color/material
|
||||||
innerBounds.minimum.x += increment;
|
innerBounds.minimum.x += increment;
|
||||||
|
@ -1090,19 +1085,24 @@ int HeightfieldClearFetchVisitor::visit(MetavoxelInfo& info) {
|
||||||
memcpy(dest, src, destWidth * DataBlock::COLOR_BYTES);
|
memcpy(dest, src, destWidth * DataBlock::COLOR_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
destX = (innerOverlap.minimum.x - info.minimum.x) * heightScale;
|
if (foundNonZero) {
|
||||||
destY = (innerOverlap.minimum.z - info.minimum.z) * heightScale;
|
destX = (innerOverlap.minimum.x - info.minimum.x) * heightScale;
|
||||||
destWidth = glm::ceil((innerOverlap.maximum.x - innerOverlap.minimum.x) * heightScale);
|
destY = (innerOverlap.minimum.z - info.minimum.z) * heightScale;
|
||||||
destHeight = glm::ceil((innerOverlap.maximum.z - innerOverlap.minimum.z) * heightScale);
|
destWidth = glm::ceil((innerOverlap.maximum.x - innerOverlap.minimum.x) * heightScale);
|
||||||
if (destWidth > 0 && destHeight > 0) {
|
destHeight = glm::ceil((innerOverlap.maximum.z - innerOverlap.minimum.z) * heightScale);
|
||||||
dest = contents.data() + (destY * size + destX) * DataBlock::COLOR_BYTES;
|
if (destWidth > 0 && destHeight > 0) {
|
||||||
|
dest = contents.data() + (destY * size + destX) * DataBlock::COLOR_BYTES;
|
||||||
|
|
||||||
for (int y = 0; y < destHeight; y++, dest += size * DataBlock::COLOR_BYTES) {
|
for (int y = 0; y < destHeight; y++, dest += size * DataBlock::COLOR_BYTES) {
|
||||||
memset(dest, 0, destWidth * DataBlock::COLOR_BYTES);
|
memset(dest, 0, destWidth * DataBlock::COLOR_BYTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
HeightfieldColorDataPointer newColorPointer(new HeightfieldColorData(contents));
|
||||||
|
info.outputValues[1] = AttributeValue(_outputs.at(1),
|
||||||
|
encodeInline<HeightfieldColorDataPointer>(newColorPointer));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
HeightfieldColorDataPointer newColorPointer(new HeightfieldColorData(contents));
|
info.outputValues[1] = AttributeValue(_outputs.at(1));
|
||||||
info.outputValues[1] = AttributeValue(_outputs.at(1), encodeInline<HeightfieldColorDataPointer>(newColorPointer));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1139,21 +1139,25 @@ int HeightfieldClearFetchVisitor::visit(MetavoxelInfo& info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destX = (innerOverlap.minimum.x - info.minimum.x) * heightScale;
|
if (foundNonZero) {
|
||||||
destY = (innerOverlap.minimum.z - info.minimum.z) * heightScale;
|
destX = (innerOverlap.minimum.x - info.minimum.x) * heightScale;
|
||||||
destWidth = glm::ceil((innerOverlap.maximum.x - innerOverlap.minimum.x) * heightScale);
|
destY = (innerOverlap.minimum.z - info.minimum.z) * heightScale;
|
||||||
destHeight = glm::ceil((innerOverlap.maximum.z - innerOverlap.minimum.z) * heightScale);
|
destWidth = glm::ceil((innerOverlap.maximum.x - innerOverlap.minimum.x) * heightScale);
|
||||||
if (destWidth > 0 && destHeight > 0) {
|
destHeight = glm::ceil((innerOverlap.maximum.z - innerOverlap.minimum.z) * heightScale);
|
||||||
dest = (uchar*)contents.data() + destY * size + destX;
|
if (destWidth > 0 && destHeight > 0) {
|
||||||
|
dest = (uchar*)contents.data() + destY * size + destX;
|
||||||
|
|
||||||
for (int y = 0; y < destHeight; y++, dest += size) {
|
for (int y = 0; y < destHeight; y++, dest += size) {
|
||||||
memset(dest, 0, destWidth);
|
memset(dest, 0, destWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearUnusedMaterials(materials, contents);
|
||||||
|
HeightfieldMaterialDataPointer newMaterialPointer(new HeightfieldMaterialData(contents, materials));
|
||||||
|
info.outputValues[2] = AttributeValue(_outputs.at(2),
|
||||||
|
encodeInline<HeightfieldMaterialDataPointer>(newMaterialPointer));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
clearUnusedMaterials(materials, contents);
|
info.outputValues[2] = AttributeValue(_outputs.at(2));
|
||||||
HeightfieldMaterialDataPointer newMaterialPointer(new HeightfieldMaterialData(contents, materials));
|
|
||||||
info.outputValues[2] = AttributeValue(_outputs.at(2),
|
|
||||||
encodeInline<HeightfieldMaterialDataPointer>(newMaterialPointer));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue