diff --git a/Cargo.lock b/Cargo.lock index 1cba836..4e34f2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -75,7 +75,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -85,14 +85,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "anyhow" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "app" @@ -199,23 +199,19 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" -version = "1.1.35" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f57c4b4da2a9d619dd035f27316d7a426305b75be93d09e92f2b9229c34feaf" +checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" dependencies = [ "shlex", ] -[[package]] -name = "cesium-implicit-tiling" -version = "0.0.1" - [[package]] name = "cesiumtiles" version = "0.0.0" @@ -255,9 +251,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -269,9 +265,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", "clap_derive", @@ -279,9 +275,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstream", "anstyle", @@ -303,9 +299,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "colorchoice" @@ -321,18 +317,18 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "crossbeam-channel" -version = "0.5.13" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" +checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471" dependencies = [ "crossbeam-utils", ] [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -349,15 +345,15 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -411,19 +407,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "fastrand" -version = "2.1.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "fixedbitset" @@ -456,9 +452,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -497,9 +493,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -522,9 +518,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "japan-geoid" @@ -538,10 +534,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -560,9 +557,9 @@ dependencies = [ [[package]] name = "las" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89e691a28279e39726e921332aa421d56d480105afd294f88d7bed5b3a7b7fc" +checksum = "144189522ecba68ea77f214415cc849594457674d11ef5243b9921afbd76c9c7" dependencies = [ "byteorder", "chrono", @@ -586,9 +583,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "linux-raw-sys" @@ -706,9 +703,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -723,9 +720,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" dependencies = [ "bytes", "prost-derive", @@ -733,11 +730,10 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" +checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" dependencies = [ - "bytes", "heck", "itertools", "log", @@ -754,9 +750,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" dependencies = [ "anyhow", "itertools", @@ -767,9 +763,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" +checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" dependencies = [ "prost", ] @@ -834,15 +830,15 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustix" -version = "0.38.39" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -853,18 +849,18 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -909,9 +905,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -928,23 +924,23 @@ dependencies = [ "fastrand", "once_cell", "rustix", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -965,9 +961,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "utf8parse" @@ -995,9 +991,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -1006,13 +1002,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -1021,9 +1016,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1031,9 +1026,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -1044,9 +1039,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "windows-core" @@ -1057,15 +1052,6 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.59.0" diff --git a/Cargo.toml b/Cargo.toml index 3590aae..73ef648 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ members = [ "pcd-*", "cesiumtiles-gltf", "projection-transform", - "cesium-implicit-tiling", ] resolver = "2" diff --git a/cesium-implicit-tiling/Cargo.toml b/cesium-implicit-tiling/Cargo.toml deleted file mode 100644 index 50bb50e..0000000 --- a/cesium-implicit-tiling/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "cesium-implicit-tiling" -edition = "2021" -version.workspace = true -authors.workspace = true - -[dependencies] diff --git a/cesium-implicit-tiling/src/lib.rs b/cesium-implicit-tiling/src/lib.rs deleted file mode 100644 index 1d7f3a3..0000000 --- a/cesium-implicit-tiling/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod octree; diff --git a/cesium-implicit-tiling/src/main.rs b/cesium-implicit-tiling/src/main.rs deleted file mode 100644 index 9db3428..0000000 --- a/cesium-implicit-tiling/src/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -use cesium_implicit_tiling::octree::{BoundingVolume, OctreeNode, TileCoord}; - -fn main() { - let bounding_box = BoundingVolume { - min: [0.0, 0.0, 0.0], - max: [1.0, 1.0, 1.0], - }; - - let subdivision_count = 2; - let octree = OctreeNode::build(bounding_box.clone(), (0, 0, 0, 0), subdivision_count); - - println!("{}", octree); -} diff --git a/cesium-implicit-tiling/src/octree.rs b/cesium-implicit-tiling/src/octree.rs deleted file mode 100644 index 2b84bb3..0000000 --- a/cesium-implicit-tiling/src/octree.rs +++ /dev/null @@ -1,229 +0,0 @@ -use std::fmt; - -#[derive(Debug, Default)] -pub struct TileCoord { - pub level: u32, - pub xyz: [u32; 3], -} - -impl TileCoord { - pub fn new(tile_coord: [u32; 4]) -> TileCoord { - TileCoord { - level: tile_coord[0], - xyz: [tile_coord[1], tile_coord[2], tile_coord[3]], - } - } - - pub fn interleave_bits(&self) -> u64 { - fn part1by2(mut n: u64) -> u64 { - n &= 0x1fffff; - n = (n | n << 32) & 0x1f00000000ffff; - n = (n | n << 16) & 0x1f0000ff0000ff; - n = (n | n << 8) & 0x100f00f00f00f00f; - n = (n | n << 4) & 0x10c30c30c30c30c3; - n = (n | n << 2) & 0x1249249249249249; - n - } - - let [x, y, z] = &self.xyz; - - let mx = part1by2(*x as u64); - let my = part1by2(*y as u64); - let mz = part1by2(*z as u64); - - mx | (my << 1) | (mz << 2) - } - - pub fn deinterleave_bits(morton_code: u64) -> (u32, u32, u32) { - fn compact1by2(mut n: u64) -> u32 { - n &= 0x1249249249249249; - n = (n ^ (n >> 2)) & 0x10c30c30c30c30c3; - n = (n ^ (n >> 4)) & 0x100f00f00f00f00f; - n = (n ^ (n >> 8)) & 0x1f0000ff0000ff; - n = (n ^ (n >> 16)) & 0x1f00000000ffff; - n = (n ^ (n >> 32)) & 0x1fffff; - n as u32 - } - - let x = compact1by2(morton_code); - let y = compact1by2(morton_code >> 1); - let z = compact1by2(morton_code >> 2); - - (x, y, z) - } -} - -#[derive(Clone, Debug, Default, PartialEq)] -pub struct BoundingVolume { - pub min: [f64; 3], - pub max: [f64; 3], -} - -#[derive(Debug, Default)] -pub struct OctreeNode { - pub bounding_volume: BoundingVolume, - pub tile_coord: TileCoord, - pub children: Option<[Box; 8]>, -} - -impl OctreeNode { - pub fn build( - bounding_box: BoundingVolume, - tile_coords: (u32, u32, u32, u32), - depth: u32, - ) -> Self { - if depth == 0 { - let tile_coords_object = TileCoord { - level: tile_coords.0, - xyz: [tile_coords.1, tile_coords.2, tile_coords.3], - }; - return OctreeNode { - bounding_volume: bounding_box, - tile_coord: tile_coords_object, - children: None, - }; - } - - let min = &bounding_box.min; - let max = &bounding_box.max; - - let mid = [ - (min[0] + max[0]) / 2.0, - (min[1] + max[1]) / 2.0, - (min[2] + max[2]) / 2.0, - ]; - - let mut children: [Box; 8] = Default::default(); - - for i in 0..8 { - let dx = (i >> 0) & 1; - let dy = (i >> 1) & 1; - let dz = (i >> 2) & 1; - - let child_min = [ - if dx == 0 { min[0] } else { mid[0] }, - if dy == 0 { min[1] } else { mid[1] }, - if dz == 0 { min[2] } else { mid[2] }, - ]; - let child_max = [ - if dx == 0 { mid[0] } else { max[0] }, - if dy == 0 { mid[1] } else { max[1] }, - if dz == 0 { mid[2] } else { max[2] }, - ]; - - let child_bounding_box = BoundingVolume { - min: child_min, - max: child_max, - }; - - let child_tile_coords = ( - tile_coords.0 + 1, // level + 1 - tile_coords.1 * 2 + dx as u32, // x * 2 + dx - tile_coords.2 * 2 + dy as u32, // y * 2 + dy - tile_coords.3 * 2 + dz as u32, // z * 2 + dz - ); - - children[i] = Box::new(OctreeNode::build( - child_bounding_box, - child_tile_coords, - depth - 1, - )); - } - - let tile_coords_object = TileCoord { - level: tile_coords.0, - xyz: [tile_coords.1, tile_coords.2, tile_coords.3], - }; - - OctreeNode { - bounding_volume: bounding_box, - tile_coord: tile_coords_object, - children: Some(children), - } - } -} - -impl fmt::Display for OctreeNode { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let level = self.tile_coord.level; - let [x, y, z] = self.tile_coord.xyz; - writeln!( - f, - "Level: {}, x: {}, y: {}, z: {}, Bounding Volume: {:?}", - level, x, y, z, self.bounding_volume - )?; - if let Some(children) = &self.children { - for child in children.iter() { - write!(f, "{}", child)?; - } - } - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_morton_order_conversion() { - let level: u32 = 0; - let x: u32 = 0b001; - let y: u32 = 0b010; - let z: u32 = 0b100; - - let tile_coord = TileCoord::new([level, x, y, z]); - let morton_code = tile_coord.interleave_bits(); - println!("x: {}, y: {}, z: {}, morton_code: {}", x, y, z, morton_code); - assert_eq!(0b100010001, morton_code); - - let (dx, dy, dz) = TileCoord::deinterleave_bits(morton_code); - println!("Decoded: x = {}, y = {}, z = {}", dx, dy, dz); - assert_eq!(x, dx); - assert_eq!(y, dy); - assert_eq!(z, dz); - } - - #[test] - fn test_octree_construction() { - let bounding_box = BoundingVolume { - min: [0.0, 0.0, 0.0], - max: [1.0, 1.0, 1.0], - }; - - let subdivision_count = 2; - let octree = OctreeNode::build(bounding_box.clone(), (0, 0, 0, 0), subdivision_count); - - let root_coord_level = 0; - let root_coord_xyz = [0, 0, 0]; - assert_eq!(octree.tile_coord.level, root_coord_level); - assert_eq!(octree.tile_coord.xyz, root_coord_xyz); - assert_eq!(octree.bounding_volume, bounding_box); - assert!(octree.children.is_some()); - - if let Some(children) = octree.children { - assert_eq!(children.len(), 8); - - let first_child = &children[0]; - let first_child_coord_level = 1; - let first_child_coord_xyz = [0, 0, 0]; - assert_eq!(first_child.tile_coord.level, first_child_coord_level); - assert_eq!(first_child.tile_coord.xyz, first_child_coord_xyz); - assert_eq!( - first_child.bounding_volume, - BoundingVolume { - min: [0.0, 0.0, 0.0], - max: [0.5, 0.5, 0.5], - } - ); - assert!(first_child.children.is_some()); - - if let Some(grand_children) = &first_child.children { - for grand_child in grand_children.iter() { - assert_eq!(grand_child.tile_coord.level, 2); - assert!(grand_child.children.is_none()); - } - } - } - } -} diff --git a/cesiumtiles-gltf/src/glb.rs b/cesiumtiles-gltf/src/glb.rs index 2e37923..a99154d 100644 --- a/cesiumtiles-gltf/src/glb.rs +++ b/cesiumtiles-gltf/src/glb.rs @@ -17,7 +17,7 @@ pub struct Glb<'a> { pub bin: Option>, } -impl<'a> Glb<'a> { +impl Glb<'_> { /// Write GLB to writer. pub fn to_writer(&self, writer: W) -> std::io::Result<()> { self.to_writer_with_alignment(writer, 4)