Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework WIP unity branch #730

Merged
merged 30 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8025c90
Resurrect Unity code
magcius Jul 30, 2023
8890008
Get rid of our own wasm module loading
magcius Jul 30, 2023
f417b69
Unity: Fix some leaks and double frees
magcius Jul 30, 2023
5609243
Unity: Fix one more double buffer free
magcius Jul 30, 2023
a3aa5ee
Unity: NeonWhite skeleton
magcius Jul 30, 2023
ae32749
Neon White fixes
magcius Jul 30, 2023
05af161
More work on Neon White
magcius Jul 30, 2023
385603a
Unity: Shader name extraction
magcius Aug 30, 2023
d28507f
unity: Level split
magcius Sep 1, 2023
0a37fdd
Re-ressurect unity
wgreenberg Nov 5, 2024
3fe0b15
wip
wgreenberg Nov 9, 2024
f5a881f
npm watch:rust should compile on start
wgreenberg Nov 10, 2024
12f7c5e
wip
wgreenberg Nov 10, 2024
39d012f
wip
wgreenberg Nov 10, 2024
c41767e
A Short Hike: Update render inst list
magcius Nov 10, 2024
995a227
wip
wgreenberg Nov 10, 2024
a892dec
more hacks
magcius Nov 10, 2024
a723f51
mesh load fixes
magcius Nov 10, 2024
d8c2bc2
wip
wgreenberg Nov 11, 2024
5eddc3b
wip
wgreenberg Nov 12, 2024
a731f18
wip
wgreenberg Nov 12, 2024
cdfa331
Neon White: Update for GfxRenderInst changes
magcius Nov 12, 2024
25bf336
kinda working!
wgreenberg Nov 12, 2024
060e224
minor v2019 fixes
wgreenberg Nov 12, 2024
c65819a
watch:rust uses build:rust-dev
wgreenberg Nov 20, 2024
d427097
fix watch:rust
wgreenberg Nov 20, 2024
3ded941
rm debug attr
wgreenberg Nov 20, 2024
f6bf967
don't render meshes with 0 submeshes
wgreenberg Nov 20, 2024
2f783e4
fix warnings
wgreenberg Nov 28, 2024
b2c9bb1
type appeasement
wgreenberg Nov 28, 2024
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"start": "pnpm run build:rust && cross-env NODE_ENV=development rspack dev",
"build": "pnpm run build:rust && cross-env NODE_ENV=production rspack build",
"build:rust": "wasm-pack build -t web rust",
"build:rust-dev": "wasm-pack build --dev -t web rust",
"build:ZeldaWindWaker": "cd src/ZeldaWindWaker/tools && tsx --experimental-wasm-modules zww_extractor.ts",
"build:ztp": "cd src/ZeldaTwilightPrincess/tools && tsx ztp_extractor.ts",
"build:dk64": "cd src/DonkeyKong64/tools && tsx extractor.ts",
Expand All @@ -47,7 +48,7 @@
"build:TheWitness": "cd src/TheWitness/tools && tsx extractor.ts",
"test:DeBlob2": "cd src/DeBlob2/tools && tsx systest.ts",
"typecheck": "tsc -w --noEmit",
"watch:rust": "onchange rust/**/*.rs -- pnpm run build:rust"
"watch:rust": "pnpm run build:rust-dev && onchange rust/src/**/*.rs rust/noclip-macros/src/**/*.rs -- pnpm run build:rust-dev"
},
"bin": {
"nc-bcsvtool": "./src/tools/bcsvtool.ts",
Expand Down
10 changes: 10 additions & 0 deletions rust/Cargo.lock

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

7 changes: 6 additions & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace]
members = ["noclip-macros"]

[package]
name = "noclip-support"
version = "0.0.0"
Expand All @@ -12,6 +15,8 @@ wasm-opt = ['-O', '--enable-bulk-memory']

[package.metadata.wasm-pack.profile.profiling]
wasm-opt = ['-Os', '--debuginfo']
demangle-name-section = true
dwarf-debug-info = true

[profile.release]
lto = true
Expand All @@ -35,4 +40,4 @@ web-sys = { version = "0.3.48", features = ["console"] }
nalgebra-glm = "0.19.0"
rand = "0.8.5"
getrandom = { version = "0.2.15", features = ["js"] }

noclip-macros = { version = "*", path = "./noclip-macros" }
12 changes: 12 additions & 0 deletions rust/noclip-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "noclip-macros"
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true

[dependencies]
proc-macro2 = "1.0.89"
quote = "1.0.37"
syn = { version = "2.0.87", features = ["extra-traits"] }
99 changes: 99 additions & 0 deletions rust/noclip-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
use syn::Data;
use quote::quote;

#[proc_macro_derive(FromStructPerField, attributes(from))]
pub fn derive_from_struct_per_field(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = syn::parse_macro_input!(item as syn::DeriveInput);

let mut from_structs = Vec::new();
for attr in &input.attrs {
match &attr.meta {
syn::Meta::List(meta_list) => {
let tokens: proc_macro::TokenStream = meta_list.tokens.clone().into();
from_structs.push(syn::parse_macro_input!(tokens as syn::Path));
},
_ => unimplemented!(),
};
}

let struct_identifier = &input.ident;
let mut impls = proc_macro2::TokenStream::new();

match &input.data {
Data::Struct(syn::DataStruct { fields, .. }) => {
let mut field_assignments = proc_macro2::TokenStream::new();
for field in fields {
let identifier = field.ident.as_ref().unwrap();
field_assignments.extend(quote!{
#identifier: value.#identifier.into(),
});
}

for from_struct in from_structs {
impls.extend(quote!{
impl From<#from_struct> for #struct_identifier {
fn from(value: #from_struct) -> #struct_identifier {
#struct_identifier {
#field_assignments
}
}
}
});
}
},
_ => unimplemented!(),
}

impls.into()
}

#[proc_macro_derive(FromEnumPerVariant, attributes(from))]
pub fn derive_from_enum(item: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = syn::parse_macro_input!(item as syn::DeriveInput);

let mut from_enums = Vec::new();
for attr in &input.attrs {
match &attr.meta {
syn::Meta::List(meta_list) => {
let tokens: proc_macro::TokenStream = meta_list.tokens.clone().into();
from_enums.push(syn::parse_macro_input!(tokens as syn::Path));
},
_ => unimplemented!(),
};
}

let enum_identifier = &input.ident;
let mut impls = proc_macro2::TokenStream::new();

match &input.data {
Data::Enum(syn::DataEnum { variants, .. }) => {
for from_enum in from_enums {
let mut variant_patterns = proc_macro2::TokenStream::new();
for variant in variants {
let identifier = &variant.ident;
variant_patterns.extend(quote!{
#from_enum::#identifier => #enum_identifier::#identifier,
});
}

impls.extend(quote!{
impl From<#from_enum> for #enum_identifier {
fn from(value: #from_enum) -> #enum_identifier {
match value {
#variant_patterns
}
}
}
});
}
},
_ => unimplemented!(),
}

impls.into()
}

#[proc_macro_attribute]
pub fn from(attr: proc_macro::TokenStream, _: proc_macro::TokenStream) -> proc_macro::TokenStream {
attr
}
121 changes: 0 additions & 121 deletions rust/src/unity/asset.rs

This file was deleted.

Loading