Enhance node creation command to include optional parent ID and update logging

This commit is contained in:
MayaTheShy
2025-11-16 22:07:26 -05:00
parent 891d82c1de
commit 8be82ca505

View File

@@ -38,7 +38,7 @@ impl Default for BridgeState {
}
enum Command {
Create { c_id: u64, name: String, transform: Mat4 },
Create { c_id: u64, name: String, parent: Option<u64>, transform: Mat4 },
Update { c_id: u64, transform: Mat4 },
SetModel { c_id: u64, model_url: String },
SetTexture { c_id: u64, texture_url: String },
@@ -255,10 +255,11 @@ lazy_static::lazy_static! {
static ref CTRL: Mutex<Ctrl> = Mutex::new(Ctrl::default());
}
#[derive(Default, Clone, serde::Serialize, serde::Deserialize)]
#[derive(Clone, serde::Serialize, serde::Deserialize)]
struct Node {
id: u64,
name: String,
parent: Option<u64>,
#[serde(skip)]
transform: Mat4,
entity_type: u8, // 0=Unknown, 1=Box, 2=Sphere, 3=Model, etc.
@@ -322,11 +323,12 @@ pub extern "C" fn sdxr_start(app_id: *const std::os::raw::c_char) -> i32 {
let cmd_task = tokio::spawn(async move {
while let Some(cmd) = rx.recv().await {
match cmd {
Command::Create { c_id, name, transform } => {
Command::Create { c_id, name, parent, transform } => {
if let Ok(mut state) = shared_for_commands.lock() {
let node = Node {
id: c_id,
name: name.clone(),
parent,
transform,
entity_type: 1, // Default to Box
model_url: String::new(),
@@ -335,7 +337,7 @@ pub extern "C" fn sdxr_start(app_id: *const std::os::raw::c_char) -> i32 {
dimensions: [0.1, 0.1, 0.1], // Default 10cm cube
};
state.nodes.insert(c_id, node);
println!("[bridge] create node id={} name={} (state nodes={})", c_id, name, state.nodes.len());
println!("[bridge] create node id={} name={} parent={:?} (state nodes={})", c_id, name, parent, state.nodes.len());
}
}
Command::Update { c_id, transform } => {