Enhance node creation command to include optional parent ID and update logging
This commit is contained in:
@@ -38,7 +38,7 @@ impl Default for BridgeState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum Command {
|
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 },
|
Update { c_id: u64, transform: Mat4 },
|
||||||
SetModel { c_id: u64, model_url: String },
|
SetModel { c_id: u64, model_url: String },
|
||||||
SetTexture { c_id: u64, texture_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());
|
static ref CTRL: Mutex<Ctrl> = Mutex::new(Ctrl::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, serde::Serialize, serde::Deserialize)]
|
||||||
struct Node {
|
struct Node {
|
||||||
id: u64,
|
id: u64,
|
||||||
name: String,
|
name: String,
|
||||||
|
parent: Option<u64>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
transform: Mat4,
|
transform: Mat4,
|
||||||
entity_type: u8, // 0=Unknown, 1=Box, 2=Sphere, 3=Model, etc.
|
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 {
|
let cmd_task = tokio::spawn(async move {
|
||||||
while let Some(cmd) = rx.recv().await {
|
while let Some(cmd) = rx.recv().await {
|
||||||
match cmd {
|
match cmd {
|
||||||
Command::Create { c_id, name, transform } => {
|
Command::Create { c_id, name, parent, transform } => {
|
||||||
if let Ok(mut state) = shared_for_commands.lock() {
|
if let Ok(mut state) = shared_for_commands.lock() {
|
||||||
let node = Node {
|
let node = Node {
|
||||||
id: c_id,
|
id: c_id,
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
|
parent,
|
||||||
transform,
|
transform,
|
||||||
entity_type: 1, // Default to Box
|
entity_type: 1, // Default to Box
|
||||||
model_url: String::new(),
|
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
|
dimensions: [0.1, 0.1, 0.1], // Default 10cm cube
|
||||||
};
|
};
|
||||||
state.nodes.insert(c_id, node);
|
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 } => {
|
Command::Update { c_id, transform } => {
|
||||||
|
|||||||
Reference in New Issue
Block a user