VOXELRENDER: extract into method

master
Martin Gerhardy 2022-04-23 21:08:10 +02:00
parent 3234e2e5b1
commit 9d85d3b842
2 changed files with 13 additions and 5 deletions

View File

@ -52,6 +52,11 @@ static inline int volumeId(const voxelformat::SceneGraphNode &node) {
return node.id();
}
static inline int nodeId(int volumeIdx) {
// TODO: using the node id here is not good as they are increasing when you modify the scene graph
return volumeIdx;
}
bool SceneGraphRenderer::empty(voxelformat::SceneGraphNode &node) {
return _renderer.empty(volumeId(node));
}
@ -83,8 +88,9 @@ void SceneGraphRenderer::shutdown() {
void SceneGraphRenderer::clear() {
_renderer.clearPendingExtractions();
for (int i = 0; i < RawVolumeRenderer::MAX_VOLUMES; ++i) {
if (_renderer.setVolume(i, nullptr, true) != nullptr) {
_renderer.updateBufferForVolume(i);
const int nId = nodeId(i);
if (_renderer.setVolume(nId, nullptr, true) != nullptr) {
_renderer.updateBufferForVolume(nId);
}
}
}
@ -92,9 +98,9 @@ void SceneGraphRenderer::clear() {
void SceneGraphRenderer::prepare(voxelformat::SceneGraph &sceneGraph, uint32_t frame, bool hideInactive, bool grayInactive) {
// remove those volumes that are no longer part of the scene graph
for (int i = 0; i < RawVolumeRenderer::MAX_VOLUMES; ++i) {
// TODO: using the node id here is not good as they are increasing when you modify the scene graph
if (!sceneGraph.hasNode(i)) {
_renderer.setVolume(i, nullptr, true);
const int nId = nodeId(i);
if (!sceneGraph.hasNode(nId)) {
_renderer.setVolume(nId, nullptr, true);
}
}

View File

@ -307,6 +307,8 @@ bool SceneManager::load(const core::String& file) {
io::FileStream stream(filePtr);
voxelformat::loadFormat(filePtr->name(), stream, newSceneGraph);
mergeIfNeeded(newSceneGraph);
// TODO: stuff that happens in RawVolumeRenderer::extractRegion and
// RawVolumeRenderer::scheduleExtractions should happen here
return core::move(newSceneGraph);
});
_lastFilename = filePtr->fileName() + "." + filePtr->extension();