Compare commits

7 Commits

Author SHA1 Message Date
MayaTheShy
95f8091f20 Resolve merge conflict in bridge/src/lib.rs: keep color tinting logic for models
Some checks failed
CI / build-and-test (push) Has been cancelled
Rust Quality Checks / rust-checks (push) Has been cancelled
2025-11-16 22:39:38 -05:00
MayaTheShy
16d68caf83 Add future risk surface and priorities section to documentation (moved from feature branch) 2025-11-16 22:36:52 -05:00
MayaTheShy
29d9d02f65 Add future risk surface and priorities section to README 2025-11-16 22:35:33 -05:00
0a39697599 Entity Color/Material Protocol Support & Model Cache Robustness
Some checks failed
CI / build-and-test (push) Has been cancelled
Rust Quality Checks / rust-checks (push) Has been cancelled
- Add support for entity color and texture fields in the bridge protocol and node state.
- Log and document color/material override attempts; actual application is blocked by missing upstream API.
- Use robust model cache directory logic:
  - Prefer OS cache dir, fallback to /tmp if unavailable.
  - Prepare for future improvements (logging, user-specific /tmp, directory creation).
- Update documentation to reflect current limitations and future roadmap.
- No breaking changes; all new logic is forward-compatible and safe for merge.
2025-11-17 02:43:16 +00:00
MayaTheShy
bc330e7a40 Update color tint application in Reify implementation to reflect current limitations
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
Rust Quality Checks / rust-checks (pull_request) Has been cancelled
2025-11-16 21:35:04 -05:00
MayaTheShy
d5d0637948 Update stardust-xr-molecules source to latest commit for improved stability 2025-11-16 21:33:12 -05:00
MayaTheShy
8cb859e873 Enhance model color tint application in Reify implementation 2025-11-16 21:26:12 -05:00
5 changed files with 118 additions and 48 deletions

View File

@@ -335,6 +335,36 @@ This allows you to:
## Roadmap
## Future Risk Surface & Priorities (612 Months)
Starworlds current architecture is robust for small to moderate scenes, but as the project grows, several risks and challenges will become increasingly important:
### Key Risks
- **Performance Scaling:** Scene complexity will make O(n) transform updates and distance queries a bottleneck. Deep hierarchies and lack of spatial indexing will limit scalability.
- **Memory/Data Layout:** Inefficient memory layout or fragmentation from dynamic hierarchies can degrade performance.
- **Concurrency & Synchronization:** If/when multithreading is introduced, unsynchronized updates and queries could cause race conditions or data corruption.
- **Lifecycle & Ownership:** Deletion and reparenting in hierarchies can cause dangling references or orphaned children, especially across FFI boundaries.
- **API Misuse:** Cycles or invalid parent/child states can cause subtle bugs or crashes if not checked.
- **Spatial Query Correctness:** Queries may become stale or incorrect if transforms are not updated atomically.
- **XR Performance:** High frame rates and low latency are critical; entity and query systems must be highly optimized.
- **Security/Authority:** In multi-user/networked scenarios, lack of permissions or rate-limiting could allow abuse.
- **Extensibility:** As more systems (physics, networking, etc.) are added, poor separation of concerns could hinder future growth.
- **Testing/Debugging:** More features and edge cases will make testing and debugging harder without good tools.
### Recommended Priorities
- **Implement/Optimize Spatial Indexing:** Integrate a spatial data structure (octree, k-d tree, etc.) for fast queries. Update incrementally as entities move.
- **Optimize Hierarchy Traversal:** Use dirty flags for transforms and consider breadth-first traversal for deep hierarchies.
- **Enforce Lifecycle Invariants:** Prevent cycles, define deletion/reparenting behavior, and add runtime checks.
- **Audit FFI Boundaries:** Ensure safe memory and ownership across Rust/C++.
- **Plan for Concurrency:** Design for thread safety and test with simulated concurrent updates/queries.
- **Document & Harden API:** Clearly document constraints and provide safe helpers/utilities.
- **XR-Specific Profiling:** Benchmark with XR workloads and optimize for frame time and memory.
- **Security & Authority:** Add permission models and rate-limiting for entity operations in multi-user mode.
- **Expand Testing & Tooling:** Add deep hierarchy/reparenting tests, fuzzing, and scene graph/query inspectors.
- **Architectural Planning:** Plan for modularity and extensibility to support future systems cleanly.
**Bottom line:** Proactively addressing these areas will ensure Starworld remains performant, safe, and extensible as it grows.
### Phase 1: Core Rendering ✅ COMPLETE
- [x] Entity type differentiation
- [x] **3D model rendering with GLTF/GLB** 🎉

