feat: add removeNode function to StardustBridge for node deletion
This commit is contained in:
@@ -161,6 +161,16 @@ bool StardustBridge::updateNodeTransform(NodeId id, const glm::mat4& transform)
|
|||||||
return true;
|
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() {
|
void StardustBridge::poll() {
|
||||||
if (!m_connected) return;
|
if (!m_connected) return;
|
||||||
|
|
||||||
@@ -237,6 +247,7 @@ bool StardustBridge::loadBridge() {
|
|||||||
m_fnShutdown = reinterpret_cast<fn_shutdown_t>(req("sdxr_shutdown"));
|
m_fnShutdown = reinterpret_cast<fn_shutdown_t>(req("sdxr_shutdown"));
|
||||||
m_fnCreateNode = reinterpret_cast<fn_create_node_t>(req("sdxr_create_node"));
|
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_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) {
|
if (m_fnStart && m_fnPoll && m_fnCreateNode && m_fnUpdateNode) {
|
||||||
m_bridgeHandle = h;
|
m_bridgeHandle = h;
|
||||||
std::cout << "[StardustBridge] Loaded Rust bridge: " << path << std::endl;
|
std::cout << "[StardustBridge] Loaded Rust bridge: " << path << std::endl;
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ public:
|
|||||||
// Update a node's transform. Returns false if the node doesn't exist.
|
// Update a node's transform. Returns false if the node doesn't exist.
|
||||||
bool updateNodeTransform(NodeId id, const glm::mat4& transform);
|
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.
|
// Poll compositor events and input. Non-blocking.
|
||||||
void poll();
|
void poll();
|
||||||
|
|
||||||
@@ -77,11 +80,13 @@ private:
|
|||||||
using fn_shutdown_t = void(*)();
|
using fn_shutdown_t = void(*)();
|
||||||
using fn_create_node_t = std::uint64_t(*)(const char*, const float*);
|
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_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_start_t m_fnStart{nullptr};
|
||||||
fn_poll_t m_fnPoll{nullptr};
|
fn_poll_t m_fnPoll{nullptr};
|
||||||
fn_shutdown_t m_fnShutdown{nullptr};
|
fn_shutdown_t m_fnShutdown{nullptr};
|
||||||
fn_create_node_t m_fnCreateNode{nullptr};
|
fn_create_node_t m_fnCreateNode{nullptr};
|
||||||
fn_update_node_t m_fnUpdateNode{nullptr};
|
fn_update_node_t m_fnUpdateNode{nullptr};
|
||||||
|
fn_remove_node_t m_fnRemoveNode{nullptr};
|
||||||
|
|
||||||
bool loadBridge();
|
bool loadBridge();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user