Skip to content

Commit

Permalink
VOXELFORMAT: THING: add parent for media node
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Jan 13, 2025
1 parent 85666b7 commit f45288c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/modules/voxelformat/private/rooms/ThingFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static scenegraph::SceneGraphTransform toTransform(const voxel::Region &region,
}

bool ThingFormat::addMediaImage(const io::ArchivePtr &archive, const NodeSpec &nodeSpec,
scenegraph::SceneGraph &sceneGraph) {
scenegraph::SceneGraph &sceneGraph, int parent) {
if (nodeSpec.mediaName.empty()) {
Log::debug("No media name found");
return false;
Expand Down Expand Up @@ -87,8 +87,8 @@ bool ThingFormat::addMediaImage(const io::ArchivePtr &archive, const NodeSpec &n
const scenegraph::SceneGraphTransform &transform =
toTransform(mediaNode.region(), mediaCanvas.localPos, mediaCanvas.localRot, mediaCanvas.localScale, 1.0f);
mediaNode.setTransform(keyFrameIdx, transform);
Log::debug("ThingFormat: Import media plane: %s", nodeSpec.mediaName.c_str());
return sceneGraph.emplace(core::move(mediaNode)) != InvalidNodeId;
Log::debug("ThingFormat: Import media plane: %s with parent %i", nodeSpec.mediaName.c_str(), parent);
return sceneGraph.emplace(core::move(mediaNode), parent) != InvalidNodeId;
}
Log::error("ThingFormat: Failed to import media plane: %s", nodeSpec.mediaName.c_str());
return false;
Expand Down Expand Up @@ -131,12 +131,13 @@ bool ThingFormat::loadNode(const io::ArchivePtr &archive, const NodeSpec &nodeSp
palette.setColor(i, rgba);
}
}
addMediaImage(archive, nodeSpec, voxSceneGraph);
addMediaImage(archive, nodeSpec, voxSceneGraph, parent);
const core::DynamicArray<int> &nodes = scenegraph::copySceneGraph(sceneGraph, voxSceneGraph, parent);
if (nodes.empty()) {
Log::error("ThingFormat: Failed to copy the scene graph from node %s", nodeSpec.modelName.c_str());
return false;
}
Log::debug("Load %i children for %s", (int)nodeSpec.children.size(), nodeSpec.modelName.c_str());
for (const NodeSpec &child : nodeSpec.children) {
if (!loadNode(archive, child, sceneGraph, ctx, nodes[0])) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/voxelformat/private/rooms/ThingFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace voxelformat {
class ThingFormat : public Format {
private:
bool loadNodeSpec(io::SeekableReadStream &stream, NodeSpec &nodeSpec) const;
bool addMediaImage(const io::ArchivePtr &archive, const NodeSpec &nodeSpec, scenegraph::SceneGraph &sceneGraph);
bool addMediaImage(const io::ArchivePtr &archive, const NodeSpec &nodeSpec, scenegraph::SceneGraph &sceneGraph, int parent);
bool loadNode(const io::ArchivePtr &archive, const NodeSpec &nodeSpec, scenegraph::SceneGraph &sceneGraph,
const LoadContext &ctx, int parent = 0);

Expand Down

0 comments on commit f45288c

Please sign in to comment.