Compare commits
27 Commits
load-textu
...
temp-spawn
| Author | SHA1 | Date | |
|---|---|---|---|
| 047f0038a5 | |||
| f0479181f6 | |||
| 971aa9e287 | |||
| 6a79c4ec24 | |||
| 9025bea5ef | |||
| 6ed71073f6 | |||
| 91bfa70f05 | |||
| 1c9bc347f6 | |||
| c9afa2d059 | |||
| 1a66dfbaf7 | |||
| 847209aac4 | |||
| 42ba757ec0 | |||
| 1cee3b52ac | |||
| e27ce3b507 | |||
| bc8f2bd566 | |||
| eed932212d | |||
| 73edb9ff95 | |||
| ae0c9e73ee | |||
| 953d424a57 | |||
| ca919b92fd | |||
| 1de3501e89 | |||
| 0135b17917 | |||
| 1878528a4f | |||
| 25e80a7c17 | |||
| 21835d13f6 | |||
| 91f6a5261f | |||
| fb4a5efa14 |
257
Cargo.lock
generated
257
Cargo.lock
generated
@@ -157,6 +157,12 @@ dependencies = [
|
|||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base64"
|
||||||
|
version = "0.13.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit-set"
|
name = "bit-set"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
@@ -184,12 +190,35 @@ version = "2.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
|
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "blake3"
|
||||||
|
version = "1.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5"
|
||||||
|
dependencies = [
|
||||||
|
"arrayref",
|
||||||
|
"arrayvec",
|
||||||
|
"cc",
|
||||||
|
"cfg-if",
|
||||||
|
"constant_time_eq",
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block"
|
name = "block"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "block-buffer"
|
||||||
|
version = "0.10.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "block-sys"
|
name = "block-sys"
|
||||||
version = "0.1.0-beta.1"
|
version = "0.1.0-beta.1"
|
||||||
@@ -302,6 +331,12 @@ dependencies = [
|
|||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "constant_time_eq"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "core-foundation"
|
name = "core-foundation"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
@@ -360,6 +395,16 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crypto-common"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
"typenum",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "d3d12"
|
name = "d3d12"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@@ -382,6 +427,17 @@ dependencies = [
|
|||||||
"enum_primitive",
|
"enum_primitive",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "digest"
|
||||||
|
version = "0.10.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||||
|
dependencies = [
|
||||||
|
"block-buffer",
|
||||||
|
"crypto-common",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dispatch"
|
name = "dispatch"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -555,6 +611,16 @@ dependencies = [
|
|||||||
"waker-fn",
|
"waker-fn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "generic-array"
|
||||||
|
version = "0.14.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||||
|
dependencies = [
|
||||||
|
"typenum",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.10"
|
version = "0.2.10"
|
||||||
@@ -822,6 +888,26 @@ version = "0.4.20"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lz4"
|
||||||
|
version = "1.24.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"lz4-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lz4-sys"
|
||||||
|
version = "1.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "malloc_buf"
|
name = "malloc_buf"
|
||||||
version = "0.0.6"
|
version = "0.0.6"
|
||||||
@@ -1198,6 +1284,12 @@ version = "0.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
|
checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppv-lite86"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-crate"
|
name = "proc-macro-crate"
|
||||||
version = "1.3.1"
|
version = "1.3.1"
|
||||||
@@ -1222,6 +1314,19 @@ name = "profiling"
|
|||||||
version = "1.0.9"
|
version = "1.0.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "46b2164ebdb1dfeec5e337be164292351e11daf63a05174c6776b2f47460f0c9"
|
checksum = "46b2164ebdb1dfeec5e337be164292351e11daf63a05174c6776b2f47460f0c9"
|
||||||
|
dependencies = [
|
||||||
|
"profiling-procmacros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "profiling-procmacros"
|
||||||
|
version = "1.0.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "74c55e9e629af5298a40e0fa106435b2da30484c4ec76b41d19bc4d00dd8b903"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.29",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
@@ -1232,6 +1337,36 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "range-alloc"
|
name = "range-alloc"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
@@ -1244,6 +1379,69 @@ version = "0.5.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rbx_binary"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4e50573021d04b680018955662eba7dc4aac3de92219231798f6c9b41e38ab01"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"lz4",
|
||||||
|
"profiling",
|
||||||
|
"rbx_dom_weak",
|
||||||
|
"rbx_reflection",
|
||||||
|
"rbx_reflection_database",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rbx_dom_weak"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "161729449bbb0cfa657ce7bcca6a160d0af06d8b8d9efdc9abe14735dccacdb9"
|
||||||
|
dependencies = [
|
||||||
|
"rbx_types",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rbx_reflection"
|
||||||
|
version = "4.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08bd48487192046fec8f805f3fa29f3d7d5beb9890b0859b1a92bd8aff580343"
|
||||||
|
dependencies = [
|
||||||
|
"rbx_types",
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rbx_reflection_database"
|
||||||
|
version = "0.2.7+roblox-588"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1be6cf674182806f11ad4899dd1feafe977591f1ae035ae05a58d4b74e487276"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"rbx_reflection",
|
||||||
|
"rmp-serde",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rbx_types"
|
||||||
|
version = "1.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "070106e926b8ae54c7bc443e5db4d868d7f0af51c1d7cfd7efe1364c1753d8a3"
|
||||||
|
dependencies = [
|
||||||
|
"base64",
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"blake3",
|
||||||
|
"lazy_static",
|
||||||
|
"rand",
|
||||||
|
"serde",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
@@ -1288,6 +1486,28 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b"
|
checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rmp"
|
||||||
|
version = "0.8.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f9860a6cc38ed1da53456442089b4dfa35e7cedaa326df63017af88385e6b20"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"num-traits 0.2.16",
|
||||||
|
"paste",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rmp-serde"
|
||||||
|
version = "1.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bffea85eea980d8a74453e5d02a8d93028f3c34725de143085a844ebe953258a"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"rmp",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.23"
|
version = "0.1.23"
|
||||||
@@ -1338,6 +1558,26 @@ dependencies = [
|
|||||||
"tiny-skia",
|
"tiny-skia",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.188"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
|
||||||
|
dependencies = [
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_derive"
|
||||||
|
version = "1.0.188"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.29",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simd-adler32"
|
name = "simd-adler32"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
@@ -1405,7 +1645,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strafe-client"
|
name = "strafe-client"
|
||||||
version = "0.3.0"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-executor",
|
"async-executor",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
@@ -1415,6 +1655,9 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"obj",
|
"obj",
|
||||||
"pollster",
|
"pollster",
|
||||||
|
"rbx_binary",
|
||||||
|
"rbx_dom_weak",
|
||||||
|
"rbx_reflection_database",
|
||||||
"wgpu",
|
"wgpu",
|
||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
@@ -1425,6 +1668,12 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
|
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "subtle"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.109"
|
version = "1.0.109"
|
||||||
@@ -1524,6 +1773,12 @@ version = "0.19.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33"
|
checksum = "a464a4b34948a5f67fddd2b823c62d9d92e44be75058b99939eae6c5b6960b33"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "typenum"
|
||||||
|
version = "1.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.11"
|
version = "1.0.11"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafe-client"
|
name = "strafe-client"
|
||||||
version = "0.3.0"
|
version = "0.5.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@@ -14,6 +14,9 @@ glam = "0.24.1"
|
|||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
obj = "0.10.2"
|
obj = "0.10.2"
|
||||||
pollster = "0.3.0"
|
pollster = "0.3.0"
|
||||||
|
rbx_binary = "0.7.1"
|
||||||
|
rbx_dom_weak = "2.5.0"
|
||||||
|
rbx_reflection_database = "0.2.7"
|
||||||
wgpu = "0.17.0"
|
wgpu = "0.17.0"
|
||||||
winit = "0.28.6"
|
winit = "0.28.6"
|
||||||
|
|
||||||
|
|||||||
BIN
images/squid.dds
Normal file
BIN
images/squid.dds
Normal file
Binary file not shown.
361
src/body.rs
361
src/body.rs
@@ -4,11 +4,7 @@ use crate::{instruction::{InstructionEmitter, InstructionConsumer, TimedInstruct
|
|||||||
pub enum PhysicsInstruction {
|
pub enum PhysicsInstruction {
|
||||||
CollisionStart(RelativeCollision),
|
CollisionStart(RelativeCollision),
|
||||||
CollisionEnd(RelativeCollision),
|
CollisionEnd(RelativeCollision),
|
||||||
SetControlDir(glam::Vec3),
|
|
||||||
StrafeTick,
|
StrafeTick,
|
||||||
Jump,
|
|
||||||
SetWalkTargetVelocity(glam::Vec3),
|
|
||||||
RefreshWalkTarget,
|
|
||||||
ReachWalkTargetVelocity,
|
ReachWalkTargetVelocity,
|
||||||
// Water,
|
// Water,
|
||||||
// Spawn(
|
// Spawn(
|
||||||
@@ -16,6 +12,23 @@ pub enum PhysicsInstruction {
|
|||||||
// bool,//true = Trigger; false = teleport
|
// bool,//true = Trigger; false = teleport
|
||||||
// bool,//true = Force
|
// bool,//true = Force
|
||||||
// )
|
// )
|
||||||
|
//temp
|
||||||
|
SetPosition(glam::Vec3),
|
||||||
|
//Both of these conditionally activate RefreshWalkTarget (by doing what SetWalkTargetVelocity used to do and then flagging it)
|
||||||
|
Input(InputInstruction),
|
||||||
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum InputInstruction {
|
||||||
|
MoveMouse(glam::IVec2),
|
||||||
|
MoveForward(bool),
|
||||||
|
MoveLeft(bool),
|
||||||
|
MoveBack(bool),
|
||||||
|
MoveRight(bool),
|
||||||
|
MoveUp(bool),
|
||||||
|
MoveDown(bool),
|
||||||
|
Jump(bool),
|
||||||
|
Zoom(bool),
|
||||||
|
Reset,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Body {
|
pub struct Body {
|
||||||
@@ -51,34 +64,35 @@ pub enum MoveRestriction {
|
|||||||
Ladder,//multiple ladders how
|
Ladder,//multiple ladders how
|
||||||
}
|
}
|
||||||
|
|
||||||
enum MouseInterpolation {
|
/*
|
||||||
First,//just checks the last value
|
|
||||||
Lerp,//lerps between
|
|
||||||
}
|
|
||||||
|
|
||||||
enum InputInstruction {
|
enum InputInstruction {
|
||||||
MoveMouse(glam::IVec2),
|
|
||||||
Jump(bool),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InputState {
|
struct InputState {
|
||||||
controls: u32,
|
|
||||||
mouse_interpolation: MouseInterpolation,
|
|
||||||
time: TIME,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputState {
|
impl InputState {
|
||||||
pub fn get_control(&self,control:u32) -> bool {
|
pub fn get_control(&self,control:u32) -> bool {
|
||||||
self.controls&control!=0
|
self.controls&control!=0
|
||||||
}
|
}
|
||||||
pub fn process_instruction(&mut self,ins:InputInstruction){
|
}
|
||||||
match ins {
|
impl crate::instruction::InstructionEmitter<InputInstruction> for InputState{
|
||||||
InputInstruction::MoveMouse(m) => todo!("set mouse_interpolation"),
|
fn next_instruction(&self, time_limit:crate::body::TIME) -> Option<TimedInstruction<InputInstruction>> {
|
||||||
InputInstruction::Jump(b) => todo!("how does info about style modifiers get here"),
|
//this is polled by PhysicsState for actions like Jump
|
||||||
}
|
//no, it has to be the other way around. physics is run up until the jump instruction, and then the jump instruction is pushed.
|
||||||
|
self.queue.get(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl crate::instruction::InstructionConsumer<InputInstruction> for InputState{
|
||||||
|
fn process_instruction(&mut self,ins:TimedInstruction<InputInstruction>){
|
||||||
|
//add to queue
|
||||||
|
self.queue.push(ins);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum MouseInterpolation {
|
||||||
|
First,//just checks the last value
|
||||||
|
Lerp,//lerps between
|
||||||
|
}
|
||||||
pub struct MouseInterpolationState {
|
pub struct MouseInterpolationState {
|
||||||
interpolation: MouseInterpolation,
|
interpolation: MouseInterpolation,
|
||||||
time0: TIME,
|
time0: TIME,
|
||||||
@@ -88,11 +102,20 @@ pub struct MouseInterpolationState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MouseInterpolationState {
|
impl MouseInterpolationState {
|
||||||
pub fn move_mouse(&mut self,time:TIME,pos:glam::IVec2){
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
interpolation:MouseInterpolation::First,
|
||||||
|
time0:0,
|
||||||
|
time1:1,//ONE NANOSECOND!!!! avoid divide by zero
|
||||||
|
mouse0:glam::IVec2::ZERO,
|
||||||
|
mouse1:glam::IVec2::ZERO,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn move_mouse(&mut self,time:TIME,delta:glam::IVec2){
|
||||||
self.time0=self.time1;
|
self.time0=self.time1;
|
||||||
self.mouse0=self.mouse1;
|
self.mouse0=self.mouse1;
|
||||||
self.time1=time;
|
self.time1=time;
|
||||||
self.mouse1=pos;
|
self.mouse1=self.mouse1+delta;
|
||||||
}
|
}
|
||||||
pub fn interpolated_position(&self,time:TIME) -> glam::IVec2 {
|
pub fn interpolated_position(&self,time:TIME) -> glam::IVec2 {
|
||||||
match self.interpolation {
|
match self.interpolation {
|
||||||
@@ -113,7 +136,6 @@ impl MouseInterpolationState {
|
|||||||
pub enum WalkEnum{
|
pub enum WalkEnum{
|
||||||
Reached,
|
Reached,
|
||||||
Transient,
|
Transient,
|
||||||
Invalid,
|
|
||||||
}
|
}
|
||||||
pub struct WalkState {
|
pub struct WalkState {
|
||||||
pub target_velocity: glam::Vec3,
|
pub target_velocity: glam::Vec3,
|
||||||
@@ -125,22 +147,120 @@ impl WalkState {
|
|||||||
Self{
|
Self{
|
||||||
target_velocity:glam::Vec3::ZERO,
|
target_velocity:glam::Vec3::ZERO,
|
||||||
target_time:0,
|
target_time:0,
|
||||||
state:WalkEnum::Invalid,
|
state:WalkEnum::Reached,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: we use the Y=up coordinate space in this example.
|
||||||
|
pub struct Camera {
|
||||||
|
offset: glam::Vec3,
|
||||||
|
angles: glam::DVec2,//YAW AND THEN PITCH
|
||||||
|
//punch: glam::Vec3,
|
||||||
|
//punch_velocity: glam::Vec3,
|
||||||
|
fov: glam::Vec2,//slope
|
||||||
|
sensitivity: glam::DVec2,
|
||||||
|
time: TIME,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn mat3_from_rotation_y_f64(angle: f64) -> glam::Mat3 {
|
||||||
|
let (sina, cosa) = angle.sin_cos();
|
||||||
|
glam::Mat3::from_cols(
|
||||||
|
glam::Vec3::new(cosa as f32, 0.0, -sina as f32),
|
||||||
|
glam::Vec3::Y,
|
||||||
|
glam::Vec3::new(sina as f32, 0.0, cosa as f32),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
fn perspective_rh(fov_x_slope: f32, fov_y_slope: f32, z_near: f32, z_far: f32) -> glam::Mat4 {
|
||||||
|
//glam_assert!(z_near > 0.0 && z_far > 0.0);
|
||||||
|
let r = z_far / (z_near - z_far);
|
||||||
|
glam::Mat4::from_cols(
|
||||||
|
glam::Vec4::new(1.0/fov_x_slope, 0.0, 0.0, 0.0),
|
||||||
|
glam::Vec4::new(0.0, 1.0/fov_y_slope, 0.0, 0.0),
|
||||||
|
glam::Vec4::new(0.0, 0.0, r, -1.0),
|
||||||
|
glam::Vec4::new(0.0, 0.0, r * z_near, 0.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
impl Camera {
|
||||||
|
pub fn from_offset(offset:glam::Vec3,aspect:f32) -> Self {
|
||||||
|
Self{
|
||||||
|
offset,
|
||||||
|
angles: glam::DVec2::ZERO,
|
||||||
|
fov: glam::vec2(aspect,1.0),
|
||||||
|
sensitivity: glam::dvec2(1.0/2048.0,1.0/2048.0),
|
||||||
|
time: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn simulate_move_angles(&self, delta: glam::IVec2) -> glam::DVec2 {
|
||||||
|
let mut a=self.angles-self.sensitivity*delta.as_dvec2();
|
||||||
|
a.y=a.y.clamp(-std::f64::consts::PI, std::f64::consts::PI);
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
fn simulate_move_rotation_y(&self, delta_x: i32) -> glam::Mat3 {
|
||||||
|
mat3_from_rotation_y_f64(self.angles.x-self.sensitivity.x*(delta_x as f64))
|
||||||
|
}
|
||||||
|
pub fn proj(&self)->glam::Mat4{
|
||||||
|
perspective_rh(self.fov.x, self.fov.y, 0.5, 1000.0)
|
||||||
|
}
|
||||||
|
pub fn view(&self,pos:glam::Vec3)->glam::Mat4{
|
||||||
|
//f32 good enough for view matrix
|
||||||
|
glam::Mat4::from_translation(pos+self.offset) * glam::Mat4::from_euler(glam::EulerRot::YXZ, self.angles.x as f32, self.angles.y as f32, 0f32)
|
||||||
|
}
|
||||||
|
pub fn set_fov_aspect(&mut self,fov:f32,aspect:f32){
|
||||||
|
self.fov.x=fov*aspect;
|
||||||
|
self.fov.y=fov;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CONTROL_MOVEFORWARD:u32 = 0b00000001;
|
||||||
|
const CONTROL_MOVEBACK:u32 = 0b00000010;
|
||||||
|
const CONTROL_MOVERIGHT:u32 = 0b00000100;
|
||||||
|
const CONTROL_MOVELEFT:u32 = 0b00001000;
|
||||||
|
const CONTROL_MOVEUP:u32 = 0b00010000;
|
||||||
|
const CONTROL_MOVEDOWN:u32 = 0b00100000;
|
||||||
|
const CONTROL_JUMP:u32 = 0b01000000;
|
||||||
|
const CONTROL_ZOOM:u32 = 0b10000000;
|
||||||
|
|
||||||
|
const FORWARD_DIR:glam::Vec3 = glam::Vec3::new(0.0,0.0,-1.0);
|
||||||
|
const RIGHT_DIR:glam::Vec3 = glam::Vec3::new(1.0,0.0,0.0);
|
||||||
|
const UP_DIR:glam::Vec3 = glam::Vec3::new(0.0,1.0,0.0);
|
||||||
|
|
||||||
|
fn get_control_dir(controls: u32) -> glam::Vec3{
|
||||||
|
//don't get fancy just do it
|
||||||
|
let mut control_dir:glam::Vec3 = glam::Vec3::new(0.0,0.0,0.0);
|
||||||
|
if controls & CONTROL_MOVEFORWARD == CONTROL_MOVEFORWARD {
|
||||||
|
control_dir+=FORWARD_DIR;
|
||||||
|
}
|
||||||
|
if controls & CONTROL_MOVEBACK == CONTROL_MOVEBACK {
|
||||||
|
control_dir+=-FORWARD_DIR;
|
||||||
|
}
|
||||||
|
if controls & CONTROL_MOVELEFT == CONTROL_MOVELEFT {
|
||||||
|
control_dir+=-RIGHT_DIR;
|
||||||
|
}
|
||||||
|
if controls & CONTROL_MOVERIGHT == CONTROL_MOVERIGHT {
|
||||||
|
control_dir+=RIGHT_DIR;
|
||||||
|
}
|
||||||
|
if controls & CONTROL_MOVEUP == CONTROL_MOVEUP {
|
||||||
|
control_dir+=UP_DIR;
|
||||||
|
}
|
||||||
|
if controls & CONTROL_MOVEDOWN == CONTROL_MOVEDOWN {
|
||||||
|
control_dir+=-UP_DIR;
|
||||||
|
}
|
||||||
|
return control_dir
|
||||||
|
}
|
||||||
|
|
||||||
pub struct PhysicsState {
|
pub struct PhysicsState {
|
||||||
pub body: Body,
|
pub body: Body,
|
||||||
pub hitbox_halfsize: glam::Vec3,
|
pub hitbox_halfsize: glam::Vec3,
|
||||||
pub contacts: std::collections::HashSet::<RelativeCollision>,
|
pub contacts: std::collections::HashSet::<RelativeCollision>,
|
||||||
//pub intersections: Vec<ModelId>,
|
//pub intersections: Vec<ModelId>,
|
||||||
//temp
|
pub models: Vec<ModelPhysics>,
|
||||||
pub models_cringe_clone: Vec<Model>,
|
|
||||||
pub temp_control_dir: glam::Vec3,
|
|
||||||
//camera must exist in state because wormholes modify the camera, also camera punch
|
//camera must exist in state because wormholes modify the camera, also camera punch
|
||||||
//pub camera: Camera,
|
pub camera: Camera,
|
||||||
//pub mouse_interpolation: MouseInterpolationState,
|
pub mouse_interpolation: MouseInterpolationState,
|
||||||
|
pub controls: u32,
|
||||||
pub time: TIME,
|
pub time: TIME,
|
||||||
pub strafe_tick_num: TIME,
|
pub strafe_tick_num: TIME,
|
||||||
pub strafe_tick_den: TIME,
|
pub strafe_tick_den: TIME,
|
||||||
@@ -152,7 +272,6 @@ pub struct PhysicsState {
|
|||||||
pub walk_accel: f32,
|
pub walk_accel: f32,
|
||||||
pub gravity: glam::Vec3,
|
pub gravity: glam::Vec3,
|
||||||
pub grounded: bool,
|
pub grounded: bool,
|
||||||
pub jump_trying: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
#[derive(Debug,Clone,Copy,Hash,Eq,PartialEq)]
|
||||||
@@ -264,13 +383,13 @@ impl Aabb {
|
|||||||
type TreyMeshFace = AabbFace;
|
type TreyMeshFace = AabbFace;
|
||||||
type TreyMesh = Aabb;
|
type TreyMesh = Aabb;
|
||||||
|
|
||||||
pub struct Model {
|
pub struct ModelPhysics {
|
||||||
//A model is a thing that has a hitbox. can be represented by a list of TreyMesh-es
|
//A model is a thing that has a hitbox. can be represented by a list of TreyMesh-es
|
||||||
//in this iteration, all it needs is extents.
|
//in this iteration, all it needs is extents.
|
||||||
transform: glam::Mat4,
|
transform: glam::Mat4,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Model {
|
impl ModelPhysics {
|
||||||
pub fn new(transform:glam::Mat4) -> Self {
|
pub fn new(transform:glam::Mat4) -> Self {
|
||||||
Self{transform}
|
Self{transform}
|
||||||
}
|
}
|
||||||
@@ -314,10 +433,10 @@ pub struct RelativeCollision {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl RelativeCollision {
|
impl RelativeCollision {
|
||||||
pub fn mesh(&self,models:&Vec<Model>) -> TreyMesh {
|
pub fn mesh(&self,models:&Vec<ModelPhysics>) -> TreyMesh {
|
||||||
return models.get(self.model as usize).unwrap().face_mesh(self.face)
|
return models.get(self.model as usize).unwrap().face_mesh(self.face)
|
||||||
}
|
}
|
||||||
pub fn normal(&self,models:&Vec<Model>) -> glam::Vec3 {
|
pub fn normal(&self,models:&Vec<ModelPhysics>) -> glam::Vec3 {
|
||||||
return models.get(self.model as usize).unwrap().face_normal(self.face)
|
return models.get(self.model as usize).unwrap().face_normal(self.face)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,8 +472,6 @@ impl PhysicsState {
|
|||||||
pub fn run(&mut self, time_limit:TIME){
|
pub fn run(&mut self, time_limit:TIME){
|
||||||
//prepare is ommitted - everything is done via instructions.
|
//prepare is ommitted - everything is done via instructions.
|
||||||
while let Some(instruction) = self.next_instruction(time_limit) {//collect
|
while let Some(instruction) = self.next_instruction(time_limit) {//collect
|
||||||
//advance
|
|
||||||
//self.advance_time(instruction.time);
|
|
||||||
//process
|
//process
|
||||||
self.process_instruction(instruction);
|
self.process_instruction(instruction);
|
||||||
//write hash lol
|
//write hash lol
|
||||||
@@ -366,9 +483,19 @@ impl PhysicsState {
|
|||||||
self.time=time;
|
self.time=time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_control(&mut self,control:u32,state:bool){
|
||||||
|
self.controls=if state{self.controls|control}else{self.controls&!control};
|
||||||
|
}
|
||||||
|
fn jump(&mut self){
|
||||||
|
self.grounded=false;//do I need this?
|
||||||
|
let mut v=self.body.velocity+glam::Vec3::new(0.0,0.715588/2.0*100.0,0.0);
|
||||||
|
self.contact_constrain_velocity(&mut v);
|
||||||
|
self.body.velocity=v;
|
||||||
|
}
|
||||||
|
|
||||||
fn contact_constrain_velocity(&self,velocity:&mut glam::Vec3){
|
fn contact_constrain_velocity(&self,velocity:&mut glam::Vec3){
|
||||||
for contact in self.contacts.iter() {
|
for contact in self.contacts.iter() {
|
||||||
let n=contact.normal(&self.models_cringe_clone);
|
let n=contact.normal(&self.models);
|
||||||
let d=velocity.dot(n);
|
let d=velocity.dot(n);
|
||||||
if d<0f32{
|
if d<0f32{
|
||||||
(*velocity)-=d/n.length_squared()*n;
|
(*velocity)-=d/n.length_squared()*n;
|
||||||
@@ -377,14 +504,13 @@ impl PhysicsState {
|
|||||||
}
|
}
|
||||||
fn contact_constrain_acceleration(&self,acceleration:&mut glam::Vec3){
|
fn contact_constrain_acceleration(&self,acceleration:&mut glam::Vec3){
|
||||||
for contact in self.contacts.iter() {
|
for contact in self.contacts.iter() {
|
||||||
let n=contact.normal(&self.models_cringe_clone);
|
let n=contact.normal(&self.models);
|
||||||
let d=acceleration.dot(n);
|
let d=acceleration.dot(n);
|
||||||
if d<0f32{
|
if d<0f32{
|
||||||
(*acceleration)-=d/n.length_squared()*n;
|
(*acceleration)-=d/n.length_squared()*n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_strafe_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
|
fn next_strafe_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
|
||||||
return Some(TimedInstruction{
|
return Some(TimedInstruction{
|
||||||
time:(self.time*self.strafe_tick_num/self.strafe_tick_den+1)*self.strafe_tick_den/self.strafe_tick_num,
|
time:(self.time*self.strafe_tick_num/self.strafe_tick_den+1)*self.strafe_tick_den/self.strafe_tick_num,
|
||||||
@@ -424,6 +550,31 @@ impl PhysicsState {
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
fn refresh_walk_target(&mut self){
|
||||||
|
//calculate acceleration yada yada
|
||||||
|
if self.grounded{
|
||||||
|
let mut v=self.walk.target_velocity;
|
||||||
|
self.contact_constrain_velocity(&mut v);
|
||||||
|
let mut target_diff=v-self.body.velocity;
|
||||||
|
target_diff.y=0f32;
|
||||||
|
if target_diff==glam::Vec3::ZERO{
|
||||||
|
let mut a=glam::Vec3::ZERO;
|
||||||
|
self.contact_constrain_acceleration(&mut a);
|
||||||
|
self.body.acceleration=a;
|
||||||
|
self.walk.state=WalkEnum::Reached;
|
||||||
|
}else{
|
||||||
|
let accel=self.walk_accel.min(self.gravity.length()*self.friction);
|
||||||
|
let time_delta=target_diff.length()/accel;
|
||||||
|
let mut a=target_diff/time_delta;
|
||||||
|
self.contact_constrain_acceleration(&mut a);
|
||||||
|
self.body.acceleration=a;
|
||||||
|
self.walk.target_time=self.body.time+((time_delta as f64)*1_000_000_000f64) as TIME;
|
||||||
|
self.walk.state=WalkEnum::Transient;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
self.walk.state=WalkEnum::Reached;//there is no walk target while not grounded
|
||||||
|
}
|
||||||
|
}
|
||||||
fn next_walk_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
|
fn next_walk_instruction(&self) -> Option<TimedInstruction<PhysicsInstruction>> {
|
||||||
//check if you have a valid walk state and create an instruction
|
//check if you have a valid walk state and create an instruction
|
||||||
if self.grounded{
|
if self.grounded{
|
||||||
@@ -432,10 +583,6 @@ impl PhysicsState {
|
|||||||
time:self.walk.target_time,
|
time:self.walk.target_time,
|
||||||
instruction:PhysicsInstruction::ReachWalkTargetVelocity
|
instruction:PhysicsInstruction::ReachWalkTargetVelocity
|
||||||
}),
|
}),
|
||||||
WalkEnum::Invalid=>Some(TimedInstruction{
|
|
||||||
time:self.time,
|
|
||||||
instruction:PhysicsInstruction::RefreshWalkTarget,
|
|
||||||
}),
|
|
||||||
WalkEnum::Reached=>None,
|
WalkEnum::Reached=>None,
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -457,7 +604,7 @@ impl PhysicsState {
|
|||||||
let mut best_time=time_limit;
|
let mut best_time=time_limit;
|
||||||
let mut exit_face:Option<TreyMeshFace>=None;
|
let mut exit_face:Option<TreyMeshFace>=None;
|
||||||
let mesh0=self.mesh();
|
let mesh0=self.mesh();
|
||||||
let mesh1=self.models_cringe_clone.get(collision_data.model as usize).unwrap().mesh();
|
let mesh1=self.models.get(collision_data.model as usize).unwrap().mesh();
|
||||||
let (v,a)=(-self.body.velocity,self.body.acceleration);
|
let (v,a)=(-self.body.velocity,self.body.acceleration);
|
||||||
//collect x
|
//collect x
|
||||||
match collision_data.face {
|
match collision_data.face {
|
||||||
@@ -608,7 +755,7 @@ impl PhysicsState {
|
|||||||
let mut best_time=time_limit;
|
let mut best_time=time_limit;
|
||||||
let mut best_face:Option<TreyMeshFace>=None;
|
let mut best_face:Option<TreyMeshFace>=None;
|
||||||
let mesh0=self.mesh();
|
let mesh0=self.mesh();
|
||||||
let mesh1=self.models_cringe_clone.get(model_id as usize).unwrap().mesh();
|
let mesh1=self.models.get(model_id as usize).unwrap().mesh();
|
||||||
let (p,v,a)=(self.body.position,self.body.velocity,self.body.acceleration);
|
let (p,v,a)=(self.body.position,self.body.velocity,self.body.acceleration);
|
||||||
//collect x
|
//collect x
|
||||||
for t in zeroes2(mesh0.max.x-mesh1.min.x,v.x,0.5*a.x) {
|
for t in zeroes2(mesh0.max.x-mesh1.min.x,v.x,0.5*a.x) {
|
||||||
@@ -733,7 +880,7 @@ impl crate::instruction::InstructionEmitter<PhysicsInstruction> for PhysicsState
|
|||||||
collector.collect(self.predict_collision_end(self.time,time_limit,collision_data));
|
collector.collect(self.predict_collision_end(self.time,time_limit,collision_data));
|
||||||
}
|
}
|
||||||
//check for collision start instructions (against every part in the game with no optimization!!)
|
//check for collision start instructions (against every part in the game with no optimization!!)
|
||||||
for i in 0..self.models_cringe_clone.len() {
|
for i in 0..self.models.len() {
|
||||||
collector.collect(self.predict_collision_start(self.time,time_limit,i as u32));
|
collector.collect(self.predict_collision_start(self.time,time_limit,i as u32));
|
||||||
}
|
}
|
||||||
if self.grounded {
|
if self.grounded {
|
||||||
@@ -751,20 +898,29 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
fn process_instruction(&mut self, ins:TimedInstruction<PhysicsInstruction>) {
|
fn process_instruction(&mut self, ins:TimedInstruction<PhysicsInstruction>) {
|
||||||
match &ins.instruction {
|
match &ins.instruction {
|
||||||
PhysicsInstruction::StrafeTick => (),
|
PhysicsInstruction::StrafeTick => (),
|
||||||
|
PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) => (),
|
||||||
_=>println!("{:?}",ins),
|
_=>println!("{:?}",ins),
|
||||||
}
|
}
|
||||||
//selectively update body
|
//selectively update body
|
||||||
match &ins.instruction {
|
match &ins.instruction {
|
||||||
PhysicsInstruction::SetWalkTargetVelocity(_)
|
PhysicsInstruction::Input(InputInstruction::MoveMouse(_)) => (),//dodge time for mouse movement
|
||||||
|PhysicsInstruction::SetControlDir(_) => self.time=ins.time,//TODO: queue instructions
|
PhysicsInstruction::SetPosition(_) => self.time=ins.time,//TODO: queue instructions
|
||||||
PhysicsInstruction::RefreshWalkTarget
|
PhysicsInstruction::Input(_)
|
||||||
|PhysicsInstruction::ReachWalkTargetVelocity
|
|PhysicsInstruction::ReachWalkTargetVelocity
|
||||||
|PhysicsInstruction::CollisionStart(_)
|
|PhysicsInstruction::CollisionStart(_)
|
||||||
|PhysicsInstruction::CollisionEnd(_)
|
|PhysicsInstruction::CollisionEnd(_)
|
||||||
|PhysicsInstruction::StrafeTick
|
|PhysicsInstruction::StrafeTick => self.advance_time(ins.time),
|
||||||
|PhysicsInstruction::Jump => self.advance_time(ins.time),
|
|
||||||
}
|
}
|
||||||
match ins.instruction {
|
match ins.instruction {
|
||||||
|
PhysicsInstruction::SetPosition(position)=>{
|
||||||
|
//temp
|
||||||
|
self.body.position=position;
|
||||||
|
//manual clear //for c in self.contacts{process_instruction(CollisionEnd(c))}
|
||||||
|
self.contacts.clear();
|
||||||
|
self.body.acceleration=self.gravity;
|
||||||
|
self.walk.state=WalkEnum::Reached;
|
||||||
|
self.grounded=false;
|
||||||
|
}
|
||||||
PhysicsInstruction::CollisionStart(c) => {
|
PhysicsInstruction::CollisionStart(c) => {
|
||||||
//check ground
|
//check ground
|
||||||
match &c.face {
|
match &c.face {
|
||||||
@@ -779,14 +935,16 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
let mut v=self.body.velocity;
|
let mut v=self.body.velocity;
|
||||||
self.contact_constrain_velocity(&mut v);
|
self.contact_constrain_velocity(&mut v);
|
||||||
self.body.velocity=v;
|
self.body.velocity=v;
|
||||||
self.walk.state=WalkEnum::Invalid;
|
if self.grounded&&self.controls&CONTROL_JUMP!=0{
|
||||||
|
self.jump();
|
||||||
|
}
|
||||||
|
self.refresh_walk_target();
|
||||||
},
|
},
|
||||||
PhysicsInstruction::CollisionEnd(c) => {
|
PhysicsInstruction::CollisionEnd(c) => {
|
||||||
self.contacts.remove(&c);//remove contact before calling contact_constrain_acceleration
|
self.contacts.remove(&c);//remove contact before calling contact_constrain_acceleration
|
||||||
let mut a=self.gravity;
|
let mut a=self.gravity;
|
||||||
self.contact_constrain_acceleration(&mut a);
|
self.contact_constrain_acceleration(&mut a);
|
||||||
self.body.acceleration=a;
|
self.body.acceleration=a;
|
||||||
self.walk.state=WalkEnum::Invalid;
|
|
||||||
//check ground
|
//check ground
|
||||||
match &c.face {
|
match &c.face {
|
||||||
AabbFace::Top => {
|
AabbFace::Top => {
|
||||||
@@ -794,27 +952,18 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
},
|
self.refresh_walk_target();
|
||||||
PhysicsInstruction::SetControlDir(control_dir)=>{
|
|
||||||
self.temp_control_dir=control_dir;
|
|
||||||
self.walk.state=WalkEnum::Invalid;
|
|
||||||
},
|
},
|
||||||
PhysicsInstruction::StrafeTick => {
|
PhysicsInstruction::StrafeTick => {
|
||||||
//let control_dir=self.get_control_dir();//this should respect your mouse interpolation settings
|
let camera_mat=self.camera.simulate_move_rotation_y(self.mouse_interpolation.interpolated_position(self.time).x-self.mouse_interpolation.mouse0.x);
|
||||||
let d=self.body.velocity.dot(self.temp_control_dir);
|
let control_dir=camera_mat*get_control_dir(self.controls);
|
||||||
|
let d=self.body.velocity.dot(control_dir);
|
||||||
if d<self.mv {
|
if d<self.mv {
|
||||||
let mut v=self.body.velocity+(self.mv-d)*self.temp_control_dir;
|
let mut v=self.body.velocity+(self.mv-d)*control_dir;
|
||||||
self.contact_constrain_velocity(&mut v);
|
self.contact_constrain_velocity(&mut v);
|
||||||
self.body.velocity=v;
|
self.body.velocity=v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PhysicsInstruction::Jump => {
|
|
||||||
self.grounded=false;//do I need this?
|
|
||||||
let mut v=self.body.velocity+glam::Vec3::new(0.0,0.715588/2.0*100.0,0.0);
|
|
||||||
self.contact_constrain_velocity(&mut v);
|
|
||||||
self.body.velocity=v;
|
|
||||||
self.walk.state=WalkEnum::Invalid;
|
|
||||||
},
|
|
||||||
PhysicsInstruction::ReachWalkTargetVelocity => {
|
PhysicsInstruction::ReachWalkTargetVelocity => {
|
||||||
//precisely set velocity
|
//precisely set velocity
|
||||||
let mut a=glam::Vec3::ZERO;
|
let mut a=glam::Vec3::ZERO;
|
||||||
@@ -825,32 +974,58 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
self.body.velocity=v;
|
self.body.velocity=v;
|
||||||
self.walk.state=WalkEnum::Reached;
|
self.walk.state=WalkEnum::Reached;
|
||||||
},
|
},
|
||||||
PhysicsInstruction::RefreshWalkTarget => {
|
PhysicsInstruction::Input(input_instruction) => {
|
||||||
//calculate acceleration yada yada
|
let mut refresh_walk_target=false;
|
||||||
if self.grounded{
|
match input_instruction{
|
||||||
let mut v=self.walk.target_velocity;
|
InputInstruction::MoveMouse(m) => {
|
||||||
self.contact_constrain_velocity(&mut v);
|
self.camera.angles=self.camera.simulate_move_angles(self.mouse_interpolation.mouse1-self.mouse_interpolation.mouse0);
|
||||||
let mut target_diff=v-self.body.velocity;
|
self.mouse_interpolation.move_mouse(self.time,m);
|
||||||
target_diff.y=0f32;
|
refresh_walk_target=true;
|
||||||
if target_diff==glam::Vec3::ZERO{
|
},
|
||||||
let mut a=glam::Vec3::ZERO;
|
InputInstruction::MoveForward(s) => {
|
||||||
self.contact_constrain_acceleration(&mut a);
|
self.set_control(CONTROL_MOVEFORWARD,s);
|
||||||
self.body.acceleration=a;
|
refresh_walk_target=true;
|
||||||
self.walk.state=WalkEnum::Reached;
|
},
|
||||||
}else{
|
InputInstruction::MoveLeft(s) => {
|
||||||
let accel=self.walk_accel.min(self.gravity.length()*self.friction);
|
self.set_control(CONTROL_MOVELEFT,s);
|
||||||
let time_delta=target_diff.length()/accel;
|
refresh_walk_target=true;
|
||||||
let mut a=target_diff/time_delta;
|
},
|
||||||
self.contact_constrain_acceleration(&mut a);
|
InputInstruction::MoveBack(s) => {
|
||||||
self.body.acceleration=a;
|
self.set_control(CONTROL_MOVEBACK,s);
|
||||||
self.walk.target_time=self.body.time+((time_delta as f64)*1_000_000_000f64) as TIME;
|
refresh_walk_target=true;
|
||||||
self.walk.state=WalkEnum::Transient;
|
},
|
||||||
}
|
InputInstruction::MoveRight(s) => {
|
||||||
|
self.set_control(CONTROL_MOVERIGHT,s);
|
||||||
|
refresh_walk_target=true;
|
||||||
|
},
|
||||||
|
InputInstruction::MoveUp(s) => {
|
||||||
|
self.set_control(CONTROL_MOVEUP,s);
|
||||||
|
refresh_walk_target=true;
|
||||||
|
},
|
||||||
|
InputInstruction::MoveDown(s) => {
|
||||||
|
self.set_control(CONTROL_MOVEDOWN,s);
|
||||||
|
refresh_walk_target=true;
|
||||||
|
},
|
||||||
|
InputInstruction::Jump(s) => {
|
||||||
|
self.set_control(CONTROL_JUMP,s);
|
||||||
|
refresh_walk_target=true;
|
||||||
|
if self.grounded{
|
||||||
|
self.jump();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
InputInstruction::Zoom(s) => {
|
||||||
|
self.set_control(CONTROL_ZOOM,s);
|
||||||
|
},
|
||||||
|
InputInstruction::Reset => println!("reset"),
|
||||||
|
}
|
||||||
|
//calculate control dir
|
||||||
|
let camera_mat=self.camera.simulate_move_rotation_y(self.mouse_interpolation.interpolated_position(self.time).x-self.mouse_interpolation.mouse0.x);
|
||||||
|
let control_dir=camera_mat*get_control_dir(self.controls);
|
||||||
|
//calculate walk target velocity
|
||||||
|
if refresh_walk_target{
|
||||||
|
self.walk.target_velocity=self.walkspeed*control_dir;
|
||||||
|
self.refresh_walk_target();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
PhysicsInstruction::SetWalkTargetVelocity(v) => {
|
|
||||||
self.walk.target_velocity=v;
|
|
||||||
self.walk.state=WalkEnum::Invalid;
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
use std::time::Instant;
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use web_sys::{ImageBitmapRenderingContext, OffscreenCanvas};
|
use web_sys::{ImageBitmapRenderingContext, OffscreenCanvas};
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{self, WindowEvent},
|
event::{self, WindowEvent, DeviceEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,8 +51,8 @@ pub trait Example: 'static + Sized {
|
|||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
queue: &wgpu::Queue,
|
queue: &wgpu::Queue,
|
||||||
);
|
);
|
||||||
fn update(&mut self, event: WindowEvent);
|
fn update(&mut self, device: &wgpu::Device, event: WindowEvent);
|
||||||
fn move_mouse(&mut self, delta: (f64,f64));
|
fn device_event(&mut self, event: DeviceEvent);
|
||||||
fn render(
|
fn render(
|
||||||
&mut self,
|
&mut self,
|
||||||
view: &wgpu::TextureView,
|
view: &wgpu::TextureView,
|
||||||
@@ -346,17 +344,14 @@ fn start<E: Example>(
|
|||||||
println!("{:#?}", instance.generate_report());
|
println!("{:#?}", instance.generate_report());
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
example.update(event);
|
example.update(&device,event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
event::Event::DeviceEvent {
|
event::Event::DeviceEvent {
|
||||||
event:
|
event,
|
||||||
winit::event::DeviceEvent::MouseMotion {
|
|
||||||
delta,
|
|
||||||
},
|
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
example.move_mouse(delta);
|
example.device_event(event);
|
||||||
},
|
},
|
||||||
event::Event::RedrawRequested(_) => {
|
event::Event::RedrawRequested(_) => {
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ pub mod framework;
|
|||||||
pub mod body;
|
pub mod body;
|
||||||
pub mod zeroes;
|
pub mod zeroes;
|
||||||
pub mod instruction;
|
pub mod instruction;
|
||||||
|
pub mod load_roblox;
|
||||||
|
|||||||
27
src/load_roblox.rs
Normal file
27
src/load_roblox.rs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
fn class_is_a(class: &str, superclass: &str) -> bool {
|
||||||
|
if class==superclass {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
let class_descriptor=rbx_reflection_database::get().classes.get(class);
|
||||||
|
if let Some(descriptor) = &class_descriptor {
|
||||||
|
if let Some(class_super) = &descriptor.superclass {
|
||||||
|
return class_is_a(&class_super, superclass)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
pub fn get_objects<R: std::io::Read>(buf_thing: R, superclass: &str) -> Result<std::vec::Vec<rbx_dom_weak::Instance>, Box<dyn std::error::Error>> {
|
||||||
|
// Using buffered I/O is recommended with rbx_binary
|
||||||
|
let dom = rbx_binary::from_reader(buf_thing)?;
|
||||||
|
|
||||||
|
let mut objects = std::vec::Vec::<rbx_dom_weak::Instance>::new();
|
||||||
|
//move matching instances into objects
|
||||||
|
let (_,mut instances) = dom.into_raw();
|
||||||
|
for (_,instance) in instances.drain() {
|
||||||
|
if class_is_a(instance.class.as_str(), superclass) {
|
||||||
|
objects.push(instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(objects)
|
||||||
|
}
|
||||||
1001
src/main.rs
1001
src/main.rs
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,4 @@
|
|||||||
struct SkyOutput {
|
struct Camera {
|
||||||
@builtin(position) position: vec4<f32>,
|
|
||||||
@location(0) sampledir: vec3<f32>,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Data {
|
|
||||||
// from camera to screen
|
// from camera to screen
|
||||||
proj: mat4x4<f32>,
|
proj: mat4x4<f32>,
|
||||||
// from screen to camera
|
// from screen to camera
|
||||||
@@ -13,9 +8,16 @@ struct Data {
|
|||||||
// camera position
|
// camera position
|
||||||
cam_pos: vec4<f32>,
|
cam_pos: vec4<f32>,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//group 0 is the camera
|
||||||
@group(0)
|
@group(0)
|
||||||
@binding(0)
|
@binding(0)
|
||||||
var<uniform> r_data: Data;
|
var<uniform> camera: Camera;
|
||||||
|
|
||||||
|
struct SkyOutput {
|
||||||
|
@builtin(position) position: vec4<f32>,
|
||||||
|
@location(0) sampledir: vec3<f32>,
|
||||||
|
};
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vs_sky(@builtin(vertex_index) vertex_index: u32) -> SkyOutput {
|
fn vs_sky(@builtin(vertex_index) vertex_index: u32) -> SkyOutput {
|
||||||
@@ -30,8 +32,8 @@ fn vs_sky(@builtin(vertex_index) vertex_index: u32) -> SkyOutput {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// transposition = inversion for this orthonormal matrix
|
// transposition = inversion for this orthonormal matrix
|
||||||
let inv_model_view = transpose(mat3x3<f32>(r_data.view[0].xyz, r_data.view[1].xyz, r_data.view[2].xyz));
|
let inv_model_view = transpose(mat3x3<f32>(camera.view[0].xyz, camera.view[1].xyz, camera.view[2].xyz));
|
||||||
let unprojected = r_data.proj_inv * pos;
|
let unprojected = camera.proj_inv * pos;
|
||||||
|
|
||||||
var result: SkyOutput;
|
var result: SkyOutput;
|
||||||
result.sampledir = inv_model_view * unprojected.xyz;
|
result.sampledir = inv_model_view * unprojected.xyz;
|
||||||
@@ -39,54 +41,70 @@ fn vs_sky(@builtin(vertex_index) vertex_index: u32) -> SkyOutput {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EntityOutput {
|
struct ModelInstance{
|
||||||
|
transform:mat4x4<f32>,
|
||||||
|
//texture_transform:mat3x3<f32>,
|
||||||
|
color:vec4<f32>,
|
||||||
|
}
|
||||||
|
//my fancy idea is to create a megatexture for each model that includes all the textures each intance will need
|
||||||
|
//the texture transform then maps the texture coordinates to the location of the specific texture
|
||||||
|
//group 1 is the model
|
||||||
|
@group(1)
|
||||||
|
@binding(0)
|
||||||
|
var<storage> model_instances: array<ModelInstance>;
|
||||||
|
@group(1)
|
||||||
|
@binding(1)
|
||||||
|
var model_texture: texture_2d<f32>;
|
||||||
|
@group(1)
|
||||||
|
@binding(2)
|
||||||
|
var model_sampler: sampler;
|
||||||
|
|
||||||
|
struct EntityOutputTexture {
|
||||||
@builtin(position) position: vec4<f32>,
|
@builtin(position) position: vec4<f32>,
|
||||||
@location(1) texture: vec2<f32>,
|
@location(1) texture: vec2<f32>,
|
||||||
@location(2) normal: vec3<f32>,
|
@location(2) normal: vec3<f32>,
|
||||||
@location(3) view: vec3<f32>,
|
@location(3) view: vec3<f32>,
|
||||||
|
@location(4) color: vec4<f32>,
|
||||||
};
|
};
|
||||||
const MAX_ENTITY_INSTANCES=1024;
|
|
||||||
@group(1)
|
|
||||||
@binding(0)
|
|
||||||
var<uniform> r_EntityTransform: array<mat4x4<f32>,MAX_ENTITY_INSTANCES>;
|
|
||||||
|
|
||||||
@vertex
|
@vertex
|
||||||
fn vs_entity(
|
fn vs_entity_texture(
|
||||||
@builtin(instance_index) instance: u32,
|
@builtin(instance_index) instance: u32,
|
||||||
@location(0) pos: vec3<f32>,
|
@location(0) pos: vec3<f32>,
|
||||||
@location(1) texture: vec2<f32>,
|
@location(1) texture: vec2<f32>,
|
||||||
@location(2) normal: vec3<f32>,
|
@location(2) normal: vec3<f32>,
|
||||||
) -> EntityOutput {
|
@location(3) color: vec4<f32>,
|
||||||
var position: vec4<f32> = r_EntityTransform[instance] * vec4<f32>(pos, 1.0);
|
) -> EntityOutputTexture {
|
||||||
var result: EntityOutput;
|
var position: vec4<f32> = model_instances[instance].transform * vec4<f32>(pos, 1.0);
|
||||||
result.normal = (r_EntityTransform[instance] * vec4<f32>(normal, 0.0)).xyz;
|
var result: EntityOutputTexture;
|
||||||
result.texture=texture;
|
result.normal = (model_instances[instance].transform * vec4<f32>(normal, 0.0)).xyz;
|
||||||
result.view = position.xyz - r_data.cam_pos.xyz;
|
result.texture=texture;//(model_instances[instance].texture_transform * vec3<f32>(texture, 1.0)).xy;
|
||||||
result.position = r_data.proj * r_data.view * position;
|
result.color=model_instances[instance].color * color;
|
||||||
|
result.view = position.xyz - camera.cam_pos.xyz;
|
||||||
|
result.position = camera.proj * camera.view * position;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0)
|
//group 2 is the skybox texture
|
||||||
|
@group(2)
|
||||||
|
@binding(0)
|
||||||
|
var cube_texture: texture_cube<f32>;
|
||||||
|
@group(2)
|
||||||
@binding(1)
|
@binding(1)
|
||||||
var r_texture: texture_cube<f32>;
|
var cube_sampler: sampler;
|
||||||
@group(0)
|
|
||||||
@binding(2)
|
|
||||||
var r_sampler: sampler;
|
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn fs_sky(vertex: SkyOutput) -> @location(0) vec4<f32> {
|
fn fs_sky(vertex: SkyOutput) -> @location(0) vec4<f32> {
|
||||||
return textureSample(r_texture, r_sampler, vertex.sampledir);
|
return textureSample(cube_texture, model_sampler, vertex.sampledir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn fs_entity(vertex: EntityOutput) -> @location(0) vec4<f32> {
|
fn fs_entity_texture(vertex: EntityOutputTexture) -> @location(0) vec4<f32> {
|
||||||
let incident = normalize(vertex.view);
|
let incident = normalize(vertex.view);
|
||||||
let normal = normalize(vertex.normal);
|
let normal = normalize(vertex.normal);
|
||||||
let d = dot(normal, incident);
|
let d = dot(normal, incident);
|
||||||
let reflected = incident - 2.0 * d * normal;
|
let reflected = incident - 2.0 * d * normal;
|
||||||
|
|
||||||
let dir = vec3<f32>(-1.0)+2.0*vec3<f32>(vertex.texture.x,0.0,vertex.texture.y);
|
let fragment_color = textureSample(model_texture, model_sampler, vertex.texture)*vertex.color;
|
||||||
let texture_color = textureSample(r_texture, r_sampler, dir).rgb;
|
let reflected_color = textureSample(cube_texture, cube_sampler, reflected).rgb;
|
||||||
let reflected_color = textureSample(r_texture, r_sampler, reflected).rgb;
|
return mix(vec4<f32>(vec3<f32>(0.1) + 0.5 * reflected_color,1.0),fragment_color,1.0-pow(1.0-abs(d),2.0));
|
||||||
return vec4<f32>(mix(vec3<f32>(0.1) + 0.5 * reflected_color,texture_color,1.0-pow(1.0-abs(d),2.0)), 1.0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user