Compare commits

..

10 Commits

Author SHA1 Message Date
1881ee2b16 dynamic objects 2023-11-22 04:37:55 -08:00
c239bbefba update deps 2023-11-18 16:14:40 -08:00
eeb1561c3d utopia preset 2023-11-10 19:12:19 -08:00
19e602544a anisotropic filtering 2023-11-10 19:08:33 -08:00
444c3cbad9 remove cybertruck model from default map 2023-11-09 19:21:04 -08:00
2006f81804 surf maps link 2023-11-08 19:41:26 -08:00
de7b7ba7be defer resize to next frame render 2023-11-08 18:20:19 -08:00
008c66e052 TrussPart 2023-11-07 20:54:49 -08:00
ba250277bd textures for spheres and cylinders 2023-11-07 20:45:05 -08:00
085d4e7912 use cubes instead of teapots and monkeys 2023-11-07 16:54:44 -08:00
9 changed files with 188 additions and 249 deletions

159
Cargo.lock generated

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "ab_glyph"
version = "0.2.22"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1061f3ff92c2f65800df1f12fc7b4ff44ee14783104187dd04dfee6f11b0fd2"
checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225"
dependencies = [
"ab_glyph_rasterizer",
"owned_ttf_parser",
@ -245,7 +245,7 @@ checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
]
[[package]]
@ -351,9 +351,9 @@ dependencies = [
[[package]]
name = "configparser"
version = "3.0.2"
version = "3.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5458d9d1a587efaf5091602c59d299696a3877a439c8f6d461a2d3cce11df87a"
checksum = "e0e56e414a2a52ab2a104f85cd40933c2fbc278b83637facf646ecf451b49237"
[[package]]
name = "constant_time_eq"
@ -412,9 +412,9 @@ dependencies = [
[[package]]
name = "cursor-icon"
version = "1.0.0"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf"
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
[[package]]
name = "d3d12"
@ -479,9 +479,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.5"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8"
dependencies = [
"libc",
"windows-sys 0.48.0",
@ -517,7 +517,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
]
[[package]]
@ -550,9 +550,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.10"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
dependencies = [
"cfg-if",
"js-sys",
@ -702,9 +702,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.0.2"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897"
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
dependencies = [
"equivalent",
"hashbrown",
@ -743,9 +743,9 @@ dependencies = [
[[package]]
name = "js-sys"
version = "0.3.64"
version = "0.3.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a"
checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8"
dependencies = [
"wasm-bindgen",
]
@ -769,9 +769,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]]
name = "lazy-regex"
version = "3.0.2"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e723bd417b2df60a0f6a2b6825f297ea04b245d4ba52b5a22cb679bdf58b05fa"
checksum = "5d12be4595afdf58bd19e4a9f4e24187da2a66700786ff660a418e9059937a4c"
dependencies = [
"lazy-regex-proc_macros",
"once_cell",
@ -780,14 +780,14 @@ dependencies = [
[[package]]
name = "lazy-regex-proc_macros"
version = "3.0.1"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f0a1d9139f0ee2e862e08a9c5d0ba0470f2aa21cd1e1aa1b1562f83116c725f"
checksum = "44bcd58e6c97a7fcbaffcdc95728b393b8d98933bfadad49ed4097845b57ef0b"
dependencies = [
"proc-macro2",
"quote",
"regex",
"syn 2.0.38",
"syn 2.0.39",
]
[[package]]
@ -798,9 +798,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.149"
version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "libloading"
@ -823,10 +823,21 @@ dependencies = [
]
[[package]]
name = "linux-raw-sys"
version = "0.4.10"
name = "libredox"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f"
checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607"
dependencies = [
"bitflags 2.4.1",
"libc",
"redox_syscall 0.4.1",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
[[package]]
name = "lock_api"
@ -929,9 +940,9 @@ dependencies = [
[[package]]
name = "naga"
version = "0.14.0"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61d829abac9f5230a85d8cc83ec0879b4c09790208ae25b5ea031ef84562e071"
checksum = "6cd05939c491da968a42986204b7431678be21fdcd4b10cc84997ba130ada5a4"
dependencies = [
"bit-set",
"bitflags 2.4.1",
@ -1036,7 +1047,7 @@ dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
]
[[package]]
@ -1103,18 +1114,18 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "orbclient"
version = "0.3.46"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8378ac0dfbd4e7895f2d2c1f1345cab3836910baf3a300b000d04250f0c8428f"
checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166"
dependencies = [
"redox_syscall 0.3.5",
"libredox",
]
[[package]]
name = "owned_ttf_parser"
version = "0.19.0"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "706de7e2214113d63a8238d1910463cfce781129a6f263d13fdb09ff64355ba4"
checksum = "d4586edfe4c648c71797a74c84bacb32b52b212eff5dfe2bb9f2c599844023e7"
dependencies = [
"ttf-parser",
]
@ -1232,7 +1243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb156a45b6b9fe8027497422179fb65afc84d36707a7ca98297bf06bccb8d43f"
dependencies = [
"quote",
"syn 2.0.38",
"syn 2.0.39",
]
[[package]]
@ -1467,9 +1478,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.38.21"
version = "0.38.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3"
checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234"
dependencies = [
"bitflags 2.4.1",
"errno",
@ -1514,22 +1525,22 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.190"
version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7"
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.190"
version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3"
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
]
[[package]]
@ -1552,9 +1563,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.11.1"
version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
[[package]]
name = "smithay-client-toolkit"
@ -1654,9 +1665,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.38"
version = "2.0.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b"
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
dependencies = [
"proc-macro2",
"quote",
@ -1665,9 +1676,9 @@ dependencies = [
[[package]]
name = "termcolor"
version = "1.3.0"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"
dependencies = [
"winapi-util",
]
@ -1689,7 +1700,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
]
[[package]]
@ -1752,9 +1763,9 @@ checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
[[package]]
name = "ttf-parser"
version = "0.19.2"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49d64318d8311fc2668e48b63969f4343e0a85c4a109aa8460d6672e364b8bd1"
checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
[[package]]
name = "unicode-ident"
@ -1804,9 +1815,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.87"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342"
checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@ -1814,24 +1825,24 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.87"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd"
checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.37"
version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03"
checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02"
dependencies = [
"cfg-if",
"js-sys",
@ -1841,9 +1852,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.87"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d"
checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -1851,22 +1862,22 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.87"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.87"
version = "0.2.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1"
checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b"
[[package]]
name = "wayland-backend"
@ -2024,9 +2035,9 @@ dependencies = [
[[package]]
name = "wgpu-core"
version = "0.18.0"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "837e02ddcdc6d4a9b56ba4598f7fd4202a7699ab03f6ef4dcdebfad2c966aea6"
checksum = "ef91c1d62d1e9e81c79e600131a258edf75c9531cbdbde09c44a011a47312726"
dependencies = [
"arrayvec",
"bit-vec",
@ -2347,9 +2358,9 @@ dependencies = [
[[package]]
name = "winnow"
version = "0.5.17"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c"
checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b"
dependencies = [
"memchr",
]
@ -2427,20 +2438,20 @@ checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
[[package]]
name = "zerocopy"
version = "0.7.18"
version = "0.7.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ede7d7c7970ca2215b8c1ccf4d4f354c4733201dfaaba72d44ae5b37472e4901"
checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.18"
version = "0.7.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b27b1bb92570f989aac0ab7e9cbfbacdd65973f7ee920d9f0e71ebac878fd0b"
checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.38",
"syn 2.0.39",
]

@ -629,6 +629,7 @@ impl GraphicsState{
mag_filter: wgpu::FilterMode::Linear,
min_filter: wgpu::FilterMode::Linear,
mipmap_filter: wgpu::FilterMode::Linear,
anisotropy_clamp:16,
..Default::default()
});

@ -22,6 +22,7 @@ pub fn new<'a>(
device:wgpu::Device,
queue:wgpu::Queue,
)->crate::compat_worker::INWorker<'a,Instruction>{
let mut resize=None;
crate::compat_worker::INWorker::new(move |ins:Instruction|{
match ins{
Instruction::GenerateModels(indexed_model_instances)=>{
@ -31,13 +32,20 @@ pub fn new<'a>(
graphics.clear();
},
Instruction::Resize(size,user_settings)=>{
println!("Resizing to {:?}",size);
config.width=size.width.max(1);
config.height=size.height.max(1);
surface.configure(&device,&config);
graphics.resize(&device,&config,&user_settings);
resize=Some((size,user_settings));
}
Instruction::Render(physics_output,predicted_time,mouse_pos)=>{
if let Some((size,user_settings))=&resize{
println!("Resizing to {:?}",size);
let t0=std::time::Instant::now();
config.width=size.width.max(1);
config.height=size.height.max(1);
surface.configure(&device,&config);
graphics.resize(&device,&config,user_settings);
println!("Resize took {:?}",t0.elapsed());
}
//clear every time w/e
resize=None;
//this has to go deeper somehow
let frame=match surface.get_current_texture(){
Ok(frame)=>frame,

@ -217,9 +217,9 @@ type RobloxWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
type RobloxCornerWedgeDescription=[Option<RobloxFaceTextureDescription>;5];
#[derive(Clone,Eq,Hash,PartialEq)]
enum RobloxBasePartDescription{
Sphere,
Sphere(RobloxPartDescription),
Part(RobloxPartDescription),
Cylinder,
Cylinder(RobloxPartDescription),
Wedge(RobloxWedgeDescription),
CornerWedge(RobloxCornerWedgeDescription),
}
@ -298,6 +298,7 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index
panic!("Part has no Shape!");
}
},
"TrussPart"=>primitives::Primitives::Cube,
"WedgePart"=>primitives::Primitives::Wedge,
"CornerWedgePart"=>primitives::Primitives::CornerWedge,
_=>{
@ -392,9 +393,9 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index
f5,//Cube::Front
]=part_texture_description;
let basepart_texture_description=match shape{
primitives::Primitives::Sphere=>RobloxBasePartDescription::Sphere,
primitives::Primitives::Sphere=>RobloxBasePartDescription::Sphere([f0,f1,f2,f3,f4,f5]),
primitives::Primitives::Cube=>RobloxBasePartDescription::Part([f0,f1,f2,f3,f4,f5]),
primitives::Primitives::Cylinder=>RobloxBasePartDescription::Cylinder,
primitives::Primitives::Cylinder=>RobloxBasePartDescription::Cylinder([f0,f1,f2,f3,f4,f5]),
//use front face texture first and use top face texture as a fallback
primitives::Primitives::Wedge=>RobloxBasePartDescription::Wedge([
f0,//Cube::Right->Wedge::Right
@ -420,8 +421,9 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index
let model_id=indexed_models.len();
model_id_from_description.insert(basepart_texture_description.clone(),model_id);//borrow checker going crazy
indexed_models.push(match basepart_texture_description{
RobloxBasePartDescription::Sphere=>primitives::unit_sphere(),
RobloxBasePartDescription::Part(part_texture_description)=>{
RobloxBasePartDescription::Sphere(part_texture_description)
|RobloxBasePartDescription::Cylinder(part_texture_description)
|RobloxBasePartDescription::Part(part_texture_description)=>{
let mut cube_face_description=primitives::CubeFaceDescription::default();
for (face_id,roblox_face_description) in part_texture_description.iter().enumerate(){
cube_face_description.insert(
@ -441,7 +443,6 @@ pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::Index
}
primitives::generate_partial_unit_cube(cube_face_description)
},
RobloxBasePartDescription::Cylinder=>primitives::unit_cylinder(),
RobloxBasePartDescription::Wedge(wedge_texture_description)=>{
let mut wedge_face_description=primitives::WedgeFaceDescription::default();
for (face_id,roblox_face_description) in wedge_texture_description.iter().enumerate(){

@ -2,6 +2,7 @@ mod bvh;
mod aabb;
mod model;
mod setup;
mod world;
mod window;
mod worker;
mod zeroes;
@ -64,49 +65,44 @@ fn load_file(path: std::path::PathBuf)->Option<model::IndexedModelInstances>{
pub fn default_models()->model::IndexedModelInstances{
let mut indexed_models = Vec::new();
indexed_models.append(&mut model::generate_indexed_model_list_from_obj(obj::ObjData::load_buf(&include_bytes!("../models/teslacyberv3.0.obj")[..]).unwrap(),glam::Vec4::ONE));
indexed_models.push(primitives::unit_sphere());
indexed_models.push(primitives::unit_cylinder());
indexed_models.push(primitives::unit_cube());
println!("models.len = {:?}", indexed_models.len());
indexed_models[0].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_translation(glam::vec3(10.,0.,-10.))).unwrap(),
..Default::default()
});
//quad monkeys
indexed_models[1].instances.push(model::ModelInstance{
indexed_models[0].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_translation(glam::vec3(10.,5.,10.))).unwrap(),
..Default::default()
});
indexed_models[1].instances.push(model::ModelInstance{
indexed_models[0].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_translation(glam::vec3(20.,5.,10.))).unwrap(),
color:glam::vec4(1.0,0.0,0.0,1.0),
..Default::default()
});
indexed_models[1].instances.push(model::ModelInstance{
indexed_models[0].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_translation(glam::vec3(10.,5.,20.))).unwrap(),
color:glam::vec4(0.0,1.0,0.0,1.0),
..Default::default()
});
indexed_models[1].instances.push(model::ModelInstance{
indexed_models[0].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_translation(glam::vec3(20.,5.,20.))).unwrap(),
color:glam::vec4(0.0,0.0,1.0,1.0),
..Default::default()
});
//decorative monkey
indexed_models[1].instances.push(model::ModelInstance{
indexed_models[0].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_translation(glam::vec3(15.,10.,15.))).unwrap(),
color:glam::vec4(0.5,0.5,0.5,0.5),
attributes:model::CollisionAttributes::Decoration,
..Default::default()
});
//teapot
indexed_models[2].instances.push(model::ModelInstance{
indexed_models[1].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_scale_rotation_translation(glam::vec3(0.5, 1.0, 0.2),glam::quat(-0.22248298016985793,-0.839457167990537,-0.05603504040830783,-0.49261857546227916),glam::vec3(-10.,7.,10.))).unwrap(),
..Default::default()
});
//ground
indexed_models[3].instances.push(model::ModelInstance{
indexed_models[2].instances.push(model::ModelInstance{
transform:integer::Planar64Affine3::try_from(glam::Affine3A::from_translation(glam::vec3(0.,0.,0.))*glam::Affine3A::from_scale(glam::vec3(160.0, 1.0, 160.0))).unwrap(),
..Default::default()
});

@ -126,152 +126,8 @@ const CORNERWEDGE_DEFAULT_NORMALS:[Planar64Vec3;5]=[
Planar64Vec3::int( 0,-1, 0),//CornerWedge::Bottom
Planar64Vec3::int( 0, 0,-1),//CornerWedge::Front
];
const GON:u32=6;
const SPHERE_STUFF:([[[[u32;3];4];((GON-1)*(GON-1)) as usize];6])={
const CUBE_EDGES:[[u32;2];12]=[[0,1],[0,3],[0,7],[1,2],[1,6],[2,3],[2,5],[3,4],[4,5],[4,7],[5,6],[6,7]];
const fn get_pos_id(p:[[u32;3];4],tex_id:u32)->u32{
if p[0][1]==tex_id{
return p[0][0];
}
if p[1][1]==tex_id{
return p[1][0];
}
if p[2][1]==tex_id{
return p[2][0];
}
if p[3][1]==tex_id{
return p[3][0];
}
panic!("tex missing")
}
const fn get_edge_id(v0:u32,v1:u32)->(u32,bool){
(match if v0<v1{[v0,v1]}else{[v1,v0]}{
[0,1]=>0,
[0,3]=>1,
[0,7]=>2,
[1,2]=>3,
[1,6]=>4,
[2,3]=>5,
[2,5]=>6,
[3,4]=>7,
[4,5]=>8,
[4,7]=>9,
[5,6]=>10,
[6,7]=>11,
_=>panic!(":)")
},v0<v1)
}
const fn get_idx(face_id:u32,v00:u32,v10:u32,v11:u32,v01:u32,x:u32,y:u32)->u32{
if x==0&&y==0{
return v00
}
if x==0&&y==GON-1{
return v01
}
if x==GON-1&&y==GON-1{
return v11
}
if x==GON-1&&y==0{
return v10
}
if x==0{
//left edge
let (edge_id,parity)=get_edge_id(v00,v01);
if parity{
return 8+edge_id*(GON-2)+(y-1)
}else{
return 8+edge_id*(GON-2)+(GON-(y-1))
}
}
if x==GON-1{
//right edge
let (edge_id,parity)=get_edge_id(v10,v11);
if parity{
return 8+edge_id*(GON-2)+(y-1)
}else{
return 8+edge_id*(GON-2)+(GON-(y-1))
}
}
if y==0{
//top edge
let (edge_id,parity)=get_edge_id(v00,v10);
if parity{
return 8+edge_id*(GON-2)+(x-1)
}else{
return 8+edge_id*(GON-2)+(GON-(x-1))
}
}
if y==GON-1{
//bottom edge
let (edge_id,parity)=get_edge_id(v01,v11);
if parity{
return 8+edge_id*(GON-2)+(x-1)
}else{
return 8+edge_id*(GON-2)+(GON-(x-1))
}
}
return 8+12*(GON-2)+face_id*(GON-2)*(GON-2)+(x-1)+(y-1)*(GON-2)
}
//topology (indexed polys)
let mut polys=[[[[0u32;3];4];((GON-1)*(GON-1)) as usize];6];
let mut face_id=0;
while face_id<6{
let p=CUBE_DEFAULT_POLYS[face_id];
//vertex ids
let v00=get_pos_id(p,0);//top left
let v10=get_pos_id(p,1);//top right
let v11=get_pos_id(p,2);//bottom right
let v01=get_pos_id(p,3);//bottom left
let mut i=0;
while i<(GON-1)*(GON-1){
let x=i as u32%GON;
let y=i as u32/GON;
let i00=get_idx(face_id as u32,v00,v10,v11,v01,x+0,y+0);
let i10=get_idx(face_id as u32,v00,v10,v11,v01,x+1,y+0);
let i11=get_idx(face_id as u32,v00,v10,v11,v01,x+1,y+1);
let i01=get_idx(face_id as u32,v00,v10,v11,v01,x+0,y+1);
//[pos,tex,norm]
polys[face_id][i as usize][0]=[i00,(x+0)+(y+0)*GON,i00];
polys[face_id][i as usize][1]=[i10,(x+1)+(y+0)*GON,i10];
polys[face_id][i as usize][2]=[i11,(x+1)+(y+1)*GON,i11];
polys[face_id][i as usize][3]=[i01,(x+0)+(y+1)*GON,i01];
i+=1;
}
face_id+=1;
}
//verts
const N_VERTS:usize=(8+12*(GON-2)+6*(GON-2)*(GON-2)) as usize;
let mut verts=[Planar64Vec3::ZERO;N_VERTS];
let mut i=0;
while i<8{
verts[i]=CUBE_DEFAULT_VERTICES[i].normalize();
i+=1;
}
i=0;
while i<12{
//
}
i=0;
while i<6{
//
}
//tex
let mut tex=[TextureCoordinate::new(0.0,0.0);(GON*GON) as usize];
let mut i=0;
while i<(GON*GON) as usize{
let x=i as u32%GON;
let y=i as u32/GON;
tex[i]=TextureCoordinate::new(x as f32/(GON-1) as f32,y as f32/(GON-1) as f32);
i+=1;
}
(verts,tex,polys)
};
pub fn unit_sphere()->crate::model::IndexedModel{
let mut indexed_model=crate::model::generate_indexed_model_list_from_obj(obj::ObjData::load_buf(&include_bytes!("../models/suzanne.obj")[..]).unwrap(),Color4::ONE).remove(0);
for pos in indexed_model.unique_pos.iter_mut(){
*pos=*pos/2;
}
indexed_model
unit_cube()
}
#[derive(Default)]
pub struct CubeFaceDescription([Option<FaceDescription>;6]);
@ -293,13 +149,8 @@ pub fn unit_cube()->crate::model::IndexedModel{
t.insert(CubeFace::Front,FaceDescription::default());
generate_partial_unit_cube(t)
}
const TEAPOT_TRANSFORM:crate::integer::Planar64Mat3=crate::integer::Planar64Mat3::int_from_cols_array([0,1,0, -1,0,0, 0,0,1]);
pub fn unit_cylinder()->crate::model::IndexedModel{
let mut indexed_model=crate::model::generate_indexed_model_list_from_obj(obj::ObjData::load_buf(&include_bytes!("../models/teapot.obj")[..]).unwrap(),Color4::ONE).remove(0);
for pos in indexed_model.unique_pos.iter_mut(){
*pos=TEAPOT_TRANSFORM*(*pos)/10;
}
indexed_model
unit_cube()
}
#[derive(Default)]
pub struct WedgeFaceDescription([Option<FaceDescription>;5]);

69
src/world.rs Normal file

@ -0,0 +1,69 @@
use crate::integer::{Time,Planar64Vec3};
use crate::instruction::TimedInstruction;
/// A C0 continuous trajectory change.
enum TrajectoryC0{
TargetPointFuture(Planar64Vec3,Time),
TargetVelocityFuture(Planar64Vec3,Time),
UseAcceleration(Planar64Vec3),
}
/// A C1 continuous trajectory change.
enum TrajectoryC1{
TargetPointVelocityFuture(Planar64Vec3,Planar64Vec3,Time),
UseVelocityAcceleration(Planar64Vec3,Planar64Vec3),
TargetPointAcceleration(Planar64Vec3,Planar64Vec3),
}
struct Trajectory{
position:Planar64Vec3,
velocity:Planar64Vec3,
acceleration:Planar64Vec3,
}
impl Trajectory{
pub fn into_body(self,time:Time)->crate::physics::Body{
crate::physics::Body::new(self.position,self.velocity,self.acceleration,time)
}
}
//literally option... Option<Option<T>> doesn't seem ergonomic but is effectively what's needed
enum Edit<T>{
Change(T),
Unchanged,
}
/// Each property is specified as either changed or staying the same
struct EditAttributes{}
struct EditStyleModifiers{}
enum Instruction{
/// Keep Position, edit Velocity and Acceleration
ContinueTrajectoryC0(TrajectoryC0),
/// Keep Position and Velocity, edit acceleration
ContinueTrajectoryC1(TrajectoryC1),
/// Teleport to a new Position, Velocity, and Acceleration
NewTrajectory(Trajectory),
/// Change the object transform (teleport) This is also how the object must rotate!
EditTransform(crate::integer::Planar64Affine3),
/// Change specific attributes
EditAttributes(EditAttributes),
/// Change specific style modifiers
EditStyleModifiers(EditStyleModifiers),
}
// The moving platform script init function returns this object's initial state
struct Dynamic{
/// somehow allow a mutable state function to control the whole thing
pub next_instruction:Option<TimedInstruction<Instruction>>,
pub update:Box<dyn FnMut(TimedInstruction<Instruction>)->Option<TimedInstruction<Instruction>>>,
}
impl crate::instruction::InstructionEmitter<Instruction> for Dynamic{
fn next_instruction(&self,time_limit:Time)->Option<TimedInstruction<Instruction>>{
self.next_instruction
}
}
impl crate::instruction::InstructionConsumer<Instruction> for Dynamic{
fn process_instruction(&mut self,instruction:TimedInstruction<Instruction>){
self.next_instruction=(self.update)(instruction);
}
}

1
tools/surf_maps Symbolic link

@ -0,0 +1 @@
/run/media/quat/Files/Documents/map-files/verify-scripts/maps/surf_all/

1
tools/utopia Executable file

@ -0,0 +1 @@
mangohud ../target/release/strafe-client surf_maps/5692145408.rbxm