Add parent ID parameter to node creation functions in Rust and C++
This commit is contained in:
@@ -544,7 +544,8 @@ pub extern "C" fn sdxr_shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn sdxr_create_node(name: *const std::os::raw::c_char, mat4: *const f32) -> u64 {
|
#[no_mangle]
|
||||||
|
pub extern "C" fn sdxr_create_node(name: *const std::os::raw::c_char, mat4: *const f32, parent_id: u64) -> u64 {
|
||||||
if !STARTED.load(Ordering::SeqCst) { return 0; }
|
if !STARTED.load(Ordering::SeqCst) { return 0; }
|
||||||
let name = unsafe { CStr::from_ptr(name) }.to_string_lossy().to_string();
|
let name = unsafe { CStr::from_ptr(name) }.to_string_lossy().to_string();
|
||||||
let m = unsafe { std::slice::from_raw_parts(mat4, 16) };
|
let m = unsafe { std::slice::from_raw_parts(mat4, 16) };
|
||||||
@@ -554,7 +555,8 @@ pub extern "C" fn sdxr_create_node(name: *const std::os::raw::c_char, mat4: *con
|
|||||||
|
|
||||||
let mut ctrl = CTRL.lock().unwrap();
|
let mut ctrl = CTRL.lock().unwrap();
|
||||||
let c_id = ctrl.next_id; ctrl.next_id += 1;
|
let c_id = ctrl.next_id; ctrl.next_id += 1;
|
||||||
if let Some(tx) = &ctrl.tx { let _ = tx.send(Command::Create { c_id, name, transform: mat }); }
|
let parent = if parent_id == 0 { None } else { Some(parent_id) };
|
||||||
|
if let Some(tx) = &ctrl.tx { let _ = tx.send(Command::Create { c_id, name, parent, transform: mat }); }
|
||||||
c_id
|
c_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,8 @@ StardustBridge::NodeId StardustBridge::createNode(const std::string& name,
|
|||||||
float m[16];
|
float m[16];
|
||||||
// GLM mat4 is column-major; pass as 16 floats as-is
|
// GLM mat4 is column-major; pass as 16 floats as-is
|
||||||
std::memcpy(m, &transform[0][0], sizeof(m));
|
std::memcpy(m, &transform[0][0], sizeof(m));
|
||||||
std::uint64_t rid = m_fnCreateNode(name.c_str(), m);
|
std::uint64_t parentVal = parent.has_value() ? *parent : 0;
|
||||||
|
std::uint64_t rid = m_fnCreateNode(name.c_str(), m, parentVal);
|
||||||
(void)rid; // Could map to NodeId if Rust returns its own id
|
(void)rid; // Could map to NodeId if Rust returns its own id
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ private:
|
|||||||
using fn_start_t = int(*)(const char*);
|
using fn_start_t = int(*)(const char*);
|
||||||
using fn_poll_t = int(*)();
|
using fn_poll_t = int(*)();
|
||||||
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*, std::uint64_t);
|
||||||
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);
|
using fn_remove_node_t = int(*)(std::uint64_t);
|
||||||
using fn_set_model_t = int(*)(std::uint64_t, const char*);
|
using fn_set_model_t = int(*)(std::uint64_t, const char*);
|
||||||
|
|||||||
Reference in New Issue
Block a user