Skip to content

Commit

Permalink
Add occlusion culling for buildings (#30)
Browse files Browse the repository at this point in the history
Also includes the cleanup of many building meshes that would crash the editor during occluder mesh generation.
  • Loading branch information
TitanNano authored Jul 15, 2024
1 parent 9c24caa commit b0ddc05
Show file tree
Hide file tree
Showing 186 changed files with 29,295 additions and 31,657 deletions.
57 changes: 53 additions & 4 deletions native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ derive-debug = "0.1.2"
thiserror = "1.0.56"
anyhow = { version = "1.0.79" }
rand = "0.8.5"
pomsky-macro = "0.11.0"
regex = "1.10.5"

godot-rust-script = { git = "https://github.com/titannano/godot-rust-script", rev = "7549d6fc208c545d3f06f02a68a7ce163073ce5d" }
44 changes: 44 additions & 0 deletions native/src/editor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
mod building_imports;

use godot::{
builtin::Callable,
engine::{notify::NodeNotification, EditorPlugin, IEditorPlugin},
obj::{Base, Gd, WithBaseField},
register::{godot_api, GodotClass},
};

use crate::util::logger;
use building_imports::SetupBuildingImports;

#[derive(GodotClass)]
#[class(editor_plugin, tool, base=EditorPlugin)]
struct EditorExtension {
setup_building_imports: Gd<SetupBuildingImports>,
base: Base<EditorPlugin>,
}

#[godot_api]
impl IEditorPlugin for EditorExtension {
fn init(base: Base<EditorPlugin>) -> Self {
Self {
setup_building_imports: SetupBuildingImports::new(base.to_gd().get_editor_interface()),
base,
}
}

fn enter_tree(&mut self) {
let building_imports = self.setup_building_imports.clone();

self.base_mut().add_tool_menu_item(
"Setup Building Imports...".into(),
Callable::from_object_method(&building_imports, "start"),
);
}

fn on_notification(&mut self, what: NodeNotification) {
if what == NodeNotification::PREDELETE {
logger::debug!("godots destructor was called for EditorExtension...");
self.setup_building_imports.clone().free();
}
}
}
Loading

0 comments on commit b0ddc05

Please sign in to comment.