checkpoint before render engine vendoring
Signed-off-by: Sienna Meridian Satterwhite <sienna@r3t.io>
This commit is contained in:
@@ -33,20 +33,21 @@ rand = "0.8"
|
||||
iroh = { version = "0.95", features = ["discovery-local-network"] }
|
||||
iroh-gossip = "0.95"
|
||||
futures-lite = "2.0"
|
||||
bincode = "1.3"
|
||||
rkyv = { workspace = true }
|
||||
bytes = "1.0"
|
||||
crossbeam-channel = "0.5.15"
|
||||
|
||||
[target.'cfg(target_os = "ios")'.dependencies]
|
||||
objc = "0.2"
|
||||
raw-window-handle = "0.6"
|
||||
tracing-oslog = "0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
iroh = { version = "0.95", features = ["discovery-local-network"] }
|
||||
iroh-gossip = "0.95"
|
||||
tempfile = "3"
|
||||
futures-lite = "2.0"
|
||||
bincode = "1.3"
|
||||
rkyv = { workspace = true }
|
||||
bytes = "1.0"
|
||||
|
||||
[lib]
|
||||
|
||||
@@ -242,7 +242,7 @@ fn screen_to_world_ray(
|
||||
screen_pos: glam::Vec2,
|
||||
camera: &Camera,
|
||||
camera_transform: &GlobalTransform,
|
||||
window: &Window,
|
||||
_window: &Window,
|
||||
) -> Option<Ray> {
|
||||
// Convert screen position to viewport position (0..1 range)
|
||||
let viewport_pos = Vec2::new(screen_pos.x, screen_pos.y);
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
pub mod event_buffer;
|
||||
pub mod input_handler;
|
||||
|
||||
pub use event_buffer::InputEventBuffer;
|
||||
pub use input_handler::InputHandlerPlugin;
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
use libmarathon::{
|
||||
engine::{EngineBridge, EngineCore},
|
||||
engine::{
|
||||
EngineBridge,
|
||||
EngineCore,
|
||||
},
|
||||
persistence::PersistenceConfig,
|
||||
};
|
||||
use std::path::PathBuf;
|
||||
|
||||
mod camera;
|
||||
mod cube;
|
||||
@@ -32,56 +34,102 @@ use session::*;
|
||||
use session_ui::*;
|
||||
|
||||
fn main() {
|
||||
// Note: eprintln doesn't work on iOS, but tracing-oslog will once initialized
|
||||
eprintln!(">>> RUST ENTRY: main() started");
|
||||
|
||||
// Initialize logging
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::from_default_env()
|
||||
.add_directive("wgpu=error".parse().unwrap())
|
||||
.add_directive("naga=warn".parse().unwrap()),
|
||||
)
|
||||
.init();
|
||||
eprintln!(">>> Initializing tracing_subscriber");
|
||||
|
||||
#[cfg(target_os = "ios")]
|
||||
{
|
||||
use tracing_subscriber::prelude::*;
|
||||
|
||||
let filter = tracing_subscriber::EnvFilter::builder()
|
||||
.with_default_directive(tracing::Level::DEBUG.into())
|
||||
.from_env_lossy()
|
||||
.add_directive("wgpu=error".parse().unwrap())
|
||||
.add_directive("naga=warn".parse().unwrap())
|
||||
.add_directive("winit=error".parse().unwrap());
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(filter)
|
||||
.with(tracing_oslog::OsLogger::new("io.r3t.aspen", "default"))
|
||||
.init();
|
||||
|
||||
info!("OSLog initialized successfully");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "ios"))]
|
||||
{
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
tracing_subscriber::EnvFilter::from_default_env()
|
||||
.add_directive("wgpu=error".parse().unwrap())
|
||||
.add_directive("naga=warn".parse().unwrap()),
|
||||
)
|
||||
.init();
|
||||
}
|
||||
|
||||
eprintln!(">>> Tracing subscriber initialized");
|
||||
|
||||
// Application configuration
|
||||
const APP_NAME: &str = "Aspen";
|
||||
|
||||
// Get platform-appropriate database path
|
||||
eprintln!(">>> Getting database path");
|
||||
let db_path = libmarathon::platform::get_database_path(APP_NAME);
|
||||
let db_path_str = db_path.to_str().unwrap().to_string();
|
||||
info!("Database path: {}", db_path_str);
|
||||
eprintln!(">>> Database path: {}", db_path_str);
|
||||
|
||||
// Create EngineBridge (for communication between Bevy and EngineCore)
|
||||
eprintln!(">>> Creating EngineBridge");
|
||||
let (engine_bridge, engine_handle) = EngineBridge::new();
|
||||
info!("EngineBridge created");
|
||||
eprintln!(">>> EngineBridge created");
|
||||
|
||||
// Spawn EngineCore on tokio runtime (runs in background thread)
|
||||
eprintln!(">>> Spawning EngineCore background thread");
|
||||
std::thread::spawn(move || {
|
||||
eprintln!(">>> [EngineCore thread] Thread started");
|
||||
info!("Starting EngineCore on tokio runtime...");
|
||||
eprintln!(">>> [EngineCore thread] Creating tokio runtime");
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
eprintln!(">>> [EngineCore thread] Tokio runtime created");
|
||||
rt.block_on(async {
|
||||
eprintln!(">>> [EngineCore thread] Creating EngineCore");
|
||||
let core = EngineCore::new(engine_handle, &db_path_str);
|
||||
eprintln!(">>> [EngineCore thread] Running EngineCore");
|
||||
core.run().await;
|
||||
});
|
||||
});
|
||||
info!("EngineCore spawned in background");
|
||||
eprintln!(">>> EngineCore thread spawned");
|
||||
|
||||
// Create Bevy app (without winit - we own the event loop)
|
||||
eprintln!(">>> Creating Bevy App");
|
||||
let mut app = App::new();
|
||||
eprintln!(">>> Bevy App created");
|
||||
|
||||
// Insert EngineBridge as a resource for Bevy systems to use
|
||||
eprintln!(">>> Inserting EngineBridge resource");
|
||||
app.insert_resource(engine_bridge);
|
||||
|
||||
// Use DefaultPlugins but disable winit/window/input (we own those)
|
||||
eprintln!(">>> Adding DefaultPlugins");
|
||||
app.add_plugins(
|
||||
DefaultPlugins
|
||||
.build()
|
||||
.disable::<bevy::log::LogPlugin>() // Using tracing-subscriber
|
||||
.disable::<bevy::winit::WinitPlugin>() // We own winit
|
||||
.disable::<bevy::window::WindowPlugin>() // We own the window
|
||||
.disable::<bevy::input::InputPlugin>() // We provide InputEvents directly
|
||||
.disable::<bevy::gilrs::GilrsPlugin>() // We handle gamepad input ourselves
|
||||
.disable::<bevy::log::LogPlugin>() // Using tracing-subscriber
|
||||
.disable::<bevy::winit::WinitPlugin>() // We own winit
|
||||
.disable::<bevy::window::WindowPlugin>() // We own the window
|
||||
.disable::<bevy::input::InputPlugin>() // We provide InputEvents directly
|
||||
.disable::<bevy::gilrs::GilrsPlugin>(), // We handle gamepad input ourselves
|
||||
);
|
||||
eprintln!(">>> DefaultPlugins added");
|
||||
|
||||
// Marathon core plugins (networking, debug UI, persistence)
|
||||
eprintln!(">>> Adding MarathonPlugin");
|
||||
app.add_plugins(libmarathon::MarathonPlugin::new(
|
||||
APP_NAME,
|
||||
PersistenceConfig {
|
||||
@@ -91,8 +139,10 @@ fn main() {
|
||||
..Default::default()
|
||||
},
|
||||
));
|
||||
eprintln!(">>> MarathonPlugin added");
|
||||
|
||||
// App-specific bridge for polling engine events
|
||||
eprintln!(">>> Adding app plugins");
|
||||
app.add_plugins(EngineBridgePlugin);
|
||||
app.add_plugins(CameraPlugin);
|
||||
app.add_plugins(RenderingPlugin);
|
||||
@@ -102,6 +152,9 @@ fn main() {
|
||||
app.add_plugins(DebugUiPlugin);
|
||||
app.add_plugins(SessionUiPlugin);
|
||||
app.add_systems(Startup, initialize_offline_resources);
|
||||
eprintln!(">>> All plugins added");
|
||||
|
||||
eprintln!(">>> Running executor");
|
||||
libmarathon::platform::run_executor(app).expect("Failed to run executor");
|
||||
eprintln!(">>> Executor returned (should never reach here)");
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ fn spawn_bridge_tasks(
|
||||
|
||||
loop {
|
||||
if let Some(msg) = bridge_out.try_recv_outgoing() {
|
||||
if let Ok(bytes) = bincode::serialize(&msg) {
|
||||
if let Ok(bytes) = rkyv::to_bytes::<rkyv::rancor::Failure>(&msg).map(|b| b.to_vec()) {
|
||||
if let Err(e) = sender.broadcast(Bytes::from(bytes)).await {
|
||||
error!("[Node {}] Broadcast failed: {}", node_id, e);
|
||||
}
|
||||
@@ -303,7 +303,7 @@ fn spawn_bridge_tasks(
|
||||
| Ok(Some(Ok(event))) => {
|
||||
if let iroh_gossip::api::Event::Received(msg) = event {
|
||||
if let Ok(versioned_msg) =
|
||||
bincode::deserialize::<VersionedMessage>(&msg.content)
|
||||
rkyv::from_bytes::<VersionedMessage, rkyv::rancor::Failure>(&msg.content)
|
||||
{
|
||||
if let Err(e) = bridge_in.push_incoming(versioned_msg) {
|
||||
error!("[Node {}] Push incoming failed: {}", node_id, e);
|
||||
|
||||
@@ -114,6 +114,7 @@ mod test_utils {
|
||||
}
|
||||
|
||||
/// Count entities with CubeMarker component
|
||||
#[allow(dead_code)]
|
||||
pub fn count_cubes(world: &mut World) -> usize {
|
||||
let mut query = world.query::<&CubeMarker>();
|
||||
query.iter(world).count()
|
||||
@@ -308,7 +309,7 @@ mod test_utils {
|
||||
"[Node {}] Sending message #{} via gossip",
|
||||
node_id, msg_count
|
||||
);
|
||||
match bincode::serialize(&versioned_msg) {
|
||||
match rkyv::to_bytes::<rkyv::rancor::Failure>(&versioned_msg).map(|b| b.to_vec()) {
|
||||
| Ok(bytes) => {
|
||||
if let Err(e) = sender.broadcast(Bytes::from(bytes)).await {
|
||||
eprintln!("[Node {}] Failed to broadcast message: {}", node_id, e);
|
||||
@@ -349,7 +350,7 @@ mod test_utils {
|
||||
"[Node {}] Received message #{} from gossip",
|
||||
node_id, msg_count
|
||||
);
|
||||
match bincode::deserialize::<VersionedMessage>(&msg.content) {
|
||||
match rkyv::from_bytes::<VersionedMessage, rkyv::rancor::Failure>(&msg.content) {
|
||||
| Ok(versioned_msg) => {
|
||||
if let Err(e) = bridge_in.push_incoming(versioned_msg) {
|
||||
eprintln!(
|
||||
|
||||
Reference in New Issue
Block a user