2
bridge/Cargo.lock generated
View File

@@ -2823,7 +2823,7 @@ dependencies = [
[[package]]
name = "stardust-xr-molecules"
version = "0.45.0"
source = "git+https://github.com/StardustXR/molecules.git?branch=dev#53cfb2eecb066faf60a1b0da0b70f84231bae2be"
source = "git+https://github.com/StardustXR/molecules.git?branch=dev#26e004af199ccccb2ff4d8662f82f4d65311d8d3"
dependencies = [
"ashpd",
"futures-util",

View File

@@ -168,6 +168,7 @@ impl Reify for BridgeState {
entity_type_name, id, model_source);
match Model::direct(&model_path) {
<<<<<<< HEAD
Ok(mut model) => {
// Asteroids Model now supports material color tinting.
if node.color != [1.0, 1.0, 1.0, 1.0] {
@@ -180,11 +181,24 @@ impl Reify for BridgeState {
}
// TODO: Apply texture from texture_url (pending API)
=======
Ok(model) => {
// TODO: Color tinting is not currently supported due to missing public API in asteroids.
// When Model/MaterialParameter API is available, apply color here.
if node.color != [1.0, 1.0, 1.0, 1.0] {
eprintln!("[bridge/reify] Node {} requested color tint RGBA({:.2}, {:.2}, {:.2}, {:.2}) -- NOT SUPPORTED YET",
id, node.color[0], node.color[1], node.color[2], node.color[3]);
}
// TODO: Apply texture from texture_url (future)
>>>>>>> 0a39697599277320e2650a938b695beeb401c931
if !node.texture_url.is_empty() {
eprintln!("[bridge/reify] Node {} has texture URL: {} - NOT YET APPLIED (API limitation)",
id, node.texture_url);
}
<<<<<<< HEAD
=======
>>>>>>> 0a39697599277320e2650a938b695beeb401c931
Some(model.build())
}
Err(e) => {
@@ -217,49 +231,28 @@ lazy_static::lazy_static! {
struct Node {
id: u64,
name: String,
#[serde(skip)]
transform: Mat4,
entity_type: u8, // 0=Unknown, 1=Box, 2=Sphere, 3=Model, etc.
model_url: String,
texture_url: String,
#[serde(skip)]
color: [f32; 4], // RGBA
#[serde(skip)]
dimensions: [f32; 3], // xyz dimensions in meters
}
Ok(mut model) => {
// Asteroids Model now supports material color tinting.
if node.color != [1.0, 1.0, 1.0, 1.0] {
let color = ast::elements::RgbaLinear::new(
node.color[0], node.color[1], node.color[2], node.color[3]
);
model = model.color_tint(color);
eprintln!("[bridge/reify] Node {}: applied color tint RGBA({:.2}, {:.2}, {:.2}, {:.2})",
id, node.color[0], node.color[1], node.color[2], node.color[3]);
}
struct Ctrl {
rt: Option<Runtime>,
handle: Option<JoinHandle<()>>, // client running thread
tx: Option<tokio::sync::mpsc::UnboundedSender<Command>>,
next_id: u64,
nodes: HashMap<u64, Node>,
shared_state: Option<Arc<Mutex<BridgeState>>>,
}
impl Default for Ctrl {
fn default() -> Self {
Self {
rt: None,
handle: None,
tx: None,
next_id: 1,
nodes: HashMap::new(),
shared_state: None,
}
}
}
#[no_mangle]
pub extern "C" fn sdxr_start(app_id: *const std::os::raw::c_char) -> i32 {
if STARTED.swap(true, Ordering::SeqCst) { return 0; }
let _name = unsafe { CStr::from_ptr(app_id) }.to_string_lossy().to_string();
// Reset connection status flags
CONNECTION_SUCCESS.store(false, Ordering::SeqCst);
CONNECTION_FAILED.store(false, Ordering::SeqCst);
let mut ctrl = CTRL.lock().unwrap();
// TODO: Apply texture from texture_url (pending API)
if !node.texture_url.is_empty() {
eprintln!("[bridge/reify] Node {} has texture URL: {} - NOT YET APPLIED (API limitation)",
id, node.texture_url);
}
Some(model.build())
}
Err(e) => {
eprintln!("[bridge/reify] Failed to load model for node {}: {}", id, e);
None
}
ctrl.next_id = 1;
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel::<Command>();
ctrl.tx = Some(tx.clone());

View File

@@ -1,3 +1,29 @@
# Future Risks & Priorities (612 Months)
As Starworld grows, the following risks and challenges will become increasingly important for developers:
- **Performance Scaling:** O(n) transform updates and distance queries will not scale for large scenes. Deep hierarchies and lack of spatial indexing will limit performance.
- **Memory/Data Layout:** Inefficient memory layout or fragmentation from dynamic hierarchies can degrade performance.
- **Concurrency & Synchronization:** Multithreading will require robust synchronization to avoid race conditions and data corruption.
- **Lifecycle & Ownership:** Deletion and reparenting in hierarchies can cause dangling references or orphaned children, especially across FFI boundaries.
- **API Misuse:** Cycles or invalid parent/child states can cause subtle bugs or crashes if not checked.
- **Spatial Query Correctness:** Queries may become stale or incorrect if transforms are not updated atomically.
- **XR Performance:** High frame rates and low latency are critical; entity and query systems must be highly optimized.
- **Security/Authority:** In multi-user/networked scenarios, lack of permissions or rate-limiting could allow abuse.
- **Extensibility:** As more systems (physics, networking, etc.) are added, poor separation of concerns could hinder future growth.
- **Testing/Debugging:** More features and edge cases will make testing and debugging harder without good tools.
## Recommended Priorities
- **Spatial Indexing:** Integrate a spatial data structure (octree, k-d tree, etc.) for fast queries. Update incrementally as entities move.
- **Hierarchy Traversal:** Use dirty flags for transforms and consider breadth-first traversal for deep hierarchies.
- **Lifecycle Invariants:** Prevent cycles, define deletion/reparenting behavior, and add runtime checks.
- **FFI Safety:** Ensure safe memory and ownership across Rust/C++.
- **Concurrency:** Design for thread safety and test with simulated concurrent updates/queries.
- **API Hardening:** Clearly document constraints and provide safe helpers/utilities.
- **XR Profiling:** Benchmark with XR workloads and optimize for frame time and memory.
- **Security:** Add permission models and rate-limiting for entity operations in multi-user mode.
- **Testing & Tooling:** Add deep hierarchy/reparenting tests, fuzzing, and scene graph/query inspectors.
- **Architecture:** Plan for modularity and extensibility to support future systems cleanly.
# Starworld Developer Quick Reference
## Build Commands

View File

@@ -372,12 +372,33 @@ make -j$(nproc)
## Future Work
- Color/texture visual application (StardustXR API extension)
- ATP protocol support (Overte asset server)
- More entity types (Text, Light, Zone, etc.)
- See IMPLEMENTATION_COMPLETE.md for priorities
## Future Risks & Priorities (612 Months)
As Starworld evolves, the following risks and challenges will become increasingly important:
- **Performance Scaling:** O(n) transform updates and distance queries will not scale for large scenes. Deep hierarchies and lack of spatial indexing will limit performance.
- **Memory/Data Layout:** Inefficient memory layout or fragmentation from dynamic hierarchies can degrade performance.
- **Concurrency & Synchronization:** Multithreading will require robust synchronization to avoid race conditions and data corruption.
- **Lifecycle & Ownership:** Deletion and reparenting in hierarchies can cause dangling references or orphaned children, especially across FFI boundaries.
- **API Misuse:** Cycles or invalid parent/child states can cause subtle bugs or crashes if not checked.
- **Spatial Query Correctness:** Queries may become stale or incorrect if transforms are not updated atomically.
- **XR Performance:** High frame rates and low latency are critical; entity and query systems must be highly optimized.
- **Security/Authority:** In multi-user/networked scenarios, lack of permissions or rate-limiting could allow abuse.
- **Extensibility:** As more systems (physics, networking, etc.) are added, poor separation of concerns could hinder future growth.
- **Testing/Debugging:** More features and edge cases will make testing and debugging harder without good tools.
### Recommended Priorities
- **Spatial Indexing:** Integrate a spatial data structure (octree, k-d tree, etc.) for fast queries. Update incrementally as entities move.
- **Hierarchy Traversal:** Use dirty flags for transforms and consider breadth-first traversal for deep hierarchies.
- **Lifecycle Invariants:** Prevent cycles, define deletion/reparenting behavior, and add runtime checks.
- **FFI Safety:** Ensure safe memory and ownership across Rust/C++.
- **Concurrency:** Design for thread safety and test with simulated concurrent updates/queries.
- **API Hardening:** Clearly document constraints and provide safe helpers/utilities.
- **XR Profiling:** Benchmark with XR workloads and optimize for frame time and memory.
- **Security:** Add permission models and rate-limiting for entity operations in multi-user mode.
- **Testing & Tooling:** Add deep hierarchy/reparenting tests, fuzzing, and scene graph/query inspectors.
- **Architecture:** Plan for modularity and extensibility to support future systems cleanly.
---