Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"permissions": {
"allow": [
"Bash(dir:*)"
]
}
}
40 changes: 33 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
[workspace]
resolver = "2"
members = [
".",
"plugins/empty",
"plugins/ecs",
"plugins/ecs_examples",
"plugins/export_macros",
]

[workspace.dependencies]
hotline-rs = { path = "." }
maths-rs = "0.2.3"
bitflags = "1.3.2"
bevy_ecs = "0.15.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.81"
font-awesome = "0.2.0"

[package]
name = "hotline-rs"
version = "0.3.2"
Expand All @@ -13,16 +32,16 @@ license-file = "license"
exclude = ["config.user.jsn", "hotline-data"]

[dependencies]
maths-rs = "0.2.3"
bitflags = "1.3.2"
maths-rs.workspace = true
bitflags.workspace = true
stb_image_rust = "2.27.2"
stb_image_write_rust = "1.16.1"
font-awesome = "0.2.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.81"
font-awesome.workspace = true
serde.workspace = true
serde_json.workspace = true
hot-lib-reloader = "0.6.4"
libloading = "0.7.4"
bevy_ecs = "0.15.0"
bevy_ecs.workspace = true
ddsfile = "0.5.1"

[dependencies.imgui-sys]
Expand Down Expand Up @@ -98,6 +117,13 @@ required-features = ["client"]
[profile.dev]
opt-level = 0

[profile.dev.package.empty]
opt-level = 1
[profile.dev.package.ecs]
opt-level = 1
[profile.dev.package.ecs_examples]
opt-level = 1

