diff --git a/Cargo.lock b/Cargo.lock index 298e334c49..097c0e9674 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,9 +42,6 @@ name = "ahash" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" -dependencies = [ - "const-random", -] [[package]] name = "ahash" @@ -235,12 +232,6 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" -[[package]] -name = "ascii" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf56136a5198c7b01a49e3afcbef6cf84597273d298f54432926024107b0109" - [[package]] name = "assets_manager" version = "0.4.2" @@ -259,39 +250,25 @@ dependencies = [ ] [[package]] -name = "async-std" -version = "1.5.0" +name = "async-channel" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267" +checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" dependencies = [ - "async-task", - "broadcaster", - "crossbeam-channel 0.4.4", - "crossbeam-deque 0.7.3", - "crossbeam-utils 0.7.2", + "concurrent-queue", + "event-listener", "futures-core", - "futures-io", - "futures-timer 2.0.2", - "kv-log-macro", - "log", - "memchr", - "mio 0.6.22", - "mio-uds", - "num_cpus", - "once_cell", - "pin-project-lite", - "pin-utils", - "slab", ] [[package]] -name = "async-task" -version = "1.3.1" +name = "async-trait" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ac2c016b079e771204030951c366db398864f5026f84a44dafb0ff20f02085d" +checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" dependencies = [ - "libc", - "winapi 0.3.9", + "proc-macro2 1.0.24", + "quote 1.0.7", + "syn 1.0.54", ] [[package]] @@ -427,9 +404,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bitvec" -version = "0.20.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5011ffc90248764d7005b0e10c7294f5aa1bd87d9dd7248f4ad475b347c294d" +checksum = "d23f76a953a42e113af6b4f3481ca32ff0a1ddbdcaa714a2333c956807b74a5f" dependencies = [ "funty", "radium", @@ -454,20 +431,6 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" -[[package]] -name = "broadcaster" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87" -dependencies = [ - "futures-channel", - "futures-core", - "futures-sink", - "futures-util", - "parking_lot 0.10.2", - "slab", -] - [[package]] name = "bstr" version = "0.2.13" @@ -512,23 +475,24 @@ version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "either", - "iovec", -] - [[package]] name = "bytes" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + +[[package]] +name = "cache-padded" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" + [[package]] name = "calloop" version = "0.6.4" @@ -771,7 +735,7 @@ version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da3da6baa321ec19e1cc41d31bf599f00c783d0517095cdaf0332e3fe8d20680" dependencies = [ - "ascii 0.9.3", + "ascii", "byteorder", "either", "memchr", @@ -786,7 +750,16 @@ checksum = "2809f67365382d65fd2b6d9c22577231b954ed27400efeafbe687bda75abcc0b" dependencies = [ "bytes 0.5.6", "memchr", - "pin-project-lite", + "pin-project-lite 0.1.9", +] + +[[package]] +name = "concurrent-queue" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +dependencies = [ + "cache-padded", ] [[package]] @@ -819,54 +792,6 @@ name = "conrod_winit" version = "0.63.0" source = "git+https://gitlab.com/veloren/conrod.git?branch=copypasta_0.7#1ae5193588fb662a7189d81edd9f2d653c7f1da0" -[[package]] -name = "const-random" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f1af9ac737b2dd2d577701e59fd09ba34822f6f2ebdb30a7647405d9e55e16a" -dependencies = [ - "const-random-macro", - "proc-macro-hack", -] - -[[package]] -name = "const-random-macro" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25e4c606eb459dd29f7c57b2e0879f2b6f14ee130918c2b78ccb58a9624e6c7a" -dependencies = [ - "getrandom 0.1.15", - "proc-macro-hack", -] - -[[package]] -name = "const-tweaker" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297be2ecc39b6e680c7bb03d8d053a483c32a61d95bd758fca76e9b95ce7e276" -dependencies = [ - "async-std", - "const-tweaker-attribute", - "ctor", - "dashmap", - "horrorshow", - "lazy_static", - "serde", - "tide", -] - -[[package]] -name = "const-tweaker-attribute" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d709e38f0f6100c0c8c0b3aefb0aa1f83af865d7b6b267e8402820513a0c0d8" -dependencies = [ - "darling", - "proc-macro2 1.0.24", - "quote 1.0.7", - "syn 1.0.54", -] - [[package]] name = "const_fn" version = "0.4.3" @@ -1130,16 +1055,17 @@ dependencies = [ [[package]] name = "criterion" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" dependencies = [ "atty", "cast", "clap", "criterion-plot", "csv", - "itertools 0.9.0", + "futures", + "itertools 0.10.0", "lazy_static", "num-traits 0.2.14", "oorandom", @@ -1151,6 +1077,7 @@ dependencies = [ "serde_derive", "serde_json", "tinytemplate", + "tokio 1.2.0", "walkdir 2.3.1", ] @@ -1174,19 +1101,10 @@ dependencies = [ "crossbeam-channel 0.5.0", "crossbeam-deque 0.8.0", "crossbeam-epoch 0.9.0", - "crossbeam-queue 0.3.1", + "crossbeam-queue", "crossbeam-utils 0.8.1", ] -[[package]] -name = "crossbeam-channel" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" -dependencies = [ - "crossbeam-utils 0.6.6", -] - [[package]] name = "crossbeam-channel" version = "0.4.4" @@ -1258,17 +1176,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - [[package]] name = "crossbeam-queue" version = "0.3.1" @@ -1279,16 +1186,6 @@ dependencies = [ "crossbeam-utils 0.8.1", ] -[[package]] -name = "crossbeam-utils" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" -dependencies = [ - "cfg-if 0.1.10", - "lazy_static", -] - [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -1321,7 +1218,7 @@ dependencies = [ "crossterm_winapi", "lazy_static", "libc", - "mio 0.7.0", + "mio 0.7.9", "parking_lot 0.10.2", "signal-hook 0.1.16", "winapi 0.3.9", @@ -1337,7 +1234,7 @@ dependencies = [ "crossterm_winapi", "lazy_static", "libc", - "mio 0.7.0", + "mio 0.7.9", "parking_lot 0.11.0", "signal-hook 0.1.16", "winapi 0.3.9", @@ -1374,16 +1271,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ctor" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fbaabec2c953050352311293be5c6aba8e141ba19d6811862b232d6fd020484" -dependencies = [ - "quote 1.0.7", - "syn 1.0.54", -] - [[package]] name = "daggy" version = "0.5.0" @@ -1428,23 +1315,6 @@ dependencies = [ "syn 1.0.54", ] -[[package]] -name = "dashmap" -version = "3.11.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f260e2fc850179ef410018660006951c1b55b79e8087e87111a2c388994b9b5" -dependencies = [ - "ahash 0.3.8", - "cfg-if 0.1.10", - "num_cpus", -] - -[[package]] -name = "data-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d0e2d24e5ee3b23a01de38eefdcd978907890701f08ffffd4cb457ca4ee8d6" - [[package]] name = "deflate" version = "0.8.6" @@ -1700,10 +1570,11 @@ dependencies = [ [[package]] name = "euc" -version = "0.5.1" -source = "git+https://github.com/zesterer/euc.git#c9a7c17a03d45fce00caeeca09afa1e1558cd183" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed019c07d54f49d3efd699f68c47ced2958b9917fca7c48092c489792732faa5" dependencies = [ - "vek 0.11.2", + "vek 0.10.4", ] [[package]] @@ -1715,6 +1586,12 @@ dependencies = [ "num-traits 0.2.14", ] +[[package]] +name = "event-listener" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" + [[package]] name = "fallible-iterator" version = "0.2.0" @@ -1859,15 +1736,9 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "funty" -version = "1.0.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ba62103ce691c2fd80fbae2213dfdda9ce60804973ac6b6e97de818ea7f52c8" - -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +checksum = "1847abb9cb65d566acd5942e94aea9c8f547ad02c98e1649326fc0e8910b8b1e" [[package]] name = "futures" @@ -1900,16 +1771,6 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -dependencies = [ - "futures 0.1.29", - "num_cpus", -] - [[package]] name = "futures-executor" version = "0.3.5" @@ -1955,25 +1816,12 @@ dependencies = [ "once_cell", ] -[[package]] -name = "futures-timer" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" - -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - [[package]] name = "futures-util" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" dependencies = [ - "futures 0.1.29", "futures-channel", "futures-core", "futures-io", @@ -1986,7 +1834,6 @@ dependencies = [ "proc-macro-hack", "proc-macro-nested", "slab", - "tokio-io", ] [[package]] @@ -2092,9 +1939,9 @@ dependencies = [ [[package]] name = "gilrs" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122bb249f904e5f4ac73fc514b9b2ce6cce3af511f5df00ffc8000e47de6b290" +checksum = "3b64ac678e1174eb012be1cfd409ff2483f23cb79bc880ce4737147245b0fbff" dependencies = [ "fnv", "gilrs-core", @@ -2107,17 +1954,18 @@ dependencies = [ [[package]] name = "gilrs-core" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43c758daf46af26d6872fe55507e3b2339779a160a06ad7a9b2a082f221209cd" +checksum = "1024d4046c5c67d2adb8c90f6ed235163b58e05d35a63bf699b53f0cceeba2c6" dependencies = [ "core-foundation 0.6.4", "io-kit-sys", "libc", "libudev-sys", "log", - "nix 0.15.0", + "nix 0.18.0", "rusty-xinput", + "serde", "stdweb 0.4.20", "uuid", "vec_map", @@ -2307,24 +2155,6 @@ dependencies = [ "svg_fmt", ] -[[package]] -name = "h2" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" -dependencies = [ - "byteorder", - "bytes 0.4.12", - "fnv", - "futures 0.1.29", - "http 0.1.21", - "indexmap", - "log", - "slab", - "string", - "tokio-io", -] - [[package]] name = "h2" version = "0.2.7" @@ -2336,7 +2166,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http 0.2.2", + "http", "indexmap", "slab", "tokio 0.2.24", @@ -2427,29 +2257,12 @@ dependencies = [ "rayon", ] -[[package]] -name = "horrorshow" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ce7e0a1bc8e4489896abc94e5664e811a502a151bebfe113b3214fa181d3fb" - [[package]] name = "hound" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a164bb2ceaeff4f42542bdb847c41517c78a60f5649671b2a07312b6e117549" -[[package]] -name = "http" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" -dependencies = [ - "bytes 0.4.12", - "fnv", - "itoa", -] - [[package]] name = "http" version = "0.2.2" @@ -2461,18 +2274,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "http 0.1.21", - "tokio-buf", -] - [[package]] name = "http-body" version = "0.3.1" @@ -2480,32 +2281,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ "bytes 0.5.6", - "http 0.2.2", + "http", ] [[package]] -name = "http-service" +name = "http-body" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9625f605ddfaf894bf78a544a7b8e31f562dc843654723a49892d9c7e75ac708" +checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" dependencies = [ - "async-std", - "bytes 0.4.12", - "futures 0.3.5", - "http 0.1.21", - "pin-project-lite", -] - -[[package]] -name = "http-service-hyper" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d5dae94e0fdb82f9524ea2f2b98458b3d8448526d8cc8beccb3d3fded8aff" -dependencies = [ - "futures 0.3.5", - "http 0.1.21", - "http-service", - "hyper 0.12.35", + "bytes 1.0.1", + "http", ] [[package]] @@ -2520,36 +2306,6 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" -[[package]] -name = "hyper" -version = "0.12.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "futures-cpupool", - "h2 0.1.26", - "http 0.1.21", - "http-body 0.1.0", - "httparse", - "iovec", - "itoa", - "log", - "net2", - "rustc_version", - "time", - "tokio 0.1.22", - "tokio-buf", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "want 0.2.0", -] - [[package]] name = "hyper" version = "0.13.9" @@ -2560,8 +2316,8 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.2.7", - "http 0.2.2", + "h2", + "http", "http-body 0.3.1", "httparse", "httpdate", @@ -2571,7 +2327,30 @@ dependencies = [ "tokio 0.2.24", "tower-service", "tracing", - "want 0.3.0", + "want", +] + +[[package]] +name = "hyper" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8e946c2b1349055e0b72ae281b238baf1a3ea7307c7e9f9d64673bdd9c26ac7" +dependencies = [ + "bytes 1.0.1", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body 0.4.0", + "httparse", + "httpdate", + "itoa", + "pin-project 1.0.2", + "socket2", + "tokio 1.2.0", + "tower-service", + "tracing", + "want", ] [[package]] @@ -2600,7 +2379,7 @@ name = "iced_futures" version = "0.2.0" source = "git+https://github.com/hecrj/iced?rev=8d882d787e6b7fd7c2435f42f82933e2ed904edf#8d882d787e6b7fd7c2435f42f82933e2ed904edf" dependencies = [ - "futures 0.3.5", + "futures", "log", "wasm-bindgen-futures", ] @@ -2873,15 +2652,6 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] - [[package]] name = "lazy-bytes-cast" version = "5.0.1" @@ -2919,9 +2689,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.77" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" +checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213" [[package]] name = "libflate" @@ -3264,14 +3034,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.0" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e9971bc8349a361217a8f2a41f5d011274686bd4436465ba51730921039d7fb" +checksum = "a5dede4e2065b3842b8b0af444119f3aa331cc7cc2dd20388bfb0f5d5a38823a" dependencies = [ - "lazy_static", "libc", "log", - "miow 0.3.5", + "miow 0.3.6", "ntapi", "winapi 0.3.9", ] @@ -3288,17 +3057,6 @@ dependencies = [ "slab", ] -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio 0.6.22", -] - [[package]] name = "miow" version = "0.2.1" @@ -3313,9 +3071,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" dependencies = [ "socket2", "winapi 0.3.9", @@ -3798,9 +3556,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.4.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] name = "oorandom" @@ -4041,6 +3799,12 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fe74897791e156a0cd8cce0db31b9b2198e67877316bf3086c3acd187f719f0" +[[package]] +name = "pin-project-lite" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cf491442e4b033ed1c722cb9f0df5fcfcf4de682466c46469c36bc47dc5548a" + [[package]] name = "pin-utils" version = "0.1.0" @@ -4082,16 +3846,32 @@ checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" [[package]] name = "plotters" -version = "0.2.15" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d1685fbe7beba33de0330629da9d955ac75bd54f33d7b79f9a895590124f6bb" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" dependencies = [ - "js-sys", "num-traits 0.2.14", + "plotters-backend", + "plotters-svg", "wasm-bindgen", "web-sys", ] +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + [[package]] name = "png" version = "0.16.7" @@ -4195,6 +3975,18 @@ dependencies = [ "thiserror", ] +[[package]] +name = "prometheus-hyper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc47fa532a12d544229015dd3fae32394949af098b8fe9a327b8c1e4c911d1c8" +dependencies = [ + "hyper 0.14.4", + "prometheus", + "tokio 1.2.0", + "tracing", +] + [[package]] name = "qstring" version = "0.7.2" @@ -4566,7 +4358,7 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "http 0.2.2", + "http", "http-body 0.3.1", "hyper 0.13.9", "hyper-rustls", @@ -4577,7 +4369,7 @@ dependencies = [ "mime", "mime_guess", "percent-encoding 2.1.0", - "pin-project-lite", + "pin-project-lite 0.1.9", "rustls 0.18.1", "serde", "serde_json", @@ -4641,12 +4433,6 @@ version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84348444bd7ad45729d0c49a4240d7cdc11c9d512c06c5ad1835c1ad4acda6db" -[[package]] -name = "route-recognizer" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea509065eb0b3c446acdd0102f0d46567dc30902dc0be91d6552035d92b0f4f8" - [[package]] name = "rust-argon2" version = "0.8.2" @@ -4886,18 +4672,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_qs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d43eef44996bbe16e99ac720e1577eefa16f7b76b5172165c98ced20ae9903e1" -dependencies = [ - "data-encoding", - "error-chain", - "percent-encoding 1.0.1", - "serde", -] - [[package]] name = "serde_repr" version = "0.1.6" @@ -5000,7 +4774,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" dependencies = [ "libc", - "mio 0.7.0", + "mio 0.7.9", "signal-hook-registry", ] @@ -5115,13 +4889,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.15" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi 0.3.9", ] @@ -5130,7 +4903,7 @@ name = "specs" version = "0.16.1" source = "git+https://github.com/amethyst/specs.git?rev=d4435bdf496cf322c74886ca09dd8795984919b4#d4435bdf496cf322c74886ca09dd8795984919b4" dependencies = [ - "crossbeam-queue 0.3.1", + "crossbeam-queue", "hashbrown 0.9.1", "hibitset", "log", @@ -5148,8 +4921,8 @@ version = "0.4.1" source = "git+https://github.com/amethyst/specs.git?rev=d4435bdf496cf322c74886ca09dd8795984919b4#d4435bdf496cf322c74886ca09dd8795984919b4" dependencies = [ "proc-macro2 1.0.24", - "quote 1.0.9", - "syn 1.0.60", + "quote 1.0.7", + "syn 1.0.54", ] [[package]] @@ -5260,15 +5033,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d44a3643b4ff9caf57abcee9c2c621d6c03d9135e0d8b589bd9afb5992cb176a" -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -dependencies = [ - "bytes 0.4.12", -] - [[package]] name = "strsim" version = "0.8.0" @@ -5430,27 +5194,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "tide" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e619c99048ae107912703d0efeec4ff4fbff704f064e51d3eee614b28ea7b739" -dependencies = [ - "async-std", - "cookie", - "futures 0.3.5", - "http 0.1.21", - "http-service", - "http-service-hyper", - "log", - "mime", - "pin-project-lite", - "route-recognizer", - "serde", - "serde_json", - "serde_qs", -] - [[package]] name = "time" version = "0.1.44" @@ -5462,19 +5205,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "tiny_http" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15ce4fc3c4cdea1a4399bb1819a539195fb69db4bbe0bde5b7c7f18fed412e02" -dependencies = [ - "ascii 1.0.0", - "chrono", - "chunked_transfer", - "log", - "url 2.1.1", -] - [[package]] name = "tinytemplate" version = "1.1.0" @@ -5491,24 +5221,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "mio 0.6.22", - "num_cpus", - "tokio-current-thread", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-threadpool", - "tokio-timer", -] - [[package]] name = "tokio" version = "0.2.24" @@ -5523,69 +5235,38 @@ dependencies = [ "memchr", "mio 0.6.22", "num_cpus", - "pin-project-lite", + "pin-project-lite 0.1.9", "slab", ] [[package]] -name = "tokio-buf" -version = "0.1.1" +name = "tokio" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" +checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a" dependencies = [ - "bytes 0.4.12", - "either", - "futures 0.1.29", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.29", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "log", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", - "lazy_static", - "log", - "mio 0.6.22", + "autocfg 1.0.1", + "bytes 1.0.1", + "libc", + "memchr", + "mio 0.7.9", "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", + "once_cell", + "pin-project-lite 0.2.5", + "signal-hook-registry", + "tokio-macros", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-macros" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.7", + "syn 1.0.54", ] [[package]] @@ -5601,56 +5282,14 @@ dependencies = [ ] [[package]] -name = "tokio-sync" -version = "0.1.8" +name = "tokio-stream" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" +checksum = "1981ad97df782ab506a1f43bf82c967326960d278acf3bf8279809648c3ff3ea" dependencies = [ - "fnv", - "futures 0.1.29", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.29", - "iovec", - "mio 0.6.22", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque 0.7.3", - "crossbeam-queue 0.2.3", - "crossbeam-utils 0.7.2", - "futures 0.1.29", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.29", - "slab", - "tokio-executor", + "futures-core", + "pin-project-lite 0.2.5", + "tokio 1.2.0", ] [[package]] @@ -5663,7 +5302,7 @@ dependencies = [ "futures-core", "futures-sink", "log", - "pin-project-lite", + "pin-project-lite 0.1.9", "tokio 0.2.24", ] @@ -5684,13 +5323,13 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" [[package]] name = "tracing" -version = "0.1.21" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0987850db3733619253fe60e17cb59b82d37c7e6c0236bb81e4d6b87c879f27" +checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "log", - "pin-project-lite", + "pin-project-lite 0.2.5", "tracing-attributes", "tracing-core", ] @@ -5708,9 +5347,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" +checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", @@ -5979,28 +5618,6 @@ dependencies = [ "serde", ] -[[package]] -name = "uvth" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e59a167890d173eb0fcd7a1b99b84dc05c521ae8d76599130b8e19bef287abbf" -dependencies = [ - "crossbeam-channel 0.3.9", - "log", - "num_cpus", -] - -[[package]] -name = "uvth" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e5910f9106b96334c6cae1f1d77a764bda66ac4ca9f507f73259f184fe1bb6b" -dependencies = [ - "crossbeam-channel 0.3.9", - "log", - "num_cpus", -] - [[package]] name = "vcpkg" version = "0.2.10" @@ -6015,9 +5632,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "vek" -version = "0.11.2" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2657d8704e5e0be82b60157c8dbc71a269273ad766984508fdc54030a0690c4d" +checksum = "4e44defd4e0c629bdc842e5d180dda428b3abd2c6b0c7e1fced8c718f65d5f77" dependencies = [ "approx 0.3.2", "num-integer", @@ -6029,13 +5646,26 @@ dependencies = [ [[package]] name = "vek" -version = "0.12.0" -source = "git+https://gitlab.com/veloren/vek.git?branch=fix_intrinsics#237a78528b505f34f6dde5dc77db3b642388fe4a" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2657d8704e5e0be82b60157c8dbc71a269273ad766984508fdc54030a0690c4d" dependencies = [ "approx 0.3.2", "num-integer", "num-traits 0.2.14", "rustc_version", + "static_assertions", +] + +[[package]] +name = "vek" +version = "0.14.1" +source = "git+https://gitlab.com/veloren/vek.git?branch=fix_intrinsics2#df6842cc874a697dec8896c66851817e744af7e8" +dependencies = [ + "approx 0.4.0", + "num-integer", + "num-traits 0.2.14", + "rustc_version", "serde", "static_assertions", ] @@ -6046,29 +5676,27 @@ version = "0.8.0" dependencies = [ "authc", "byteorder", - "futures-executor", - "futures-timer 3.0.2", "futures-util", "hashbrown 0.9.1", "image", "num 0.3.1", - "num_cpus", "rayon", "specs", + "tokio 1.2.0", "tracing", "tracing-subscriber", - "uvth 3.1.1", - "vek 0.12.0", + "vek 0.14.1", "veloren-common", "veloren-common-net", "veloren-common-sys", - "veloren_network", + "veloren-network", ] [[package]] name = "veloren-common" version = "0.8.0" dependencies = [ + "approx 0.4.0", "arraygen", "assets_manager", "criterion", @@ -6101,7 +5729,7 @@ dependencies = [ "tracing", "tracy-client", "uuid", - "vek 0.12.0", + "vek 0.14.1", ] [[package]] @@ -6115,7 +5743,7 @@ dependencies = [ "sum_type", "tracing", "tracy-client", - "vek 0.12.0", + "vek 0.14.1", "veloren-common", ] @@ -6136,13 +5764,56 @@ dependencies = [ "toml", "tracing", "tracy-client", - "vek 0.12.0", + "vek 0.14.1", "veloren-common", "veloren-common-net", "veloren-plugin-api", "wasmer", ] +[[package]] +name = "veloren-network" +version = "0.3.0" +dependencies = [ + "async-channel", + "async-trait", + "bincode", + "bitflags", + "bytes 1.0.1", + "clap", + "criterion", + "crossbeam-channel 0.5.0", + "futures-core", + "futures-util", + "lazy_static", + "lz-fear", + "prometheus", + "prometheus-hyper", + "rand 0.8.3", + "serde", + "shellexpand", + "tokio 1.2.0", + "tokio-stream", + "tracing", + "tracing-subscriber", + "veloren-network-protocol", +] + +[[package]] +name = "veloren-network-protocol" +version = "0.6.0" +dependencies = [ + "async-channel", + "async-trait", + "bitflags", + "bytes 1.0.1", + "criterion", + "prometheus", + "rand 0.8.3", + "tokio 1.2.0", + "tracing", +] + [[package]] name = "veloren-plugin-api" version = "0.1.0" @@ -6177,14 +5848,10 @@ version = "0.8.0" dependencies = [ "authc", "chrono", - "const-tweaker", "crossbeam-channel 0.5.0", "diesel", "diesel_migrations", "dotenv", - "futures-channel", - "futures-executor", - "futures-timer 3.0.2", "futures-util", "hashbrown 0.9.1", "itertools 0.9.0", @@ -6192,6 +5859,7 @@ dependencies = [ "libsqlite3-sys", "portpicker", "prometheus", + "prometheus-hyper", "rand 0.8.3", "rayon", "ron", @@ -6201,16 +5869,15 @@ dependencies = [ "slab", "specs", "specs-idvs", - "tiny_http", + "tokio 1.2.0", "tracing", - "uvth 3.1.1", - "vek 0.12.0", + "vek 0.14.1", "veloren-common", "veloren-common-net", "veloren-common-sys", + "veloren-network", "veloren-plugin-api", "veloren-world", - "veloren_network", ] [[package]] @@ -6225,6 +5892,7 @@ dependencies = [ "serde", "signal-hook 0.2.2", "termcolor", + "tokio 1.2.0", "tracing", "tracing-subscriber", "tracing-tracy", @@ -6243,8 +5911,8 @@ dependencies = [ "chrono", "conrod_core", "conrod_winit", - "const-tweaker", "copy_dir", + "coreaudio-sys", "cpal", "criterion", "crossbeam", @@ -6272,6 +5940,7 @@ dependencies = [ "lazy_static", "native-dialog", "num 0.3.1", + "num_cpus", "old_school_gfx_glutin_ext", "ordered-float 2.0.1", "rand 0.8.3", @@ -6281,14 +5950,14 @@ dependencies = [ "specs", "specs-idvs", "termcolor", + "tokio 1.2.0", "tracing", "tracing-appender", "tracing-log", "tracing-subscriber", "tracing-tracy", "treeculler", - "uvth 3.1.1", - "vek 0.12.0", + "vek 0.14.1", "veloren-client", "veloren-common", "veloren-common-net", @@ -6311,7 +5980,7 @@ dependencies = [ "libloading 0.6.3", "notify 5.0.0-pre.3", "tracing", - "vek 0.12.0", + "vek 0.14.1", "veloren-common", ] @@ -6343,34 +6012,11 @@ dependencies = [ "svg_fmt", "tracing", "tracing-subscriber", - "vek 0.12.0", + "vek 0.14.1", "veloren-common", "veloren-common-net", ] -[[package]] -name = "veloren_network" -version = "0.2.0" -dependencies = [ - "async-std", - "bincode", - "bitflags", - "clap", - "crossbeam-channel 0.5.0", - "futures 0.3.5", - "lazy_static", - "lz-fear", - "prometheus", - "rand 0.8.3", - "serde", - "shellexpand", - "tiny_http", - "tracing", - "tracing-futures", - "tracing-subscriber", - "uvth 4.0.1", -] - [[package]] name = "version_check" version = "0.1.5" @@ -6410,17 +6056,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "want" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" -dependencies = [ - "futures 0.1.29", - "log", - "try-lock", -] - [[package]] name = "want" version = "0.3.0" diff --git a/common/src/path.rs b/common/src/path.rs index 8c5eab36ea..0743191b0c 100644 --- a/common/src/path.rs +++ b/common/src/path.rs @@ -33,12 +33,10 @@ impl FromIterator for Path { } impl IntoIterator for Path { - type Item = T; type IntoIter = std::vec::IntoIter; + type Item = T; - fn into_iter(self) -> Self::IntoIter { - self.nodes.into_iter() - } + fn into_iter(self) -> Self::IntoIter { self.nodes.into_iter() } } impl Path { diff --git a/common/src/store.rs b/common/src/store.rs index 6666ccadd4..2b819dd47d 100644 --- a/common/src/store.rs +++ b/common/src/store.rs @@ -1,5 +1,5 @@ use std::{ - cmp::{Eq, PartialEq, Ord, PartialOrd, Ordering}, + cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}, fmt, hash, marker::PhantomData, ops::{Index, IndexMut}, @@ -30,14 +30,10 @@ impl PartialEq for Id { fn eq(&self, other: &Self) -> bool { self.idx == other.idx && self.gen == other.gen } } impl Ord for Id { - fn cmp(&self, other: &Self) -> Ordering { - (self.idx, self.gen).cmp(&(other.idx, other.gen)) - } + fn cmp(&self, other: &Self) -> Ordering { (self.idx, self.gen).cmp(&(other.idx, other.gen)) } } impl PartialOrd for Id { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } + fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl fmt::Debug for Id { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -77,9 +73,7 @@ impl Default for Store { } impl Store { - pub fn len(&self) -> usize { - self.len - } + pub fn len(&self) -> usize { self.len } pub fn contains(&self, id: Id) -> bool { self.entries diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index f10c028252..c82fe87355 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -364,7 +364,7 @@ image_ids! { mmap_site_cave_bg: "voxygen.element.map.cave_bg", mmap_site_cave_hover: "voxygen.element.map.cave_hover", mmap_site_cave: "voxygen.element.map.cave", - mmap_site_excl: "voxygen.element.map.excl", + mmap_site_excl: "voxygen.element.map.excl", // Window Parts window_3: "voxygen.element.frames.window_3", diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index b31720d8b9..bca1b2ffe9 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -586,8 +586,10 @@ impl<'a> Widget for Map<'a> { if show_caves { site_btn.set(state.ids.mmap_site_icons[i], ui); } - }, - _ => {site_btn.set(state.ids.mmap_site_icons[i], ui);}, + }, + _ => { + site_btn.set(state.ids.mmap_site_icons[i], ui); + }, } // Difficulty from 0-6 diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index 8812f5a348..de08a545a7 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -380,9 +380,15 @@ impl<'a, V: RectRasterableVol + ReadVol + Debug + 'static> let greedy_size_cross = Vec3::new(greedy_size.x - 1, greedy_size.y - 1, greedy_size.z); let draw_delta = Vec3::new(1, 1, z_start); - let get_light = |_: &mut (), pos: Vec3| volume - .get(range.min + pos) - .map_or(1.0, |b| if b.is_opaque() { 0.0 } else { light(pos + range.min) }); + let get_light = |_: &mut (), pos: Vec3| { + volume.get(range.min + pos).map_or(1.0, |b| { + if b.is_opaque() { + 0.0 + } else { + light(pos + range.min) + } + }) + }; let get_glow = |_: &mut (), pos: Vec3| glow(pos + range.min); let get_color = |_: &mut (), pos: Vec3| flat_get(pos).get_color().unwrap_or(Rgb::zero()); diff --git a/voxygen/src/scene/math.rs b/voxygen/src/scene/math.rs index f228b33ebe..dcd43c4efd 100644 --- a/voxygen/src/scene/math.rs +++ b/voxygen/src/scene/math.rs @@ -2,7 +2,8 @@ use core::{iter, mem}; use hashbrown::HashMap; use num::traits::Float; pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, vec::repr_simd::*}; -//pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, vec::repr_c::*}; +//pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, +// vec::repr_c::*}; pub fn aabb_to_points(bounds: Aabb) -> [Vec3; 8] { [ diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 345d6d79b3..c69a98aa62 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -3,7 +3,7 @@ mod watcher; pub use self::watcher::BlocksOfInterest; use crate::{ - mesh::{greedy::GreedyMesh, Meshable, terrain::SUNLIGHT}, + mesh::{greedy::GreedyMesh, terrain::SUNLIGHT, Meshable}, render::{ ColLightFmt, ColLightInfo, Consts, FluidPipeline, GlobalModel, Instances, Mesh, Model, RenderError, Renderer, ShadowPipeline, SpriteInstance, SpriteLocals, SpritePipeline, @@ -524,22 +524,35 @@ impl Terrain { .map(|c| c.blocks_of_interest.lights.iter()) .into_iter() .flatten() - .map(move |(lpos, level)| (Vec3::::from(chunk_pos * TerrainChunk::RECT_SIZE.map(|e| e as i32)) + *lpos, level)) + .map(move |(lpos, level)| { + ( + Vec3::::from( + chunk_pos * TerrainChunk::RECT_SIZE.map(|e| e as i32), + ) + *lpos, + level, + ) + }) }) .flatten() - .fold((Vec3::broadcast(0.001), 0.0, 0.0f32), |(bias, total, max), (lpos, level)| { - let rpos = lpos.map(|e| e as f32 + 0.5) - wpos; - let level = (*level as f32 - rpos.magnitude()).max(0.0) / SUNLIGHT as f32; - ( - bias + rpos.try_normalized().unwrap_or_else(Vec3::zero) * level, - total + level, - max.max(level), - ) - }); + .fold( + (Vec3::broadcast(0.001), 0.0, 0.0f32), + |(bias, total, max), (lpos, level)| { + let rpos = lpos.map(|e| e as f32 + 0.5) - wpos; + let level = (*level as f32 - rpos.magnitude()).max(0.0) / SUNLIGHT as f32; + ( + bias + rpos.try_normalized().unwrap_or_else(Vec3::zero) * level, + total + level, + max.max(level), + ) + }, + ); let bias_factor = bias.magnitude() * (1.0 - AMBIANCE) / total.max(0.001); - (bias.try_normalized().unwrap_or_else(Vec3::zero) * bias_factor.powf(0.5), self.glow_at_wpos(wpos.map(|e| e.floor() as i32))) + ( + bias.try_normalized().unwrap_or_else(Vec3::zero) * bias_factor.powf(0.5), + self.glow_at_wpos(wpos.map(|e| e.floor() as i32)), + ) } /// Maintain terrain data. To be called once per tick. @@ -630,21 +643,19 @@ impl Terrain { // be meshed span!(guard, "Add chunks with modified blocks to mesh todo list"); // TODO: would be useful if modified blocks were grouped by chunk - for (&pos, &block) in scene_data - .state - .terrain_changes() - .modified_blocks - .iter() - { - // TODO: Be cleverer about this to avoid remeshing all neighbours. There are a few things that can create - // an 'effect at a distance'. These are as follows: - // - A glowing block is added or removed, thereby causing a lighting recalculation proportional to its glow - // radius. - // - An opaque block that was blocking sunlight from entering a cavity is removed (or added) thereby + for (&pos, &block) in scene_data.state.terrain_changes().modified_blocks.iter() { + // TODO: Be cleverer about this to avoid remeshing all neighbours. There are a + // few things that can create an 'effect at a distance'. These are + // as follows: + // - A glowing block is added or removed, thereby causing a lighting + // recalculation proportional to its glow radius. + // - An opaque block that was blocking sunlight from entering a cavity is + // removed (or added) thereby // changing the way that sunlight propagates into the cavity. // - // We can and should be cleverer about this, but it's non-trivial. For now, just conservatively assume that - // the lighting in all neighbouring chunks is invalidated. Thankfully, this doesn't need to happen often + // We can and should be cleverer about this, but it's non-trivial. For now, just + // conservatively assume that the lighting in all neighbouring + // chunks is invalidated. Thankfully, this doesn't need to happen often // because block modification is unusual in Veloren. // let block_effect_radius = block.get_glow().unwrap_or(0).max(1); let block_effect_radius = crate::mesh::terrain::MAX_LIGHT_DIST; diff --git a/world/src/all.rs b/world/src/all.rs index 40158af578..030952d731 100644 --- a/world/src/all.rs +++ b/world/src/all.rs @@ -1,7 +1,7 @@ -use std::ops::Range; -use enum_iterator::IntoEnumIterator; -use vek::*; use crate::util::math::close; +use enum_iterator::IntoEnumIterator; +use std::ops::Range; +use vek::*; #[derive(Copy, Clone, Debug, IntoEnumIterator)] pub enum ForestKind { @@ -33,7 +33,7 @@ impl ForestKind { ForestKind::Birch => 0.0..0.6, ForestKind::Mangrove => 0.65..1.3, ForestKind::Swamp => 0.5..1.1, - _ => 0.0..0.0 + _ => 0.0..0.0, } } @@ -76,9 +76,11 @@ impl ForestKind { pub fn proclivity(&self, env: &Environment) -> f32 { self.ideal_proclivity() - * close(env.humid, self.humid_range()) - * close(env.temp, self.temp_range()) - * self.near_water_range().map_or(1.0, |near_water_range| close(env.near_water, near_water_range)) + * close(env.humid, self.humid_range()) + * close(env.temp, self.temp_range()) + * self.near_water_range().map_or(1.0, |near_water_range| { + close(env.near_water, near_water_range) + }) } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 4defa2e087..a1284ac22e 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -1,6 +1,6 @@ use crate::{ column::{ColumnGen, ColumnSample}, - util::{RandomField, Sampler, SmallCache, FastNoise}, + util::{FastNoise, RandomField, Sampler, SmallCache}, IndexRef, }; use common::terrain::{ @@ -121,14 +121,22 @@ impl<'a> BlockGen<'a> { if stone_factor >= 0.5 { if wposf.z as f32 > height - cliff_offset.max(0.0) { - if cliff_offset.max(0.0) > cliff_height - (FastNoise::new(37).get(wposf / Vec3::new(6.0, 6.0, 10.0)) * 0.5 + 0.5) * (height - grass_depth - wposf.z as f32).mul(0.25).clamped(0.0, 8.0) { + if cliff_offset.max(0.0) + > cliff_height + - (FastNoise::new(37).get(wposf / Vec3::new(6.0, 6.0, 10.0)) * 0.5 + + 0.5) + * (height - grass_depth - wposf.z as f32) + .mul(0.25) + .clamped(0.0, 8.0) + { Some(Block::empty()) } else { let col = Lerp::lerp( col.map(|e| e as f32), col.map(|e| e as f32) * 0.7, (wposf.z as f32 - basement * 0.3).div(2.0).sin() * 0.5 + 0.5, - ).map(|e| e as u8); + ) + .map(|e| e as u8); Some(Block::new(BlockKind::Rock, col)) } } else { @@ -198,7 +206,9 @@ pub struct ZCache<'a> { impl<'a> ZCache<'a> { pub fn get_z_limits(&self) -> (f32, f32) { - let min = self.sample.alt - (self.sample.chaos.min(1.0) * 16.0) - self.sample.cliff_offset.max(0.0); + let min = self.sample.alt + - (self.sample.chaos.min(1.0) * 16.0) + - self.sample.cliff_offset.max(0.0); let min = min - 4.0; let rocks = if self.sample.rock > 0.0 { 12.0 } else { 0.0 }; diff --git a/world/src/canvas.rs b/world/src/canvas.rs index abc6f3a4b7..940ef051db 100644 --- a/world/src/canvas.rs +++ b/world/src/canvas.rs @@ -2,9 +2,9 @@ use crate::{ block::ZCache, column::ColumnSample, index::IndexRef, + land::Land, sim::{SimChunk, WorldSim}, util::Grid, - land::Land, }; use common::{ terrain::{Block, TerrainChunk, TerrainChunkSize}, @@ -48,9 +48,7 @@ impl<'a> CanvasInfo<'a> { pub fn chunks(&self) -> &'a WorldSim { self.chunks } - pub fn land(&self) -> Land<'_> { - Land::from_sim(self.chunks) - } + pub fn land(&self) -> Land<'_> { Land::from_sim(self.chunks) } } pub struct Canvas<'a> { @@ -66,7 +64,11 @@ impl<'a> Canvas<'a> { pub fn info(&mut self) -> CanvasInfo<'a> { self.info } pub fn get(&mut self, pos: Vec3) -> Block { - self.chunk.get(pos - self.wpos()).ok().copied().unwrap_or(Block::empty()) + self.chunk + .get(pos - self.wpos()) + .ok() + .copied() + .unwrap_or(Block::empty()) } pub fn set(&mut self, pos: Vec3, block: Block) { diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 19bac38ed2..45b7be02ef 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -7,10 +7,9 @@ use crate::{ config::CONFIG, sim::WorldSim, site::{namegen::NameGen, Castle, Dungeon, Settlement, Site as WorldSite}, - util::{attempt, seed_expan, MapVec, CARDINALS, NEIGHBORS}, site2, - Index, - Land, + util::{attempt, seed_expan, MapVec, CARDINALS, NEIGHBORS}, + Index, Land, }; use common::{ astar::Astar, @@ -216,9 +215,11 @@ impl Civs { SiteKind::Castle => { WorldSite::castle(Castle::generate(wpos, Some(ctx.sim), &mut rng)) }, - SiteKind::Refactor => { - WorldSite::refactor(site2::Site::generate(&Land::from_sim(&ctx.sim), &mut rng, wpos)) - }, + SiteKind::Refactor => WorldSite::refactor(site2::Site::generate( + &Land::from_sim(&ctx.sim), + &mut rng, + wpos, + )), }); sim_site.site_tmp = Some(site); let site_ref = &index.sites[site]; diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index a24ed76f23..5719b6a5ca 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -272,11 +272,12 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { .rem_euclid(200.0) / 64.0 - 1.0; - let cliff_scale = ((self.sim.gen_ctx.hill_nz.get(wposf.div(128.0).into_array()) as f32 * 1.5 + 0.75) - + self.sim.gen_ctx.hill_nz.get(wposf.div(48.0).into_array()) as f32 * 0.1) - .clamped(0.0, 1.0).powf(2.0); - let cliff_height = - sim.get_interpolated(wpos, |chunk| chunk.cliff_height)? * cliff_scale; + let cliff_scale = + ((self.sim.gen_ctx.hill_nz.get(wposf.div(128.0).into_array()) as f32 * 1.5 + 0.75) + + self.sim.gen_ctx.hill_nz.get(wposf.div(48.0).into_array()) as f32 * 0.1) + .clamped(0.0, 1.0) + .powf(2.0); + let cliff_height = sim.get_interpolated(wpos, |chunk| chunk.cliff_height)? * cliff_scale; let cliff = if cliff_factor < 0.0 { cliff_factor.abs().powf(1.5) } else { diff --git a/world/src/land.rs b/world/src/land.rs index 2bf8ec6b09..8384251647 100644 --- a/world/src/land.rs +++ b/world/src/land.rs @@ -1,31 +1,31 @@ use crate::sim; -use common::{ - terrain::TerrainChunkSize, - vol::RectVolSize, -}; +use common::{terrain::TerrainChunkSize, vol::RectVolSize}; use vek::*; -/// A wrapper type that may contain a reference to a generated world. If not, default values will be provided. +/// A wrapper type that may contain a reference to a generated world. If not, +/// default values will be provided. pub struct Land<'a> { sim: Option<&'a sim::WorldSim>, } impl<'a> Land<'a> { - pub fn empty() -> Self { - Self { sim: None } - } + pub fn empty() -> Self { Self { sim: None } } - pub fn from_sim(sim: &'a sim::WorldSim) -> Self { - Self { sim: Some(sim) } - } + pub fn from_sim(sim: &'a sim::WorldSim) -> Self { Self { sim: Some(sim) } } pub fn get_alt_approx(&self, wpos: Vec2) -> f32 { - self.sim.and_then(|sim| sim.get_alt_approx(wpos)).unwrap_or(0.0) + self.sim + .and_then(|sim| sim.get_alt_approx(wpos)) + .unwrap_or(0.0) } pub fn get_gradient_approx(&self, wpos: Vec2) -> f32 { self.sim - .and_then(|sim| sim.get_gradient_approx(wpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e.div_euclid(sz as i32)))) + .and_then(|sim| { + sim.get_gradient_approx( + wpos.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e.div_euclid(sz as i32)), + ) + }) .unwrap_or(0.0) } diff --git a/world/src/layer/mod.rs b/world/src/layer/mod.rs index 2ee84d558f..64e5d99e58 100644 --- a/world/src/layer/mod.rs +++ b/world/src/layer/mod.rs @@ -161,7 +161,10 @@ pub fn apply_caves_to(canvas: &mut Canvas, rng: &mut impl Rng) { .mul(45.0) as i32; // Generate stalagtites if there's something for them to hold on to - if canvas.get(Vec3::new(wpos2d.x, wpos2d.y, cave_roof)).is_filled() { + if canvas + .get(Vec3::new(wpos2d.x, wpos2d.y, cave_roof)) + .is_filled() + { for z in cave_roof - stalagtites..cave_roof { canvas.set( Vec3::new(wpos2d.x, wpos2d.y, z), diff --git a/world/src/layer/scatter.rs b/world/src/layer/scatter.rs index 870ba6ad0e..3c3d03ab1b 100644 --- a/world/src/layer/scatter.rs +++ b/world/src/layer/scatter.rs @@ -577,11 +577,15 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) { // surface if let Some(solid_end) = (-4..8) .find(|z| { - canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z)).is_solid() + canvas + .get(Vec3::new(wpos2d.x, wpos2d.y, alt + z)) + .is_solid() }) .and_then(|solid_start| { (1..8).map(|z| solid_start + z).find(|z| { - !canvas.get(Vec3::new(wpos2d.x, wpos2d.y, alt + z)).is_solid() + !canvas + .get(Vec3::new(wpos2d.x, wpos2d.y, alt + z)) + .is_solid() }) }) { diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 9198f08bd6..c7b0969d03 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -60,7 +60,14 @@ pub fn apply_trees_to(canvas: &mut Canvas, dynamic_rng: &mut impl Rng) { canvas.foreach_col(|canvas, wpos2d, col| { let trees = info.chunks().get_near_trees(wpos2d); - for TreeAttr { pos, seed, scale, forest_kind, inhabited } in trees { + for TreeAttr { + pos, + seed, + scale, + forest_kind, + inhabited, + } in trees + { let tree = if let Some(tree) = tree_cache.entry(pos).or_insert_with(|| { let col = ColumnGen::new(info.chunks()).get((pos, info.index()))?; @@ -127,7 +134,11 @@ pub fn apply_trees_to(canvas: &mut Canvas, dynamic_rng: &mut impl Rng) { ForestKind::Giant => { break 'model TreeModel::Procedural( ProceduralTree::generate( - TreeConfig::giant(&mut RandomPerm::new(seed), scale, inhabited), + TreeConfig::giant( + &mut RandomPerm::new(seed), + scale, + inhabited, + ), &mut RandomPerm::new(seed), ), StructureBlock::TemperateLeaves, @@ -184,7 +195,9 @@ pub fn apply_trees_to(canvas: &mut Canvas, dynamic_rng: &mut impl Rng) { TreeModel::Structure(s) => s.get(model_pos).ok().copied(), TreeModel::Procedural(t, leaf_block) => Some( match t.is_branch_or_leaves_at(model_pos.map(|e| e as f32 + 0.5)) { - (_, _, true, _) => StructureBlock::Block(BlockKind::Wood, Rgb::new(110, 68, 22)), + (_, _, true, _) => { + StructureBlock::Block(BlockKind::Wood, Rgb::new(110, 68, 22)) + }, (_, _, _, true) => StructureBlock::None, (true, _, _, _) => StructureBlock::Log, (_, true, _, _) => *leaf_block, @@ -204,9 +217,14 @@ pub fn apply_trees_to(canvas: &mut Canvas, dynamic_rng: &mut impl Rng) { ) .map(|block| { // Add lights to the tree - if inhabited && last_block.is_air() && block.kind() == BlockKind::Wood && dynamic_rng.gen_range(0..256) == 0 { + if inhabited + && last_block.is_air() + && block.kind() == BlockKind::Wood + && dynamic_rng.gen_range(0..256) == 0 + { canvas.set(wpos + Vec3::unit_z(), Block::air(SpriteKind::Lantern)); - // Add a snow covering to the block above under certain circumstances + // Add a snow covering to the block above under certain + // circumstances } else if col.snow_cover && ((block.kind() == BlockKind::Leaves && is_leaf_top) || (is_top && block.is_filled())) @@ -423,8 +441,7 @@ impl ProceduralTree { const PHI: f32 = 0.618; const RAD_PER_BRANCH: f32 = f32::consts::TAU * PHI; - let screw = (screw_shift + dist * splits as f32 * RAD_PER_BRANCH).sin() - * x_axis + let screw = (screw_shift + dist * splits as f32 * RAD_PER_BRANCH).sin() * x_axis + (screw_shift + dist * splits as f32 * RAD_PER_BRANCH).cos() * y_axis; // Choose a point close to the branch to act as the target direction for the @@ -488,7 +505,12 @@ impl ProceduralTree { pub fn get_bounds(&self) -> Aabb { self.branches[self.trunk_idx].aabb } // Recursively search for branches or leaves by walking the tree's branch graph. - fn is_branch_or_leaves_at_inner(&self, pos: Vec3, parent: &Branch, branch_idx: usize) -> (bool, bool, bool, bool) { + fn is_branch_or_leaves_at_inner( + &self, + pos: Vec3, + parent: &Branch, + branch_idx: usize, + ) -> (bool, bool, bool, bool) { let branch = &self.branches[branch_idx]; // Always probe the sibling branch, since our AABB doesn't include its bounds // (it's not one of our children) @@ -506,7 +528,8 @@ impl ProceduralTree { let siblings = branch_or_leaves | Vec4::from(this); // Probe the children of this branch - let children = branch.child_idx + let children = branch + .child_idx .map(|idx| Vec4::::from(self.is_branch_or_leaves_at_inner(pos, branch, idx))) .unwrap_or_default(); @@ -521,8 +544,9 @@ impl ProceduralTree { /// position in the tree. #[inline(always)] pub fn is_branch_or_leaves_at(&self, pos: Vec3) -> (bool, bool, bool, bool) { - let (log, leaf, platform, air) = self.is_branch_or_leaves_at_inner(pos, &self.branches[self.trunk_idx], self.trunk_idx); - (log /*& !air*/, leaf & !air, platform & !air, air) + let (log, leaf, platform, air) = + self.is_branch_or_leaves_at_inner(pos, &self.branches[self.trunk_idx], self.trunk_idx); + (log /* & !air */, leaf & !air, platform & !air, air) } } @@ -547,7 +571,11 @@ struct Branch { impl Branch { /// Determine whether there are either branches or leaves at the given /// position in the branch. - pub fn is_branch_or_leaves_at(&self, pos: Vec3, parent: &Branch) -> ((bool, bool, bool, bool), f32) { + pub fn is_branch_or_leaves_at( + &self, + pos: Vec3, + parent: &Branch, + ) -> ((bool, bool, bool, bool), f32) { // fn finvsqrt(x: f32) -> f32 { // let y = f32::from_bits(0x5f375a86 - (x.to_bits() >> 1)); // y * (1.5 - ( x * 0.5 * y * y )) @@ -588,20 +616,32 @@ impl Branch { let stair_thickness = 2.0; let stair_space = 5.0; if self.has_stairs { - let (platform, air) = if pos.z >= self.line.start.z.min(self.line.end.z) - 1.0 && pos.z <= self.line.start.z.max(self.line.end.z) + stair_thickness + stair_space && d2 < (wood_radius + stair_width).powi(2) { + let (platform, air) = if pos.z >= self.line.start.z.min(self.line.end.z) - 1.0 + && pos.z + <= self.line.start.z.max(self.line.end.z) + stair_thickness + stair_space + && d2 < (wood_radius + stair_width).powi(2) + { let rpos = pos.xy() - p; let stretch = 32.0; - let stair_section = ((rpos.x as f32).atan2(rpos.y as f32) / (f32::consts::PI * 2.0) * stretch + pos.z).rem_euclid(stretch); - (stair_section < stair_thickness, stair_section >= stair_thickness && stair_section < stair_thickness + stair_space) // Stairs + let stair_section = + ((rpos.x as f32).atan2(rpos.y as f32) / (f32::consts::PI * 2.0) * stretch + + pos.z) + .rem_euclid(stretch); + ( + stair_section < stair_thickness, + stair_section >= stair_thickness + && stair_section < stair_thickness + stair_space, + ) // Stairs } else { (false, false) }; - let platform = platform || (self.has_stairs - && self.wood_radius > 4.0 - && !air - && d2 < (wood_radius + 10.0).powi(2) - && pos.z % 48.0 < stair_thickness); + let platform = platform + || (self.has_stairs + && self.wood_radius > 4.0 + && !air + && d2 < (wood_radius + 10.0).powi(2) + && pos.z % 48.0 < stair_thickness); (false, false, platform, air) } else { diff --git a/world/src/sim/map.rs b/world/src/sim/map.rs index 7541757361..8ac6747b97 100644 --- a/world/src/sim/map.rs +++ b/world/src/sim/map.rs @@ -166,7 +166,11 @@ pub fn sample_pos( }); let downhill_wpos = downhill.unwrap_or(wpos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32)); - let alt = if is_basement { basement } else { column_rgb_alt.map_or(alt, |(_, alt)| alt) }; + let alt = if is_basement { + basement + } else { + column_rgb_alt.map_or(alt, |(_, alt)| alt) + }; let true_water_alt = (alt.max(water_alt) as f64 - focus.z) / gain as f64; let true_alt = (alt as f64 - focus.z) / gain as f64; diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 258e264f49..39d69b1d81 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -29,22 +29,22 @@ use crate::{ column::ColumnGen, site::Site, util::{ - seed_expan, FastNoise, FastNoise2d, RandomField, RandomPerm, Sampler, StructureGen2d, LOCALITY, - NEIGHBORS, CARDINALS, DHashSet, + seed_expan, DHashSet, FastNoise, FastNoise2d, RandomField, RandomPerm, Sampler, + StructureGen2d, CARDINALS, LOCALITY, NEIGHBORS, }, IndexRef, CONFIG, }; use common::{ assets::{self, AssetExt}, grid::Grid, + lottery::Lottery, + spiral::Spiral2d, store::Id, terrain::{ map::MapConfig, uniform_idx_as_vec2, vec2_as_uniform_idx, BiomeKind, MapSizeLg, TerrainChunkSize, }, vol::RectVolSize, - lottery::Lottery, - spiral::Spiral2d, }; use common_net::msg::WorldMapMsg; use enum_iterator::IntoEnumIterator; @@ -1535,7 +1535,10 @@ impl WorldSim { pos += CARDINALS .iter() .copied() - .max_by_key(|rpos| self.get_gradient_approx(pos + rpos).map_or(0, |g| (g * 1000.0) as i32)) + .max_by_key(|rpos| { + self.get_gradient_approx(pos + rpos) + .map_or(0, |g| (g * 1000.0) as i32) + }) .unwrap(); // Can't fail } else { break; @@ -1563,8 +1566,8 @@ impl WorldSim { // self.get_mut(locs[2].0).unwrap().cliff.0.neighbors |= // 1 << ((to_next_idx as u8 + 4) % 8); - // self.get_mut(locs[1].0).unwrap().cliff.0.offset = Vec2::new(rng.gen_range(-16..17), rng.gen_range(-16..17)); - // } + // self.get_mut(locs[1].0).unwrap().cliff.0.offset = + // Vec2::new(rng.gen_range(-16..17), rng.gen_range(-16..17)); } for cliff in cliffs { let alt = self.get(cliff).map_or(0.0, |c| c.alt); @@ -2076,21 +2079,30 @@ impl WorldSim { let env = Environment { humid: chunk.humidity, temp: chunk.temp, - near_water: if chunk.river.is_lake() || chunk.river.near_river() { 1.0 } else { 0.0 }, + near_water: if chunk.river.is_lake() || chunk.river.near_river() { + 1.0 + } else { + 0.0 + }, }; Some(TreeAttr { pos, seed, scale: 1.0, - forest_kind: *Lottery::from(ForestKind::into_enum_iter() - .enumerate() - .map(|(i, fk)| { - const CLUSTER_SIZE: f64 = 48.0; - let nz = (FastNoise2d::new(i as u32 * 37).get(pos.map(|e| e as f64) / CLUSTER_SIZE) + 1.0) / 2.0; - (fk.proclivity(&env) * nz, fk) - }) - .collect::>()) - .choose_seeded(seed), + forest_kind: *Lottery::from( + ForestKind::into_enum_iter() + .enumerate() + .map(|(i, fk)| { + const CLUSTER_SIZE: f64 = 48.0; + let nz = (FastNoise2d::new(i as u32 * 37) + .get(pos.map(|e| e as f64) / CLUSTER_SIZE) + + 1.0) + / 2.0; + (fk.proclivity(&env) * nz, fk) + }) + .collect::>(), + ) + .choose_seeded(seed), inhabited: false, }) }); @@ -2344,7 +2356,11 @@ impl SimChunk { let env = Environment { humid: humidity, temp, - near_water: if river.is_lake() || river.near_river() { 1.0 } else { 0.0 }, + near_water: if river.is_lake() || river.near_river() { + 1.0 + } else { + 0.0 + }, }; ForestKind::into_enum_iter() @@ -2393,7 +2409,5 @@ impl SimChunk { } } - pub fn near_cliffs(&self) -> bool { - self.cliff_height > 0.0 - } + pub fn near_cliffs(&self) -> bool { self.cliff_height > 0.0 } } diff --git a/world/src/site/mod.rs b/world/src/site/mod.rs index a18b4ca1ae..77d6f12428 100644 --- a/world/src/site/mod.rs +++ b/world/src/site/mod.rs @@ -11,12 +11,7 @@ pub use self::{ settlement::Settlement, }; -use crate::{ - column::ColumnSample, - IndexRef, - site2, - Canvas, -}; +use crate::{column::ColumnSample, site2, Canvas, IndexRef}; use common::{ generation::ChunkSupplement, terrain::Block, @@ -118,11 +113,7 @@ impl Site { } } - pub fn apply_to<'a>( - &'a self, - canvas: &mut Canvas, - dynamic_rng: &mut impl Rng, - ) { + pub fn apply_to<'a>(&'a self, canvas: &mut Canvas, dynamic_rng: &mut impl Rng) { let info = canvas.info(); let get_col = |wpos| info.col(wpos + info.wpos); match &self.kind { diff --git a/world/src/site2/gen.rs b/world/src/site2/gen.rs index 642d83cdce..5431264cf2 100644 --- a/world/src/site2/gen.rs +++ b/world/src/site2/gen.rs @@ -1,7 +1,7 @@ use super::*; use common::{ - terrain::Block, store::{Id, Store}, + terrain::Block, }; use vek::*; @@ -26,9 +26,11 @@ pub struct Fill { impl Fill { fn contains_at(&self, tree: &Store, prim: Id, pos: Vec3) -> bool { // Custom closure because vek's impl of `contains_point` is inclusive :( - let aabb_contains = |aabb: Aabb, pos: Vec3| (aabb.min.x..aabb.max.x).contains(&pos.x) - && (aabb.min.y..aabb.max.y).contains(&pos.y) - && (aabb.min.z..aabb.max.z).contains(&pos.z); + let aabb_contains = |aabb: Aabb, pos: Vec3| { + (aabb.min.x..aabb.max.x).contains(&pos.x) + && (aabb.min.y..aabb.max.y).contains(&pos.y) + && (aabb.min.z..aabb.max.z).contains(&pos.z) + }; match &tree[prim] { Primitive::Empty => false, @@ -36,15 +38,28 @@ impl Fill { Primitive::Aabb(aabb) => aabb_contains(*aabb, pos), Primitive::Pyramid { aabb, inset } => { let inset = (*inset).max(aabb.size().reduce_min()); - let inner = Aabr { min: aabb.min.xy() - 1 + inset, max: aabb.max.xy() - inset }; - aabb_contains(*aabb, pos) && (inner.projected_point(pos.xy()) - pos.xy()) - .map(|e| e.abs()) - .reduce_max() as f32 / (inset as f32) < 1.0 - ((pos.z - aabb.min.z) as f32 + 0.5) / (aabb.max.z - aabb.min.z) as f32 + let inner = Aabr { + min: aabb.min.xy() - 1 + inset, + max: aabb.max.xy() - inset, + }; + aabb_contains(*aabb, pos) + && (inner.projected_point(pos.xy()) - pos.xy()) + .map(|e| e.abs()) + .reduce_max() as f32 + / (inset as f32) + < 1.0 + - ((pos.z - aabb.min.z) as f32 + 0.5) / (aabb.max.z - aabb.min.z) as f32 }, - Primitive::And(a, b) => self.contains_at(tree, *a, pos) && self.contains_at(tree, *b, pos), - Primitive::Or(a, b) => self.contains_at(tree, *a, pos) || self.contains_at(tree, *b, pos), - Primitive::Xor(a, b) => self.contains_at(tree, *a, pos) ^ self.contains_at(tree, *b, pos), + Primitive::And(a, b) => { + self.contains_at(tree, *a, pos) && self.contains_at(tree, *b, pos) + }, + Primitive::Or(a, b) => { + self.contains_at(tree, *a, pos) || self.contains_at(tree, *b, pos) + }, + Primitive::Xor(a, b) => { + self.contains_at(tree, *a, pos) ^ self.contains_at(tree, *b, pos) + }, } } @@ -65,14 +80,22 @@ impl Fill { Primitive::Empty => return None, Primitive::Aabb(aabb) => *aabb, Primitive::Pyramid { aabb, .. } => *aabb, - Primitive::And(a, b) => or_zip_with(self.get_bounds_inner(tree, *a), self.get_bounds_inner(tree, *b), |a, b| a.intersection(b))?, - Primitive::Or(a, b) | Primitive::Xor(a, b) => - or_zip_with(self.get_bounds_inner(tree, *a), self.get_bounds_inner(tree, *b), |a, b| a.union(b))?, + Primitive::And(a, b) => or_zip_with( + self.get_bounds_inner(tree, *a), + self.get_bounds_inner(tree, *b), + |a, b| a.intersection(b), + )?, + Primitive::Or(a, b) | Primitive::Xor(a, b) => or_zip_with( + self.get_bounds_inner(tree, *a), + self.get_bounds_inner(tree, *b), + |a, b| a.union(b), + )?, }) } pub fn get_bounds(&self, tree: &Store) -> Aabb { - self.get_bounds_inner(tree, self.prim).unwrap_or_else(|| Aabb::new_empty(Vec3::zero())) + self.get_bounds_inner(tree, self.prim) + .unwrap_or_else(|| Aabb::new_empty(Vec3::zero())) } } @@ -82,7 +105,8 @@ pub trait Structure { site: &Site, prim: F, fill: G, - ) {} + ) { + } // Generate a primitive tree and fills for this structure fn render_collect(&self, site: &Site) -> (Store, Vec) { diff --git a/world/src/site2/mod.rs b/world/src/site2/mod.rs index f8a3a6855c..e8f5d333dd 100644 --- a/world/src/site2/mod.rs +++ b/world/src/site2/mod.rs @@ -3,38 +3,37 @@ mod plot; mod tile; use self::{ + gen::{Fill, Primitive, Structure}, plot::{Plot, PlotKind}, - tile::{TileGrid, Tile, TileKind, HazardKind, TILE_SIZE}, - gen::{Primitive, Fill, Structure}, + tile::{HazardKind, Tile, TileGrid, TileKind, TILE_SIZE}, }; use crate::{ site::SpawnRules, - util::{Grid, attempt, DHashSet, CARDINALS, SQUARE_4, SQUARE_9, LOCALITY}, - Canvas, - Land, + util::{attempt, DHashSet, Grid, CARDINALS, LOCALITY, SQUARE_4, SQUARE_9}, + Canvas, Land, }; use common::{ - terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize}, - vol::RectVolSize, - store::{Id, Store}, astar::Astar, lottery::Lottery, spiral::Spiral2d, + store::{Id, Store}, + terrain::{Block, BlockKind, SpriteKind, TerrainChunkSize}, + vol::RectVolSize, }; use hashbrown::hash_map::DefaultHashBuilder; use rand::prelude::*; use rand_chacha::ChaChaRng; -use vek::*; use std::ops::Range; +use vek::*; -/// Seed a new RNG from an old RNG, thereby making the old RNG indepedent of changing use of the new RNG. The practical -/// effect of this is to reduce the extent to which changes to child generation algorithm produce a 'butterfly effect' -/// on their parent generators, meaning that generators will be less likely to produce entirely different outcomes if -/// some detail of a generation algorithm changes slightly. This is generally good and makes worldgen code easier to -/// maintain and less liable to breaking changes. -fn reseed(rng: &mut impl Rng) -> impl Rng { - ChaChaRng::from_seed(rng.gen::<[u8; 32]>()) -} +/// Seed a new RNG from an old RNG, thereby making the old RNG indepedent of +/// changing use of the new RNG. The practical effect of this is to reduce the +/// extent to which changes to child generation algorithm produce a 'butterfly +/// effect' on their parent generators, meaning that generators will be less +/// likely to produce entirely different outcomes if some detail of a generation +/// algorithm changes slightly. This is generally good and makes worldgen code +/// easier to maintain and less liable to breaking changes. +fn reseed(rng: &mut impl Rng) -> impl Rng { ChaChaRng::from_seed(rng.gen::<[u8; 32]>()) } #[derive(Default)] pub struct Site { @@ -47,15 +46,23 @@ pub struct Site { impl Site { pub fn radius(&self) -> f32 { - ((self.tiles.bounds.min.map(|e| e.abs()).reduce_max() - .max(self.tiles.bounds.max.map(|e| e.abs()).reduce_max()) + 1) * tile::TILE_SIZE as i32) as f32 + ((self + .tiles + .bounds + .min + .map(|e| e.abs()) + .reduce_max() + .max(self.tiles.bounds.max.map(|e| e.abs()).reduce_max()) + + 1) + * tile::TILE_SIZE as i32) as f32 } pub fn spawn_rules(&self, wpos: Vec2) -> SpawnRules { SpawnRules { - trees: SQUARE_9 - .iter() - .all(|&rpos| self.wpos_tile(wpos + rpos * tile::TILE_SIZE as i32).is_empty()), + trees: SQUARE_9.iter().all(|&rpos| { + self.wpos_tile(wpos + rpos * tile::TILE_SIZE as i32) + .is_empty() + }), ..SpawnRules::default() } } @@ -82,7 +89,14 @@ impl Site { } } - pub fn create_road(&mut self, land: &Land, rng: &mut impl Rng, a: Vec2, b: Vec2, w: u16) -> Option> { + pub fn create_road( + &mut self, + land: &Land, + rng: &mut impl Rng, + a: Vec2, + b: Vec2, + w: u16, + ) -> Option> { const MAX_ITERS: usize = 4096; let range = -(w as i32) / 2..w as i32 - w as i32 / 2; let heuristic = |tile: &Vec2| { @@ -95,17 +109,22 @@ impl Site { } (tile.distance_squared(b) as f32).sqrt() }; - let path = Astar::new(MAX_ITERS, a, &heuristic, DefaultHashBuilder::default()).poll( - MAX_ITERS, - &heuristic, - |tile| { let tile = *tile; CARDINALS.iter().map(move |dir| tile + *dir) }, - |a, b| { - let alt_a = land.get_alt_approx(self.tile_center_wpos(*a)); - let alt_b = land.get_alt_approx(self.tile_center_wpos(*b)); - (alt_a - alt_b).abs() / TILE_SIZE as f32 - }, - |tile| *tile == b, - ).into_path()?; + let path = Astar::new(MAX_ITERS, a, &heuristic, DefaultHashBuilder::default()) + .poll( + MAX_ITERS, + &heuristic, + |tile| { + let tile = *tile; + CARDINALS.iter().map(move |dir| tile + *dir) + }, + |a, b| { + let alt_a = land.get_alt_approx(self.tile_center_wpos(*a)); + let alt_b = land.get_alt_approx(self.tile_center_wpos(*b)); + (alt_a - alt_b).abs() / TILE_SIZE as f32 + }, + |tile| *tile == b, + ) + .into_path()?; let plot = self.create_plot(Plot { kind: PlotKind::Road(path.clone()), @@ -134,24 +153,41 @@ impl Site { Some(plot) } - pub fn find_aabr(&mut self, search_pos: Vec2, area_range: Range, min_dims: Extent2) -> Option<(Aabr, Vec2)> { - self.tiles.find_near( - search_pos, - |center, _| self.tiles.grow_aabr(center, area_range.clone(), min_dims) + pub fn find_aabr( + &mut self, + search_pos: Vec2, + area_range: Range, + min_dims: Extent2, + ) -> Option<(Aabr, Vec2)> { + self.tiles.find_near(search_pos, |center, _| { + self.tiles + .grow_aabr(center, area_range.clone(), min_dims) .ok() .filter(|aabr| { - (aabr.min.x..aabr.max.x).any(|x| self.tiles.get(Vec2::new(x, aabr.min.y - 1)).is_road()) - || (aabr.min.x..aabr.max.x).any(|x| self.tiles.get(Vec2::new(x, aabr.max.y)).is_road()) - || (aabr.min.y..aabr.max.y).any(|y| self.tiles.get(Vec2::new(aabr.min.x - 1, y)).is_road()) - || (aabr.min.y..aabr.max.y).any(|y| self.tiles.get(Vec2::new(aabr.max.x, y)).is_road()) - }), - ) + (aabr.min.x..aabr.max.x) + .any(|x| self.tiles.get(Vec2::new(x, aabr.min.y - 1)).is_road()) + || (aabr.min.x..aabr.max.x) + .any(|x| self.tiles.get(Vec2::new(x, aabr.max.y)).is_road()) + || (aabr.min.y..aabr.max.y) + .any(|y| self.tiles.get(Vec2::new(aabr.min.x - 1, y)).is_road()) + || (aabr.min.y..aabr.max.y) + .any(|y| self.tiles.get(Vec2::new(aabr.max.x, y)).is_road()) + }) + }) } - pub fn find_roadside_aabr(&mut self, rng: &mut impl Rng, area_range: Range, min_dims: Extent2) -> Option<(Aabr, Vec2)> { - let dir = Vec2::::zero().map(|_| rng.gen_range(-1.0..1.0)).normalized(); + pub fn find_roadside_aabr( + &mut self, + rng: &mut impl Rng, + area_range: Range, + min_dims: Extent2, + ) -> Option<(Aabr, Vec2)> { + let dir = Vec2::::zero() + .map(|_| rng.gen_range(-1.0..1.0)) + .normalized(); let search_pos = if rng.gen() { - self.plot(*self.plazas.choose(rng)?).root_tile + (dir * 4.0).map(|e: f32| e.round() as i32) + self.plot(*self.plazas.choose(rng)?).root_tile + + (dir * 4.0).map(|e: f32| e.round() as i32) } else { if let PlotKind::Road(path) = &self.plot(*self.roads.choose(rng)?).kind { *path.nodes().choose(rng)? + (dir * 1.0).map(|e: f32| e.round() as i32) @@ -167,17 +203,27 @@ impl Site { let pos = attempt(32, || { self.plazas .choose(rng) - .map(|&p| self.plot(p).root_tile + (Vec2::new(rng.gen_range(-1.0..1.0), rng.gen_range(-1.0..1.0)).normalized() * 24.0).map(|e| e as i32)) + .map(|&p| { + self.plot(p).root_tile + + (Vec2::new(rng.gen_range(-1.0..1.0), rng.gen_range(-1.0..1.0)) + .normalized() + * 24.0) + .map(|e| e as i32) + }) .filter(|tile| !self.tiles.get(*tile).is_obstacle()) - .filter(|&tile| self - .plazas - .iter() - .all(|&p| self.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2)) - && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max()) + .filter(|&tile| { + self.plazas + .iter() + .all(|&p| self.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2)) + && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max() + }) }) - .unwrap_or_else(Vec2::zero); + .unwrap_or_else(Vec2::zero); - let aabr = Aabr { min: pos + Vec2::broadcast(-3), max: pos + Vec2::broadcast(4) }; + let aabr = Aabr { + min: pos + Vec2::broadcast(-3), + max: pos + Vec2::broadcast(4), + }; let plaza = self.create_plot(Plot { kind: PlotKind::Plaza, root_tile: pos, @@ -193,7 +239,8 @@ impl Site { let mut already_pathed = vec![plaza]; // One major, one minor road for width in (1..=2).rev() { - if let Some(&p) = self.plazas + if let Some(&p) = self + .plazas .iter() .filter(|p| !already_pathed.contains(p)) .min_by_key(|&&p| self.plot(p).root_tile.distance_squared(pos)) @@ -217,7 +264,9 @@ impl Site { if let Some(kind) = wpos_is_hazard(land, self.tile_wpos(tile)) { for &rpos in &SQUARE_4 { // `get_mut` doesn't increase generation bounds - self.tiles.get_mut(tile - rpos - 1).map(|tile| tile.kind = TileKind::Hazard(kind)); + self.tiles + .get_mut(tile - rpos - 1) + .map(|tile| tile.kind = TileKind::Hazard(kind)); } } }); @@ -235,12 +284,7 @@ impl Site { site.make_plaza(land, &mut rng); - let build_chance = Lottery::from(vec![ - (64.0, 1), - (5.0, 2), - (20.0, 3), - (0.75, 4), - ]); + let build_chance = Lottery::from(vec![(64.0, 1), (5.0, 2), (20.0, 3), (0.75, 4)]); let mut castles = 0; @@ -249,9 +293,21 @@ impl Site { // House 1 => { let size = (2.0 + rng.gen::().powf(8.0) * 3.0).round() as u32; - if let Some((aabr, door_tile)) = attempt(32, || site.find_roadside_aabr(&mut rng, 4..(size + 1).pow(2), Extent2::broadcast(size))) { + if let Some((aabr, door_tile)) = attempt(32, || { + site.find_roadside_aabr( + &mut rng, + 4..(size + 1).pow(2), + Extent2::broadcast(size), + ) + }) { let plot = site.create_plot(Plot { - kind: PlotKind::House(plot::House::generate(land, &mut reseed(&mut rng), &site, door_tile, aabr)), + kind: PlotKind::House(plot::House::generate( + land, + &mut reseed(&mut rng), + &site, + door_tile, + aabr, + )), root_tile: aabr.center(), tiles: aabr_tiles(aabr).collect(), seed: rng.gen(), @@ -267,7 +323,9 @@ impl Site { }, // Guard tower 2 => { - if let Some((aabr, _)) = attempt(10, || site.find_roadside_aabr(&mut rng, 4..4, Extent2::new(2, 2))) { + if let Some((aabr, _)) = attempt(10, || { + site.find_roadside_aabr(&mut rng, 4..4, Extent2::new(2, 2)) + }) { let plot = site.create_plot(Plot { kind: PlotKind::Castle, root_tile: aabr.center(), @@ -285,28 +343,26 @@ impl Site { 3 => { attempt(10, || { let search_pos = attempt(16, || { - let tile = (Vec2::new( - rng.gen_range(-1.0..1.0), - rng.gen_range(-1.0..1.0), - ).normalized() * rng.gen_range(16.0..48.0)).map(|e| e as i32); + let tile = + (Vec2::new(rng.gen_range(-1.0..1.0), rng.gen_range(-1.0..1.0)) + .normalized() + * rng.gen_range(16.0..48.0)) + .map(|e| e as i32); - if site - .plazas - .iter() - .all(|&p| site.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2)) - && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max() + if site.plazas.iter().all(|&p| { + site.plot(p).root_tile.distance_squared(tile) > 20i32.pow(2) + }) && rng.gen_range(0..48) > tile.map(|e| e.abs()).reduce_max() { Some(tile) } else { None } }) - .unwrap_or_else(Vec2::zero); + .unwrap_or_else(Vec2::zero); - site.tiles.find_near( - search_pos, - |center, _| site.tiles.grow_organic(&mut rng, center, 12..64).ok() - ) + site.tiles.find_near(search_pos, |center, _| { + site.tiles.grow_organic(&mut rng, center, 12..64).ok() + }) }) .map(|(tiles, _)| { for tile in tiles { @@ -319,7 +375,9 @@ impl Site { }, // Castle 4 if castles < 1 => { - if let Some((aabr, _)) = attempt(10, || site.find_roadside_aabr(&mut rng, 16 * 16..18 * 18, Extent2::new(16, 16))) { + if let Some((aabr, _)) = attempt(10, || { + site.find_roadside_aabr(&mut rng, 16 * 16..18 * 18, Extent2::new(16, 16)) + }) { let plot = site.create_plot(Plot { kind: PlotKind::Castle, root_tile: aabr.center(), @@ -337,22 +395,38 @@ impl Site { kind: TileKind::Castle, plot: Some(plot), }; - site.tiles.set(Vec2::new(aabr.min.x, aabr.min.y), tower.clone()); - site.tiles.set(Vec2::new(aabr.max.x - 1, aabr.min.y), tower.clone()); - site.tiles.set(Vec2::new(aabr.min.x, aabr.max.y - 1), tower.clone()); - site.tiles.set(Vec2::new(aabr.max.x - 1, aabr.max.y - 1), tower.clone()); + site.tiles + .set(Vec2::new(aabr.min.x, aabr.min.y), tower.clone()); + site.tiles + .set(Vec2::new(aabr.max.x - 1, aabr.min.y), tower.clone()); + site.tiles + .set(Vec2::new(aabr.min.x, aabr.max.y - 1), tower.clone()); + site.tiles + .set(Vec2::new(aabr.max.x - 1, aabr.max.y - 1), tower.clone()); // Courtyard - site.blit_aabr(Aabr { min: aabr.min + 1, max: aabr.max - 1 } , Tile { - kind: TileKind::Road { a: 0, b: 0, w: 0 }, - plot: Some(plot), - }); + site.blit_aabr( + Aabr { + min: aabr.min + 1, + max: aabr.max - 1, + }, + Tile { + kind: TileKind::Road { a: 0, b: 0, w: 0 }, + plot: Some(plot), + }, + ); // Keep - site.blit_aabr(Aabr { min: aabr.center() - 3, max: aabr.center() + 3 }, Tile { - kind: TileKind::Castle, - plot: Some(plot), - }); + site.blit_aabr( + Aabr { + min: aabr.center() - 3, + max: aabr.center() + 3, + }, + Tile { + kind: TileKind::Castle, + plot: Some(plot), + }, + ); castles += 1; } @@ -384,7 +458,12 @@ impl Site { let tile = self.tiles.get(tpos); let twpos = self.tile_wpos(tpos); let border = TILE_SIZE as i32; - let cols = (-border..TILE_SIZE as i32 + border).map(|y| (-border..TILE_SIZE as i32 + border).map(move |x| (twpos + Vec2::new(x, y), Vec2::new(x, y)))).flatten(); + let cols = (-border..TILE_SIZE as i32 + border) + .map(|y| { + (-border..TILE_SIZE as i32 + border) + .map(move |x| (twpos + Vec2::new(x, y), Vec2::new(x, y))) + }) + .flatten(); match &tile.kind { TileKind::Empty | TileKind::Hazard(_) => {}, @@ -418,15 +497,16 @@ impl Site { // // .filter_map(|line| Some(line?.projected_point(wpos2df))) // // .min_by_key(|p| p.distance_squared(wpos2df) as i32); - // // let is_near_road = nearest_road.map_or(false, |r| r.distance_squared(wpos2df) < 3.0f32.powi(2)); + // // let is_near_road = nearest_road.map_or(false, |r| + // r.distance_squared(wpos2df) < 3.0f32.powi(2)); // // if let Some(nearest_road) = nearest_road // // .filter(|r| r.distance_squared(wpos2df) < 6.0f32.powi(2)) // // { - // // let road_alt = canvas.col(nearest_road.map(|e| e.floor() as i32)).map_or(0, |col| col.alt as i32); - // // (-4..5).for_each(|z| canvas.map( - // // Vec3::new(wpos2d.x, wpos2d.y, road_alt + z), - // // |b| if z > 0 { + // // let road_alt = canvas.col(nearest_road.map(|e| e.floor() as + // i32)).map_or(0, |col| col.alt as i32); // + // (-4..5).for_each(|z| canvas.map( // Vec3::new(wpos2d.x, + // wpos2d.y, road_alt + z), // |b| if z > 0 { // // Block::air(SpriteKind::Empty) // // } else { // // Block::new(BlockKind::Rock, Rgb::new(55, 45, 65)) @@ -562,7 +642,9 @@ impl Site { let tile_aabr = Aabr { min: self.wpos_tile_pos(canvas.wpos()) - 1, - max: self.wpos_tile_pos(canvas.wpos() + TerrainChunkSize::RECT_SIZE.map(|e| e as i32) + 2) + 3, // Round up, uninclusive, border + max: self + .wpos_tile_pos(canvas.wpos() + TerrainChunkSize::RECT_SIZE.map(|e| e as i32) + 2) + + 3, // Round up, uninclusive, border }; // Don't double-generate the same plot per chunk! @@ -621,10 +703,9 @@ fn wpos_is_hazard(land: &Land, wpos: Vec2) -> Option { } } -pub fn aabr_tiles(aabr: Aabr) -> impl Iterator> { +pub fn aabr_tiles(aabr: Aabr) -> impl Iterator> { (0..aabr.size().h) - .map(move |y| (0..aabr.size().w) - .map(move |x| aabr.min + Vec2::new(x, y))) + .map(move |y| (0..aabr.size().w).map(move |x| aabr.min + Vec2::new(x, y))) .flatten() } diff --git a/world/src/site2/plot.rs b/world/src/site2/plot.rs index cb50abbc19..d2af39b252 100644 --- a/world/src/site2/plot.rs +++ b/world/src/site2/plot.rs @@ -1,8 +1,6 @@ mod house; -pub use self::{ - house::House, -}; +pub use self::house::House; use super::*; use crate::util::DHashSet; diff --git a/world/src/site2/plot/house.rs b/world/src/site2/plot/house.rs index 8a6455db34..bbba4c149f 100644 --- a/world/src/site2/plot/house.rs +++ b/world/src/site2/plot/house.rs @@ -80,16 +80,22 @@ impl Structure for House { let mut pillars_y = prim(Primitive::Empty); for x in self.tile_aabr.min.x..self.tile_aabr.max.x + 2 { let pillar = prim(Primitive::Aabb(Aabb { - min: site.tile_wpos(Vec2::new(x, self.tile_aabr.min.y)).with_z(self.alt), - max: (site.tile_wpos(Vec2::new(x, self.tile_aabr.max.y + 1)) + Vec2::unit_x()).with_z(self.alt + roof), + min: site + .tile_wpos(Vec2::new(x, self.tile_aabr.min.y)) + .with_z(self.alt), + max: (site.tile_wpos(Vec2::new(x, self.tile_aabr.max.y + 1)) + Vec2::unit_x()) + .with_z(self.alt + roof), })); pillars_y = prim(Primitive::Or(pillars_y, pillar)); } let mut pillars_x = prim(Primitive::Empty); for y in self.tile_aabr.min.y..self.tile_aabr.max.y + 2 { let pillar = prim(Primitive::Aabb(Aabb { - min: site.tile_wpos(Vec2::new(self.tile_aabr.min.x, y)).with_z(self.alt), - max: (site.tile_wpos(Vec2::new(self.tile_aabr.max.x + 1, y)) + Vec2::unit_y()).with_z(self.alt + roof), + min: site + .tile_wpos(Vec2::new(self.tile_aabr.min.x, y)) + .with_z(self.alt), + max: (site.tile_wpos(Vec2::new(self.tile_aabr.max.x + 1, y)) + Vec2::unit_y()) + .with_z(self.alt + roof), })); pillars_x = prim(Primitive::Or(pillars_x, pillar)); } @@ -109,8 +115,12 @@ impl Structure for House { let mut windows = prim(Primitive::Empty); for y in self.tile_aabr.min.y..self.tile_aabr.max.y { let window = prim(Primitive::Aabb(Aabb { - min: (site.tile_wpos(Vec2::new(self.tile_aabr.min.x, y)) + Vec2::unit_y() * 2).with_z(self.alt + height + 2), - max: (site.tile_wpos(Vec2::new(self.tile_aabr.max.x, y + 1)) + Vec2::new(1, -1)).with_z(self.alt + height + 2 + window_height), + min: (site.tile_wpos(Vec2::new(self.tile_aabr.min.x, y)) + + Vec2::unit_y() * 2) + .with_z(self.alt + height + 2), + max: (site.tile_wpos(Vec2::new(self.tile_aabr.max.x, y + 1)) + + Vec2::new(1, -1)) + .with_z(self.alt + height + 2 + window_height), })); windows = prim(Primitive::Or(windows, window)); } @@ -124,8 +134,12 @@ impl Structure for House { let mut windows = prim(Primitive::Empty); for x in self.tile_aabr.min.x..self.tile_aabr.max.x { let window = prim(Primitive::Aabb(Aabb { - min: (site.tile_wpos(Vec2::new(x, self.tile_aabr.min.y)) + Vec2::unit_x() * 2).with_z(self.alt + height + 2), - max: (site.tile_wpos(Vec2::new(x + 1, self.tile_aabr.max.y)) + Vec2::new(-1, 1)).with_z(self.alt + height + 2 + window_height), + min: (site.tile_wpos(Vec2::new(x, self.tile_aabr.min.y)) + + Vec2::unit_x() * 2) + .with_z(self.alt + height + 2), + max: (site.tile_wpos(Vec2::new(x + 1, self.tile_aabr.max.y)) + + Vec2::new(-1, 1)) + .with_z(self.alt + height + 2 + window_height), })); windows = prim(Primitive::Or(windows, window)); } diff --git a/world/src/site2/tile.rs b/world/src/site2/tile.rs index f80fac3bec..ea9f0b0f70 100644 --- a/world/src/site2/tile.rs +++ b/world/src/site2/tile.rs @@ -41,13 +41,15 @@ impl TileGrid { // WILL NOT EXPAND BOUNDS! pub fn get_mut(&mut self, tpos: Vec2) -> Option<&mut Tile> { let tpos = tpos + TILE_RADIUS as i32; - self.zones.get_mut(tpos.map(|e| e.div_euclid(ZONE_SIZE as i32))).and_then(|zone| { - zone.get_or_insert_with(|| { - Grid::populate_from(Vec2::broadcast(ZONE_SIZE as i32), |_| None) + self.zones + .get_mut(tpos.map(|e| e.div_euclid(ZONE_SIZE as i32))) + .and_then(|zone| { + zone.get_or_insert_with(|| { + Grid::populate_from(Vec2::broadcast(ZONE_SIZE as i32), |_| None) + }) + .get_mut(tpos.map(|e| e.rem_euclid(ZONE_SIZE as i32))) + .map(|tile| tile.get_or_insert_with(|| Tile::empty())) }) - .get_mut(tpos.map(|e| e.rem_euclid(ZONE_SIZE as i32))) - .map(|tile| tile.get_or_insert_with(|| Tile::empty())) - }) } pub fn set(&mut self, tpos: Vec2, tile: Tile) -> Option { @@ -55,7 +57,11 @@ impl TileGrid { self.get_mut(tpos).map(|t| std::mem::replace(t, tile)) } - pub fn find_near(&self, tpos: Vec2, mut f: impl FnMut(Vec2, &Tile) -> Option) -> Option<(R, Vec2)> { + pub fn find_near( + &self, + tpos: Vec2, + mut f: impl FnMut(Vec2, &Tile) -> Option, + ) -> Option<(R, Vec2)> { const MAX_SEARCH_RADIUS_BLOCKS: u32 = 70; const MAX_SEARCH_CELLS: u32 = ((MAX_SEARCH_RADIUS_BLOCKS / TILE_SIZE) * 2 + 1).pow(2); Spiral2d::new() @@ -64,8 +70,16 @@ impl TileGrid { .find_map(|tpos| (&mut f)(tpos, self.get(tpos)).zip(Some(tpos))) } - pub fn grow_aabr(&self, center: Vec2, area_range: Range, min_dims: Extent2) -> Result, Aabr> { - let mut aabr = Aabr { min: center, max: center + 1 }; + pub fn grow_aabr( + &self, + center: Vec2, + area_range: Range, + min_dims: Extent2, + ) -> Result, Aabr> { + let mut aabr = Aabr { + min: center, + max: center + 1, + }; if !self.get(center).is_empty() { return Err(aabr); @@ -75,27 +89,42 @@ impl TileGrid { for i in 0..32 { if i - last_growth >= 4 { break; - } else if aabr.size().product() + if i % 2 == 0 { aabr.size().h } else { aabr.size().w } > area_range.end as i32 { + } else if aabr.size().product() + + if i % 2 == 0 { + aabr.size().h + } else { + aabr.size().w + } + > area_range.end as i32 + { break; } else { // `center.sum()` to avoid biasing certain directions match (i + center.sum().abs()) % 4 { - 0 if (aabr.min.y..aabr.max.y + 1).all(|y| self.get(Vec2::new(aabr.max.x, y)).is_empty()) => { + 0 if (aabr.min.y..aabr.max.y + 1) + .all(|y| self.get(Vec2::new(aabr.max.x, y)).is_empty()) => + { aabr.max.x += 1; last_growth = i; - }, - 1 if (aabr.min.x..aabr.max.x + 1).all(|x| self.get(Vec2::new(x, aabr.max.y)).is_empty()) => { + } + 1 if (aabr.min.x..aabr.max.x + 1) + .all(|x| self.get(Vec2::new(x, aabr.max.y)).is_empty()) => + { aabr.max.y += 1; last_growth = i; - }, - 2 if (aabr.min.y..aabr.max.y + 1).all(|y| self.get(Vec2::new(aabr.min.x - 1, y)).is_empty()) => { + } + 2 if (aabr.min.y..aabr.max.y + 1) + .all(|y| self.get(Vec2::new(aabr.min.x - 1, y)).is_empty()) => + { aabr.min.x -= 1; last_growth = i; - }, - 3 if (aabr.min.x..aabr.max.x + 1).all(|x| self.get(Vec2::new(x, aabr.min.y - 1)).is_empty()) => { + } + 3 if (aabr.min.x..aabr.max.x + 1) + .all(|x| self.get(Vec2::new(x, aabr.min.y - 1)).is_empty()) => + { aabr.min.y -= 1; last_growth = i; - }, + } _ => {}, } } @@ -111,7 +140,12 @@ impl TileGrid { } } - pub fn grow_organic(&self, rng: &mut impl Rng, center: Vec2, area_range: Range) -> Result>, DHashSet>> { + pub fn grow_organic( + &self, + rng: &mut impl Rng, + center: Vec2, + area_range: Range, + ) -> Result>, DHashSet>> { let mut tiles = DHashSet::default(); let mut open = Vec::new(); @@ -165,26 +199,16 @@ impl Tile { } /// Create a tile that is not associated with any plot. - pub const fn free(kind: TileKind) -> Self { - Self { - kind, - plot: None, - } - } + pub const fn free(kind: TileKind) -> Self { Self { kind, plot: None } } pub fn is_empty(&self) -> bool { self.kind == TileKind::Empty } - pub fn is_road(&self) -> bool { - matches!(self.kind, TileKind::Road { .. }) - } + pub fn is_road(&self) -> bool { matches!(self.kind, TileKind::Road { .. }) } pub fn is_obstacle(&self) -> bool { matches!( self.kind, - TileKind::Hazard(_) - | TileKind::Building - | TileKind::Castle - | TileKind::Wall + TileKind::Hazard(_) | TileKind::Building | TileKind::Castle | TileKind::Wall ) } } diff --git a/world/src/util/math.rs b/world/src/util/math.rs index 857dd8c018..56f91d795a 100644 --- a/world/src/util/math.rs +++ b/world/src/util/math.rs @@ -1,9 +1,10 @@ use std::ops::Range; use vek::*; -/// Return a value between 0 and 1 corresponding to how close to the centre of `range` `x` is. -/// The exact function used is left unspecified, but it shall have the shape of a bell-like curve. -/// This function is required to return `0` (or a value extremely close to `0`) when `x` is outside of `range`. +/// Return a value between 0 and 1 corresponding to how close to the centre of +/// `range` `x` is. The exact function used is left unspecified, but it shall +/// have the shape of a bell-like curve. This function is required to return `0` +/// (or a value extremely close to `0`) when `x` is outside of `range`. pub fn close(x: f32, range: Range) -> f32 { let mean = (range.start + range.end) / 2.0; let width = (range.end - range.start) / 2.0; diff --git a/world/src/util/mod.rs b/world/src/util/mod.rs index 60868f52c3..0a22405bcd 100644 --- a/world/src/util/mod.rs +++ b/world/src/util/mod.rs @@ -1,6 +1,6 @@ pub mod fast_noise; -pub mod math; pub mod map_vec; +pub mod math; pub mod random; pub mod sampler; pub mod seed_expan;