diff --git a/sable_rapier/src/main/java/dev/ryanhcode/sable/physics/impl/rapier/Rapier3D.java b/sable_rapier/src/main/java/dev/ryanhcode/sable/physics/impl/rapier/Rapier3D.java index a3701315..b1915bd8 100644 --- a/sable_rapier/src/main/java/dev/ryanhcode/sable/physics/impl/rapier/Rapier3D.java +++ b/sable_rapier/src/main/java/dev/ryanhcode/sable/physics/impl/rapier/Rapier3D.java @@ -50,12 +50,12 @@ private static Path resolveNativeDir() { final Path gameDir = SableLoaderPlatform.INSTANCE.getGameDirectory(); if (gameDir != null) { final Path gameDirRelativeDir = gameDir.resolve(".sable").resolve("natives").normalize(); - Sable.LOGGER.info("Using game-dir-relative Rapier native directory {}", gameDirRelativeDir.toAbsolutePath()); + Sable.LOGGER.info("Using game directory relative Sable Rapier native directory {}", gameDirRelativeDir.toAbsolutePath()); return gameDirRelativeDir; } final Path fallbackDir = Paths.get(System.getProperty("user.home", System.getProperty("user.dir")), ".sable", "natives"); - Sable.LOGGER.info("Using fallback Rapier native directory {}", fallbackDir.toAbsolutePath()); + Sable.LOGGER.info("Using fallback Sable Rapier native directory {}", fallbackDir.toAbsolutePath()); return fallbackDir; } diff --git a/sable_rapier/src/main/resources/natives/sable_rapier/sable_rapier_binaries.zip.l4z b/sable_rapier/src/main/resources/natives/sable_rapier/sable_rapier_binaries.zip.l4z deleted file mode 100644 index bec86cf9..00000000 Binary files a/sable_rapier/src/main/resources/natives/sable_rapier/sable_rapier_binaries.zip.l4z and /dev/null differ diff --git a/sable_rapier/src/main/rust/rapier/src/lib.rs b/sable_rapier/src/main/rust/rapier/src/lib.rs index 2d224733..970b1247 100644 --- a/sable_rapier/src/main/rust/rapier/src/lib.rs +++ b/sable_rapier/src/main/rust/rapier/src/lib.rs @@ -18,6 +18,8 @@ use jni::sys::{jboolean, jdouble, jint, jlong}; use jni::{JNIEnv, JavaVM}; use rapier3d::glamx::{DVec3, Quat}; use std::collections::HashMap; +use std::io::ErrorKind::BrokenPipe; +use std::io::{self, Write}; use std::sync::{Arc, OnceLock, RwLock}; use fern::colors::{Color, ColoredLevelConfig}; @@ -303,6 +305,39 @@ pub fn get_rigid_body<'a>( &sim.rigid_body_set[*handle] } +struct LogWriter; + +impl Write for LogWriter { + fn write(&mut self, buf: &[u8]) -> std::io::Result { + let mut stdout = io::stdout().lock(); + match stdout.write(buf) { + Err(error) => { + if error.kind() == BrokenPipe { + Ok(buf.len()) + } else { + Err(error) + } + } + other => other, + } + } + + fn flush(&mut self) -> io::Result<()> { + let mut stdout = io::stdout().lock(); + + match stdout.flush() { + Err(error) => { + if error.kind() == BrokenPipe { + Ok(()) + } else { + Err(error) + } + } + other => other, + } + } +} + #[unsafe(no_mangle)] pub extern "system" fn Java_dev_ryanhcode_sable_physics_impl_rapier_Rapier3D_initialize<'local>( env: JNIEnv<'local>, @@ -330,7 +365,7 @@ pub extern "system" fn Java_dev_ryanhcode_sable_physics_impl_rapier_Rapier3D_ini }) .level(log::LevelFilter::Info) .level_for("jni", log::LevelFilter::Error) - .chain(std::io::stdout()) + .chain(fern::Output::writer(Box::new(LogWriter), "\n")) .apply(); RwLock::new(PhysicsState {