[profile.release]
lto = "off"
incremental = true
incremental = true
2 changes: 1 addition & 1 deletion config.jsn
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
client: {
type: shell
commands: [
"cargo build --manifest-path plugins/Cargo.toml ${config_flags}"
"cargo build -p empty -p ecs -p ecs_examples ${config_flags}"
]
}
plugins: {
Expand Down
2 changes: 1 addition & 1 deletion examples/imgui_demo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn main() -> Result<(), hotline_rs::Error> {

dev.execute(&cmdbuffer);

swap_chain.swap(&dev);
swap_chain.swap(&mut dev);
ci = (ci + 1) % 4;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/play_video/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn main() -> Result<(), hotline_rs::Error> {

dev.execute(&cmdbuffer);

swap_chain.swap(&dev);
swap_chain.swap(&mut dev);
ci = (ci + 1) % 4;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/raytraced_triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ fn main() -> Result<(), hotline_rs::Error> {
device.execute(&cmd);

// swap for the next frame
swap_chain.swap(&device);
swap_chain.swap(&mut device);
}

// must wait for the final frame to be completed
Expand Down
2 changes: 1 addition & 1 deletion examples/resource_tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ fn main() -> Result<(), hotline_rs::Error> {

dev.execute(&cmdbuffer);

swap_chain.swap(&dev);
swap_chain.swap(&mut dev);
ci = (ci + 1) % 4;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/swap_chain/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn main() -> Result<(), hotline_rs::Error> {
device.execute(&cmd);

println!("swap {}", t);
swap_chain.swap(&device);
swap_chain.swap(&mut device);

t += 1.0 / 600.0;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn main() -> Result<(), hotline_rs::Error> {
device.execute(&cmd);

// swap for the next frame
swap_chain.swap(&device);
swap_chain.swap(&mut device);
}

// must wait for the final frame to be completed
Expand Down
11 changes: 0 additions & 11 deletions plugins/Cargo.toml

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/config.toml

This file was deleted.

14 changes: 7 additions & 7 deletions plugins/ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["rlib", "dylib"]

[dependencies]
hotline-rs = { path = "../.." }
maths-rs = "0.2.3"
bevy_ecs = "0.15.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.81"
font-awesome = "0.2.0"
bitflags = "1.3.2"
hotline-rs.workspace = true
maths-rs.workspace = true
bevy_ecs.workspace = true
serde.workspace = true
serde_json.workspace = true
font-awesome.workspace = true
bitflags.workspace = true
41 changes: 17 additions & 24 deletions plugins/ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ impl BevyPlugin {
let exported_function_name = format!("export_{}", name);
if view_name.is_empty() {
// function with () no args
let hook = lib.get_symbol::<unsafe extern fn() -> SystemConfigs>(exported_function_name.as_bytes());
let hook = lib.get_symbol::<unsafe extern "C" fn() -> SystemConfigs>(exported_function_name.as_bytes());
if let Ok(hook_fn) = hook {
return Some(hook_fn());
}
}
else {
// function with pass name args
let hook = lib.get_symbol::<unsafe extern fn(String) -> SystemConfigs>(exported_function_name.as_bytes());
let hook = lib.get_symbol::<unsafe extern "C" fn(String) -> SystemConfigs>(exported_function_name.as_bytes());
if let Ok(hook_fn) = hook {
return Some(hook_fn(view_name.to_string()));
}
Expand All @@ -309,7 +309,7 @@ impl BevyPlugin {
for (lib_name, lib) in &client.libs {
unsafe {
let function_name = format!("get_system_{}", lib_name).to_string();
let hook = lib.get_symbol::<unsafe extern fn(String, String) -> Option<SystemConfigs>>(function_name.as_bytes());
let hook = lib.get_symbol::<unsafe extern "C" fn(String, String) -> Option<SystemConfigs>>(function_name.as_bytes());
if let Ok(hook_fn) = hook {
let desc = hook_fn(name.to_string(), view_name.to_string());
if desc.is_some() {
Expand All @@ -327,7 +327,7 @@ impl BevyPlugin {
for (lib_name, lib) in &client.libs {
unsafe {
let function_name = format!("get_demos_{}", lib_name).to_string();
let list = lib.get_symbol::<unsafe extern fn() -> Vec<String>>(function_name.as_bytes());
let list = lib.get_symbol::<unsafe extern "C" fn() -> Vec<String>>(function_name.as_bytes());
if let Ok(list_fn) = list {
let mut lib_demos = list_fn();
demos.append(&mut lib_demos);
Expand All @@ -352,7 +352,7 @@ impl BevyPlugin {
for (_, lib) in &client.libs {
unsafe {
let function_name = format!("{}", self.session_info.active_demo).to_string();
let demo = lib.get_symbol::<unsafe extern fn(&mut PlatformClient) -> ScheduleInfo>(function_name.as_bytes());
let demo = lib.get_symbol::<unsafe extern "C" fn(&mut PlatformClient) -> ScheduleInfo>(function_name.as_bytes());
if let Ok(demo_fn) = demo {
return Some(demo_fn(client));
}
Expand All @@ -364,24 +364,21 @@ impl BevyPlugin {
}

/// If we change demo or need to rebuild render graphs we need to invoke this, code changes will already invoke setup
fn resetup(&mut self, mut client: PlatformClient) -> PlatformClient {
fn resetup(&mut self, client: &mut PlatformClient) {
// serialize
client.serialise_plugin_data("ecs", &self.session_info);
// unload / setup
client.swap_chain.wait_for_last_frame();
client = self.unload(client);
self.unload(client);
client.pmfx.unload_views();
self.setup(client)
}

/// Custom function to handle custome data change events which can trigger resetup
fn check_for_changes(&mut self, client: PlatformClient) -> PlatformClient {
fn check_for_changes(&mut self, client: &mut PlatformClient) {
// render graph itself has chaned
if self.render_graph_hash != client.pmfx.get_render_graph_hash(&self.schedule_info.render_graph) {
self.resetup(client)
}
else {
client
self.resetup(client);
}
}

Expand All @@ -403,7 +400,7 @@ impl BevyPlugin {
}
}

fn schedule_ui(&mut self, mut client: PlatformClient) -> PlatformClient {
fn schedule_ui(&mut self, client: &mut PlatformClient) {
let error_col = vec4f(1.0, 0.0, 0.3, 1.0);
let warning_col = vec4f(1.0, 7.0, 0.0, 1.0);
let default_col = vec4f(1.0, 1.0, 1.0, 1.0);
Expand Down Expand Up @@ -472,7 +469,6 @@ impl BevyPlugin {
}
}
}
client
}

fn setup_camera(&mut self) -> (Camera, Mat4f, Position) {
Expand Down Expand Up @@ -520,14 +516,14 @@ impl Plugin<gfx_platform::Device, os_platform::App> for BevyPlugin {
}
}

fn setup(&mut self, mut client: PlatformClient) -> PlatformClient {
fn setup(&mut self, client: &mut PlatformClient) {
// clear errors
self.errors = HashMap::new();

self.session_info = client.deserialise_plugin_data("ecs");

// dynamically change demos and lookup infos in other libs
let schedule_info = self.get_demo_schedule_info(&mut client);
let schedule_info = self.get_demo_schedule_info(client);

// get schedule or use default and warn the user
self.schedule_info = if let Some(info) = schedule_info {
Expand Down Expand Up @@ -607,14 +603,13 @@ impl Plugin<gfx_platform::Device, os_platform::App> for BevyPlugin {

// we defer the actual setup system calls until the update where resources will be inserted into the world
self.run_setup = true;
client
}

fn update(&mut self, mut client: PlatformClient) -> PlatformClient {
let session_info = self.session_info.clone();

// check for any changes
client = self.check_for_changes(client);
self.check_for_changes(&mut client);

// clear pmfx view errors before we render
client.pmfx.view_errors.lock().unwrap().clear();
Expand Down Expand Up @@ -662,15 +657,14 @@ impl Plugin<gfx_platform::Device, os_platform::App> for BevyPlugin {
client
}

fn unload(&mut self, client: PlatformClient) -> PlatformClient {
fn unload(&mut self, _client: &mut PlatformClient) {
// drop everything while its safe
self.setup_schedule = Schedule::default();
self.schedule = Schedule::default();
self.world = World::default();
client
}

fn ui(&mut self, mut client: PlatformClient) -> PlatformClient {
fn ui(&mut self, client: &mut PlatformClient) {
let mut open = true;
let mut resetup = false;
if client.imgui.begin("ecs", &mut open, imgui::WindowFlags::NONE) {
Expand Down Expand Up @@ -790,7 +784,7 @@ impl Plugin<gfx_platform::Device, os_platform::App> for BevyPlugin {
}
}

client = self.schedule_ui(client);
self.schedule_ui(client);
}

// preform any re-setup actions
Expand All @@ -801,11 +795,10 @@ impl Plugin<gfx_platform::Device, os_platform::App> for BevyPlugin {
self.session_info.main_camera = Some(default_cameras[&self.session_info.active_demo]);
}
}
client = self.resetup(client);
self.resetup(client);
}

client.imgui.end();
client
}
}

Expand Down
8 changes: 4 additions & 4 deletions plugins/ecs_examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"
crate-type = ["rlib", "dylib"]

[dependencies]
hotline-rs = { path = "../.." }
hotline-rs.workspace = true
export_macros = { path = "../export_macros" }
maths-rs = "0.2.3"
bevy_ecs = "0.15.0"
maths-rs.workspace = true
bevy_ecs.workspace = true
rand = "0.8.5"
bitflags = "1.3.2"
bitflags.workspace = true
Loading
Loading