VOXELFORMAT: fixed segfaul in vox format saving

master
Martin Gerhardy 2022-04-29 17:58:37 +02:00
parent 1447cb34e9
commit f36e3a20e9
2 changed files with 8 additions and 0 deletions

View File

@ -75,6 +75,10 @@ void Format::splitVolumes(const SceneGraph& srcSceneGraph, SceneGraph& destScene
destSceneGraph.reserve(srcSceneGraph.size());
for (SceneGraphNode &node : srcSceneGraph) {
const voxel::Region& region = node.region();
if (!region.isValid()) {
Log::debug("invalid region for node %i", node.id());
continue;
}
if (glm::all(glm::lessThan(region.getDimensionsInVoxels(), maxSize))) {
SceneGraphNode newNode;
newNode.setVolume(new voxel::RawVolume(node.volume()), true);

View File

@ -312,6 +312,10 @@ bool VoxFormat::saveGroups(const SceneGraph &sceneGraph, const core::String &fil
const int replacement = findClosestPaletteIndex();
const size_t modelCount = newSceneGraph.size();
if (modelCount == 0) {
Log::error("No model nodes found in scene graph");
return false;
}
core::Buffer<ogt_vox_model> models(modelCount);
core::Buffer<ogt_vox_layer> layers(modelCount);
core::Buffer<ogt_vox_instance> instances(modelCount);