feat: add removeNode function to StardustBridge for node deletion

This commit is contained in:
MayaTheShy
2025-11-08 16:00:11 -05:00
parent 32412f6525
commit d0ca78acc1
2 changed files with 16 additions and 0 deletions

View File

@@ -161,6 +161,16 @@ bool StardustBridge::updateNodeTransform(NodeId id, const glm::mat4& transform)
return true;
}
bool StardustBridge::removeNode(NodeId id) {
auto it = m_nodes.find(id);
if (it == m_nodes.end()) return false;
m_nodes.erase(it);
if (m_fnRemoveNode) {
(void)m_fnRemoveNode(id);
}
return true;
}
void StardustBridge::poll() {
if (!m_connected) return;
@@ -237,6 +247,7 @@ bool StardustBridge::loadBridge() {
m_fnShutdown = reinterpret_cast<fn_shutdown_t>(req("sdxr_shutdown"));
m_fnCreateNode = reinterpret_cast<fn_create_node_t>(req("sdxr_create_node"));
m_fnUpdateNode = reinterpret_cast<fn_update_node_t>(req("sdxr_update_node"));
m_fnRemoveNode = reinterpret_cast<fn_remove_node_t>(req("sdxr_remove_node"));
if (m_fnStart && m_fnPoll && m_fnCreateNode && m_fnUpdateNode) {
m_bridgeHandle = h;
std::cout << "[StardustBridge] Loaded Rust bridge: " << path << std::endl;

View File

@@ -28,6 +28,9 @@ public:
// Update a node's transform. Returns false if the node doesn't exist.
bool updateNodeTransform(NodeId id, const glm::mat4& transform);
// Remove a node. Returns false if the node doesn't exist.
bool removeNode(NodeId id);
// Poll compositor events and input. Non-blocking.
void poll();
@@ -77,11 +80,13 @@ private:
using fn_shutdown_t = void(*)();
using fn_create_node_t = std::uint64_t(*)(const char*, const float*);
using fn_update_node_t = int(*)(std::uint64_t, const float*);
using fn_remove_node_t = int(*)(std::uint64_t);
fn_start_t m_fnStart{nullptr};
fn_poll_t m_fnPoll{nullptr};
fn_shutdown_t m_fnShutdown{nullptr};
fn_create_node_t m_fnCreateNode{nullptr};
fn_update_node_t m_fnUpdateNode{nullptr};
fn_remove_node_t m_fnRemoveNode{nullptr};
bool loadBridge();
};