Fix incorrect textures being rendered #29
267
Cargo.lock
generated
267
Cargo.lock
generated
@@ -50,7 +50,7 @@ dependencies = [
|
|||||||
"ndk-context",
|
"ndk-context",
|
||||||
"ndk-sys",
|
"ndk-sys",
|
||||||
"num_enum 0.7.3",
|
"num_enum 0.7.3",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -217,7 +217,7 @@ checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"async-task",
|
"async-task",
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
"fastrand 2.1.1",
|
"fastrand",
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
@@ -291,7 +291,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -331,7 +331,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -348,7 +348,7 @@ checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -470,15 +470,6 @@ version = "2.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
|
||||||
[[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 = "blocking"
|
name = "blocking"
|
||||||
version = "1.6.1"
|
version = "1.6.1"
|
||||||
@@ -509,7 +500,7 @@ checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -613,7 +604,7 @@ dependencies = [
|
|||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -648,10 +639,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5"
|
checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
|
"color-spantrace",
|
||||||
"eyre",
|
"eyre",
|
||||||
"indenter",
|
"indenter",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"owo-colors",
|
"owo-colors",
|
||||||
|
"tracing-error",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "color-spantrace"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
"owo-colors",
|
||||||
|
"tracing-core",
|
||||||
|
"tracing-error",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -727,15 +732,6 @@ dependencies = [
|
|||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpufeatures"
|
|
||||||
version = "0.2.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.4.2"
|
version = "1.4.2"
|
||||||
@@ -766,16 +762,6 @@ version = "0.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||||
|
|
||||||
[[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 = "cty"
|
name = "cty"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@@ -788,16 +774,6 @@ version = "1.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
|
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "digest"
|
|
||||||
version = "0.10.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
|
||||||
dependencies = [
|
|
||||||
"block-buffer",
|
|
||||||
"crypto-common",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "directories"
|
name = "directories"
|
||||||
version = "5.0.1"
|
version = "5.0.1"
|
||||||
@@ -942,7 +918,7 @@ checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1002,15 +978,6 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fastrand"
|
|
||||||
version = "1.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
|
|
||||||
dependencies = [
|
|
||||||
"instant",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
@@ -1089,7 +1056,7 @@ version = "2.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5"
|
checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand 2.1.1",
|
"fastrand",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
"parking",
|
"parking",
|
||||||
@@ -1104,7 +1071,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1149,16 +1116,6 @@ dependencies = [
|
|||||||
"windows",
|
"windows",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[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.15"
|
version = "0.2.15"
|
||||||
@@ -1475,7 +1432,7 @@ dependencies = [
|
|||||||
"combine",
|
"combine",
|
||||||
"jni-sys",
|
"jni-sys",
|
||||||
"log",
|
"log",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"windows-sys 0.45.0",
|
"windows-sys 0.45.0",
|
||||||
]
|
]
|
||||||
@@ -1503,7 +1460,7 @@ checksum = "062c875482ccb676fd40c804a40e3824d4464c18c364547456d1c8e8e951ae47"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"miette",
|
"miette",
|
||||||
"nom",
|
"nom",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1562,7 +1519,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1624,7 +1581,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex-syntax 0.8.4",
|
"regex-syntax 0.8.4",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1658,7 +1615,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1708,7 +1665,7 @@ checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"miette-derive",
|
"miette-derive",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1720,7 +1677,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1797,7 +1754,7 @@ dependencies = [
|
|||||||
"raw-window-handle 0.4.3",
|
"raw-window-handle 0.4.3",
|
||||||
"raw-window-handle 0.5.2",
|
"raw-window-handle 0.5.2",
|
||||||
"raw-window-handle 0.6.2",
|
"raw-window-handle 0.6.2",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1923,10 +1880,10 @@ version = "0.7.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate 3.2.0",
|
"proc-macro-crate 1.3.1",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2091,7 +2048,7 @@ dependencies = [
|
|||||||
"phf_shared 0.11.2",
|
"phf_shared 0.11.2",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2137,7 +2094,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2159,7 +2116,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066"
|
checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic-waker",
|
"atomic-waker",
|
||||||
"fastrand 2.1.1",
|
"fastrand",
|
||||||
"futures-io",
|
"futures-io",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2260,7 +2217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd"
|
checksum = "8021cf59c8ec9c432cfc2526ac6b8aa508ecaf29cd415f271b8406c1b851c3fd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2283,7 +2240,7 @@ dependencies = [
|
|||||||
"itertools 0.13.0",
|
"itertools 0.13.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2343,15 +2300,6 @@ dependencies = [
|
|||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "random-string"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f70fd13c3024ae3f17381bb5c4d409c6dc9ea6895c08fa2147aba305bea3c4af"
|
|
||||||
dependencies = [
|
|
||||||
"fastrand 1.9.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raw-window-handle"
|
name = "raw-window-handle"
|
||||||
version = "0.4.3"
|
version = "0.4.3"
|
||||||
@@ -2399,7 +2347,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"libredox",
|
"libredox",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2548,7 +2496,7 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2571,7 +2519,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2583,17 +2531,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha1"
|
|
||||||
version = "0.10.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"cpufeatures",
|
|
||||||
"digest",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sharded-slab"
|
name = "sharded-slab"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
@@ -2688,7 +2625,7 @@ dependencies = [
|
|||||||
"scan_fmt",
|
"scan_fmt",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
"tracing",
|
"tracing",
|
||||||
"wayland-protocols",
|
"wayland-protocols",
|
||||||
"wayland-protocols-misc",
|
"wayland-protocols-misc",
|
||||||
@@ -2716,9 +2653,10 @@ checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr"
|
name = "stardust-xr"
|
||||||
version = "0.45.0"
|
version = "0.45.0"
|
||||||
source = "git+https://github.com/StardustXR/core.git#1bc94e67cad6b69fa3c509598b07bc5085cc65a3"
|
source = "git+https://github.com/StardustXR/core.git?branch=dev#b68343a67f93e95ac5bec138c8ee0e082189a489"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cluFlock",
|
"cluFlock",
|
||||||
|
"color-eyre",
|
||||||
"dirs",
|
"dirs",
|
||||||
"global_counter",
|
"global_counter",
|
||||||
"mint",
|
"mint",
|
||||||
@@ -2728,7 +2666,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"shiva-color-rs",
|
"shiva-color-rs",
|
||||||
"stardust-xr-schemas",
|
"stardust-xr-schemas",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
@@ -2736,7 +2674,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr-schemas"
|
name = "stardust-xr-schemas"
|
||||||
version = "1.5.3"
|
version = "1.5.3"
|
||||||
source = "git+https://github.com/StardustXR/core.git#1bc94e67cad6b69fa3c509598b07bc5085cc65a3"
|
source = "git+https://github.com/StardustXR/core.git?branch=dev#b68343a67f93e95ac5bec138c8ee0e082189a489"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"flexbuffers",
|
"flexbuffers",
|
||||||
@@ -2744,10 +2682,10 @@ dependencies = [
|
|||||||
"futures-util",
|
"futures-util",
|
||||||
"kdl",
|
"kdl",
|
||||||
"manifest-dir-macros",
|
"manifest-dir-macros",
|
||||||
"random-string",
|
"nanoid",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
"tokio",
|
"tokio",
|
||||||
"zbus",
|
"zbus",
|
||||||
]
|
]
|
||||||
@@ -2814,12 +2752,12 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stereokit-macros"
|
name = "stereokit-macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/mvvvv/StereoKit-rust.git#1a0ba771a948e31044f0dd264efcc9f5be4682d5"
|
source = "git+https://github.com/mvvvv/StereoKit-rust.git#73ffaae6f42aa369e599a6ea0391f77840d682d8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stereokit-rust"
|
name = "stereokit-rust"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/mvvvv/StereoKit-rust.git#1a0ba771a948e31044f0dd264efcc9f5be4682d5"
|
source = "git+https://github.com/mvvvv/StereoKit-rust.git#73ffaae6f42aa369e599a6ea0391f77840d682d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android-activity",
|
"android-activity",
|
||||||
"android_logger",
|
"android_logger",
|
||||||
@@ -2833,7 +2771,7 @@ dependencies = [
|
|||||||
"ndk-sys",
|
"ndk-sys",
|
||||||
"openxr-sys",
|
"openxr-sys",
|
||||||
"stereokit-macros",
|
"stereokit-macros",
|
||||||
"thiserror",
|
"thiserror 2.0.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2871,7 +2809,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rustversion",
|
"rustversion",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2887,9 +2825,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.77"
|
version = "2.0.87"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed"
|
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -2915,7 +2853,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
|
checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"fastrand 2.1.1",
|
"fastrand",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix",
|
"rustix",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
@@ -2938,7 +2876,16 @@ version = "1.0.63"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl 1.0.63",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror"
|
||||||
|
version = "2.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror-impl 2.0.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2949,7 +2896,18 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thiserror-impl"
|
||||||
|
version = "2.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2998,7 +2956,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3151,7 +3109,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3164,6 +3122,16 @@ dependencies = [
|
|||||||
"valuable",
|
"valuable",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-error"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e"
|
||||||
|
dependencies = [
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-log"
|
name = "tracing-log"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -3230,12 +3198,6 @@ version = "0.2.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "typenum"
|
|
||||||
version = "1.17.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uds_windows"
|
name = "uds_windows"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@@ -3433,7 +3395,7 @@ version = "0.1.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3473,7 +3435,7 @@ checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3484,7 +3446,7 @@ checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3776,7 +3738,7 @@ dependencies = [
|
|||||||
"phf_shared 0.11.2",
|
"phf_shared 0.11.2",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror",
|
"thiserror 1.0.63",
|
||||||
"unicase",
|
"unicase",
|
||||||
"xkbcommon-rs-codegen",
|
"xkbcommon-rs-codegen",
|
||||||
"xkeysym",
|
"xkeysym",
|
||||||
@@ -3809,9 +3771,9 @@ checksum = "539a77ee7c0de333dcc6da69b177380a0b81e0dacfa4f7344c465a36871ee601"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zbus"
|
name = "zbus"
|
||||||
version = "4.4.0"
|
version = "5.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725"
|
checksum = "333be40ef37976542e10832ba961e3e44ea215a6b1e2673066b303ee3e0ede10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-broadcast",
|
"async-broadcast",
|
||||||
"async-executor",
|
"async-executor",
|
||||||
@@ -3826,20 +3788,17 @@ dependencies = [
|
|||||||
"enumflags2",
|
"enumflags2",
|
||||||
"event-listener",
|
"event-listener",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-sink",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"hex",
|
"hex",
|
||||||
"nix 0.29.0",
|
"nix 0.29.0",
|
||||||
"ordered-stream",
|
"ordered-stream",
|
||||||
"rand",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"sha1",
|
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"uds_windows",
|
"uds_windows",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
"xdg-home",
|
"xdg-home",
|
||||||
"zbus_macros",
|
"zbus_macros",
|
||||||
"zbus_names",
|
"zbus_names",
|
||||||
@@ -3848,22 +3807,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zbus_macros"
|
name = "zbus_macros"
|
||||||
version = "4.4.0"
|
version = "5.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e"
|
checksum = "381be624000c82e716c2a45d9213fabacf82177591fa8a6ff655d2825450601a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate 3.2.0",
|
"proc-macro-crate 3.2.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
"zvariant_utils",
|
"zvariant_utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zbus_names"
|
name = "zbus_names"
|
||||||
version = "3.0.0"
|
version = "4.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c"
|
checksum = "cdc27fbd3593ff015cef906527a2ec4115e2e3dbf6204a24d952ac4975c80614"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
@@ -3888,42 +3847,46 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zvariant"
|
name = "zvariant"
|
||||||
version = "4.2.0"
|
version = "5.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe"
|
checksum = "c690a1da8858fd4377b8cc3134a753b0bea1d8ebd78ad6e5897fab821c5e184e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"endi",
|
"endi",
|
||||||
"enumflags2",
|
"enumflags2",
|
||||||
"serde",
|
"serde",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
"zvariant_derive",
|
"zvariant_derive",
|
||||||
|
"zvariant_utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zvariant_derive"
|
name = "zvariant_derive"
|
||||||
version = "4.2.0"
|
version = "5.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449"
|
checksum = "83b6ddc1fed08493e4f2bd9350e7d00a3383467228735f3f169a9f8820fde755"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro-crate 3.2.0",
|
"proc-macro-crate 3.2.0",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.87",
|
||||||
"zvariant_utils",
|
"zvariant_utils",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zvariant_utils"
|
name = "zvariant_utils"
|
||||||
version = "2.1.0"
|
version = "3.0.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340"
|
checksum = "6f8d85190ba70bc7b9540430df078bb529620b1464ed4a606010de584e27094d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"serde",
|
||||||
|
"static_assertions",
|
||||||
|
"syn 2.0.87",
|
||||||
|
"winnow 0.6.18",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ members = ["codegen"]
|
|||||||
|
|
||||||
[workspace.dependencies.stardust-xr]
|
[workspace.dependencies.stardust-xr]
|
||||||
git = "https://github.com/StardustXR/core.git"
|
git = "https://github.com/StardustXR/core.git"
|
||||||
|
branch = "dev"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "stardust-xr-server"
|
name = "stardust-xr-server"
|
||||||
@@ -40,16 +41,17 @@ auto_link_exclude_list = [
|
|||||||
[profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
debug = true
|
debug = true
|
||||||
strip = "none"
|
strip = false
|
||||||
debug-assertions = true
|
debug-assertions = true
|
||||||
overflow-checks = true
|
overflow-checks = true
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
debug = "line-tables-only"
|
debug = "line-tables-only"
|
||||||
strip = "none"
|
strip = true
|
||||||
debug-assertions = true
|
debug-assertions = true
|
||||||
overflow-checks = false
|
overflow-checks = false
|
||||||
|
lto = "thin"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# small utility thingys
|
# small utility thingys
|
||||||
@@ -87,7 +89,7 @@ prisma = "0.1.1"
|
|||||||
libc = "0.2.155"
|
libc = "0.2.155"
|
||||||
nix = "0.29.0"
|
nix = "0.29.0"
|
||||||
input-event-codes = "6.2.0"
|
input-event-codes = "6.2.0"
|
||||||
zbus = { version = "4.4.0", default-features = false, features = ["tokio"] }
|
zbus = { version = "5.0.0", default-features = false, features = ["tokio"] }
|
||||||
directories = "5.0.1"
|
directories = "5.0.1"
|
||||||
xkbcommon-rs = "0.1.0"
|
xkbcommon-rs = "0.1.0"
|
||||||
|
|
||||||
|
|||||||
@@ -64,11 +64,25 @@ fn codegen_protocol(protocol: &'static str) -> proc_macro::TokenStream {
|
|||||||
};
|
};
|
||||||
let aspect = generate_aspect(&Aspect {
|
let aspect = generate_aspect(&Aspect {
|
||||||
name: "interface".to_string(),
|
name: "interface".to_string(),
|
||||||
|
id: 0,
|
||||||
description: protocol.description.clone(),
|
description: protocol.description.clone(),
|
||||||
inherits: vec![],
|
inherits: vec![],
|
||||||
members: p.members,
|
members: p.members,
|
||||||
});
|
});
|
||||||
quote!(#node_id #aspect)
|
quote! {
|
||||||
|
#node_id
|
||||||
|
#aspect
|
||||||
|
pub struct Interface;
|
||||||
|
impl crate::nodes::Aspect for Interface {
|
||||||
|
impl_aspect_for_interface_aspect!{}
|
||||||
|
}
|
||||||
|
pub fn create_interface(client: &std::sync::Arc<crate::core::client::Client>) -> color_eyre::eyre::Result<()>{
|
||||||
|
let node = crate::nodes::Node::from_id(client,INTERFACE_NODE_ID,false);
|
||||||
|
node.add_aspect(Interface);
|
||||||
|
node.add_to_scenegraph()?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let custom_enums = protocol
|
let custom_enums = protocol
|
||||||
@@ -177,11 +191,12 @@ fn generate_aspect(aspect: &Aspect) -> TokenStream {
|
|||||||
Span::call_site(),
|
Span::call_site(),
|
||||||
);
|
);
|
||||||
let client_side_members = client_members
|
let client_side_members = client_members
|
||||||
.map(generate_member)
|
.map(|m| generate_member(aspect.id, m))
|
||||||
.reduce(fold_tokens)
|
.reduce(fold_tokens)
|
||||||
.map(|t| {
|
.map(|t| {
|
||||||
// TODO: properly import all dependencies
|
// TODO: properly import all dependencies
|
||||||
quote! {
|
quote! {
|
||||||
|
#[allow(clippy::all)]
|
||||||
pub mod #client_mod_name {
|
pub mod #client_mod_name {
|
||||||
use super::*;
|
use super::*;
|
||||||
#t
|
#t
|
||||||
@@ -190,11 +205,6 @@ fn generate_aspect(aspect: &Aspect) -> TokenStream {
|
|||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let aspect_trait_name = Ident::new(
|
|
||||||
&format!("{}Aspect", &aspect.name.to_case(Case::Pascal)),
|
|
||||||
Span::call_site(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let opcodes = aspect
|
let opcodes = aspect
|
||||||
.members
|
.members
|
||||||
.iter()
|
.iter()
|
||||||
@@ -219,31 +229,86 @@ fn generate_aspect(aspect: &Aspect) -> TokenStream {
|
|||||||
let alias_info = generate_alias_info(aspect);
|
let alias_info = generate_alias_info(aspect);
|
||||||
|
|
||||||
let server_side_members = server_members
|
let server_side_members = server_members
|
||||||
.map(generate_member)
|
.map(|m| generate_member(aspect.id, m))
|
||||||
.reduce(fold_tokens)
|
.reduce(fold_tokens)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let add_node_members = aspect
|
let aspect_trait_name = Ident::new(
|
||||||
|
&format!("{}Aspect", &aspect.name.to_case(Case::Pascal)),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
let run_signals = aspect
|
||||||
.members
|
.members
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|m| m.side == Side::Server)
|
.filter(|m| m.side == Side::Server)
|
||||||
.map(generate_handler)
|
.filter(|m| m._type == MemberType::Signal)
|
||||||
|
.map(|m| generate_run_member(&aspect_trait_name, MemberType::Signal, m))
|
||||||
|
.reduce(fold_tokens)
|
||||||
|
.unwrap_or_default();
|
||||||
|
let run_methods = aspect
|
||||||
|
.members
|
||||||
|
.iter()
|
||||||
|
.filter(|m| m.side == Side::Server)
|
||||||
|
.filter(|m| m._type == MemberType::Method)
|
||||||
|
.map(|m| generate_run_member(&aspect_trait_name, MemberType::Method, m))
|
||||||
.reduce(fold_tokens)
|
.reduce(fold_tokens)
|
||||||
.map(|members| {
|
|
||||||
quote! {
|
|
||||||
fn add_node_members(node: &crate::nodes::Node) {
|
|
||||||
#members
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let server_side_members = quote! {
|
let server_side_members = quote! {
|
||||||
|
#[allow(clippy::all)]
|
||||||
#[doc = #description]
|
#[doc = #description]
|
||||||
pub trait #aspect_trait_name {
|
pub trait #aspect_trait_name {
|
||||||
#add_node_members
|
|
||||||
#server_side_members
|
#server_side_members
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
quote!(#opcodes #alias_info #client_side_members #server_side_members)
|
let aspect_macro_name = Ident::new(
|
||||||
|
&format!(
|
||||||
|
"impl_aspect_for_{}_aspect",
|
||||||
|
aspect.name.to_case(Case::Snake)
|
||||||
|
),
|
||||||
|
Span::call_site(),
|
||||||
|
);
|
||||||
|
let aspect_id = aspect.id;
|
||||||
|
let aspect_macro = quote! {
|
||||||
|
macro_rules! #aspect_macro_name {
|
||||||
|
() => {
|
||||||
|
fn id(&self) -> u64 {
|
||||||
|
#aspect_id
|
||||||
|
}
|
||||||
|
fn as_any(self: Arc<Self>) -> Arc<dyn std::any::Any + Send + Sync + 'static> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
#[allow(clippy::all)]
|
||||||
|
fn run_signal(
|
||||||
|
&self,
|
||||||
|
_calling_client: std::sync::Arc<crate::core::client::Client>,
|
||||||
|
_node: std::sync::Arc<crate::nodes::Node>,
|
||||||
|
_signal: u64,
|
||||||
|
_message: crate::nodes::Message
|
||||||
|
) -> Result<(), stardust_xr::scenegraph::ScenegraphError> {
|
||||||
|
match _signal {
|
||||||
|
#run_signals
|
||||||
|
_ => Err(stardust_xr::scenegraph::ScenegraphError::MemberNotFound)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[allow(clippy::all)]
|
||||||
|
fn run_method(
|
||||||
|
&self,
|
||||||
|
_calling_client: std::sync::Arc<crate::core::client::Client>,
|
||||||
|
_node: std::sync::Arc<crate::nodes::Node>,
|
||||||
|
_method: u64,
|
||||||
|
_message: crate::nodes::Message,
|
||||||
|
_method_response: crate::nodes::MethodResponseSender,
|
||||||
|
) {
|
||||||
|
match _method {
|
||||||
|
#run_methods
|
||||||
|
_ => {
|
||||||
|
let _ = _method_response.send(Err(stardust_xr::scenegraph::ScenegraphError::MemberNotFound));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
quote!(#opcodes #alias_info #client_side_members #server_side_members #aspect_macro)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_alias_opcodes(aspect: &Aspect, side: Side, _type: MemberType) -> TokenStream {
|
fn generate_alias_opcodes(aspect: &Aspect, side: Side, _type: MemberType) -> TokenStream {
|
||||||
@@ -283,6 +348,7 @@ fn generate_alias_info(aspect: &Aspect) -> TokenStream {
|
|||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
|
#[allow(clippy::all)]
|
||||||
pub static ref #aspect_alias_info_name: crate::nodes::alias::AliasInfo = crate::nodes::alias::AliasInfo {
|
pub static ref #aspect_alias_info_name: crate::nodes::alias::AliasInfo = crate::nodes::alias::AliasInfo {
|
||||||
server_signals: vec![#local_signals],
|
server_signals: vec![#local_signals],
|
||||||
server_methods: vec![#local_methods],
|
server_methods: vec![#local_methods],
|
||||||
@@ -293,8 +359,8 @@ fn generate_alias_info(aspect: &Aspect) -> TokenStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_member(member: &Member) -> TokenStream {
|
fn generate_member(aspect_id: u64, member: &Member) -> TokenStream {
|
||||||
let id = member.opcode;
|
let opcode = member.opcode;
|
||||||
let name = Ident::new(&member.name.to_case(Case::Snake), Span::call_site());
|
let name = Ident::new(&member.name.to_case(Case::Snake), Span::call_site());
|
||||||
let description = &member.description;
|
let description = &member.description;
|
||||||
|
|
||||||
@@ -326,27 +392,21 @@ fn generate_member(member: &Member) -> TokenStream {
|
|||||||
.unwrap_or_else(|| quote!(()));
|
.unwrap_or_else(|| quote!(()));
|
||||||
|
|
||||||
match (side, _type) {
|
match (side, _type) {
|
||||||
(Side::Client, MemberType::Method) => {
|
|
||||||
quote! {
|
|
||||||
#[doc = #description]
|
|
||||||
pub async fn #name(#argument_decls) -> color_eyre::eyre::Result<(#return_type, Vec<std::os::fd::OwnedFd>)> {
|
|
||||||
_node.execute_remote_method_typed(#id, &(#argument_uses), vec![]).await
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(Side::Client, MemberType::Signal) => {
|
(Side::Client, MemberType::Signal) => {
|
||||||
quote! {
|
quote! {
|
||||||
#[doc = #description]
|
#[doc = #description]
|
||||||
pub fn #name(#argument_decls) -> color_eyre::eyre::Result<()> {
|
pub fn #name(#argument_decls) -> color_eyre::eyre::Result<()> {
|
||||||
let serialized = stardust_xr::schemas::flex::serialize((#argument_uses))?;
|
let serialized = stardust_xr::schemas::flex::serialize((#argument_uses))?;
|
||||||
_node.send_remote_signal(#id, serialized)
|
_node.send_remote_signal(#aspect_id, #opcode, serialized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Side::Server, MemberType::Method) => {
|
(Side::Client, MemberType::Method) => {
|
||||||
quote! {
|
quote! {
|
||||||
#[doc = #description]
|
#[doc = #description]
|
||||||
fn #name(#argument_decls) -> impl std::future::Future<Output = color_eyre::eyre::Result<#return_type>> + Send + 'static;
|
pub async fn #name(#argument_decls) -> color_eyre::eyre::Result<(#return_type, Vec<std::os::fd::OwnedFd>)> {
|
||||||
|
_node.execute_remote_method_typed(#aspect_id, #opcode, &(#argument_uses), vec![]).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Side::Server, MemberType::Signal) => {
|
(Side::Server, MemberType::Signal) => {
|
||||||
@@ -355,9 +415,15 @@ fn generate_member(member: &Member) -> TokenStream {
|
|||||||
fn #name(#argument_decls) -> color_eyre::eyre::Result<()>;
|
fn #name(#argument_decls) -> color_eyre::eyre::Result<()>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(Side::Server, MemberType::Method) => {
|
||||||
|
quote! {
|
||||||
|
#[doc = #description]
|
||||||
|
fn #name(#argument_decls) -> impl std::future::Future<Output = color_eyre::eyre::Result<#return_type>> + Send + Sync + 'static;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn generate_handler(member: &Member) -> TokenStream {
|
fn generate_run_member(aspect_name: &Ident, _type: MemberType, member: &Member) -> TokenStream {
|
||||||
let opcode = member.opcode;
|
let opcode = member.opcode;
|
||||||
let member_name_ident = Ident::new(&member.name, Span::call_site());
|
let member_name_ident = Ident::new(&member.name, Span::call_site());
|
||||||
|
|
||||||
@@ -379,7 +445,10 @@ fn generate_handler(member: &Member) -> TokenStream {
|
|||||||
.clone()
|
.clone()
|
||||||
.zip(argument_types)
|
.zip(argument_types)
|
||||||
.map(|(argument_names, argument_types)| {
|
.map(|(argument_names, argument_types)| {
|
||||||
quote!(let (#argument_names): (#argument_types) = stardust_xr::schemas::flex::deserialize(_message.as_ref())?;)
|
quote!{
|
||||||
|
#[allow(unused_parens)]
|
||||||
|
let (#argument_names): (#argument_types) = stardust_xr::schemas::flex::deserialize(_message.as_ref())?;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let serialize = generate_argument_serialize(
|
let serialize = generate_argument_serialize(
|
||||||
@@ -393,21 +462,19 @@ fn generate_handler(member: &Member) -> TokenStream {
|
|||||||
.map(|a| generate_argument_deserialize(&a.name, &a._type, a.optional))
|
.map(|a| generate_argument_deserialize(&a.name, &a._type, a.optional))
|
||||||
.reduce(|a, b| quote!(#a, #b))
|
.reduce(|a, b| quote!(#a, #b))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
match member._type {
|
match _type {
|
||||||
MemberType::Signal => quote! {
|
MemberType::Signal => quote! {
|
||||||
node.add_local_signal(#opcode, |_node, _calling_client, _message| {
|
#opcode => (move || {
|
||||||
#deserialize
|
#deserialize
|
||||||
Self::#member_name_ident(_node, _calling_client.clone(), #argument_uses)
|
<Self as #aspect_name>::#member_name_ident(_node, _calling_client.clone(), #argument_uses)
|
||||||
});
|
})().map_err(|e: color_eyre::Report| stardust_xr::scenegraph::ScenegraphError::MemberError { error: e.to_string() }),
|
||||||
},
|
},
|
||||||
MemberType::Method => quote! {
|
MemberType::Method => quote! {
|
||||||
node.add_local_method(#opcode, |_node, _calling_client, _message, _method_response| {
|
#opcode => _method_response.wrap_async(async move {
|
||||||
_method_response.wrap_async(async move {
|
#deserialize
|
||||||
#deserialize
|
let result = <Self as #aspect_name>::#member_name_ident(_node, _calling_client.clone(), #argument_uses).await?;
|
||||||
let result = Self::#member_name_ident(_node, _calling_client.clone(), #argument_uses).await?;
|
Ok((#serialize, Vec::<std::os::fd::OwnedFd>::new()))
|
||||||
Ok((#serialize, Vec::new()))
|
}),
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
justfile
Normal file
12
justfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
PREFIX := "usr"
|
||||||
|
BINARY := PREFIX / "bin"
|
||||||
|
DESTDIR := "/"
|
||||||
|
|
||||||
|
build:
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
test:
|
||||||
|
cargo test
|
||||||
|
|
||||||
|
install:
|
||||||
|
install -Dm755 target/release/stardust-xr-server {{ DESTDIR }}{{ BINARY }}/stardust-xr-server
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#[macro_export]
|
|
||||||
macro_rules! create_interface {
|
|
||||||
($iface:ident) => {
|
|
||||||
pub fn create_interface(client: &Arc<Client>) -> Result<()> {
|
|
||||||
let node = Node::from_id(client, INTERFACE_NODE_ID, false);
|
|
||||||
<$iface as self::InterfaceAspect>::add_node_members(&node);
|
|
||||||
node.add_to_scenegraph()?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ pub mod client;
|
|||||||
pub mod client_state;
|
pub mod client_state;
|
||||||
pub mod delta;
|
pub mod delta;
|
||||||
pub mod destroy_queue;
|
pub mod destroy_queue;
|
||||||
pub mod idl_utils;
|
|
||||||
pub mod registry;
|
pub mod registry;
|
||||||
pub mod resource;
|
pub mod resource;
|
||||||
pub mod scenegraph;
|
pub mod scenegraph;
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ impl MethodResponseSender {
|
|||||||
// let _ = self.0.send(map_method_return(result));
|
// let _ = self.0.send(map_method_return(result));
|
||||||
// }
|
// }
|
||||||
pub fn wrap_sync<F: FnOnce() -> color_eyre::eyre::Result<Message>>(self, f: F) {
|
pub fn wrap_sync<F: FnOnce() -> color_eyre::eyre::Result<Message>>(self, f: F) {
|
||||||
self.send(f().map_err(|e| ScenegraphError::MethodError {
|
self.send(f().map_err(|e| ScenegraphError::MemberError {
|
||||||
error: e.to_string(),
|
error: e.to_string(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -74,11 +74,11 @@ impl MethodResponseSender {
|
|||||||
fn map_method_return<T: Serialize>(
|
fn map_method_return<T: Serialize>(
|
||||||
result: color_eyre::eyre::Result<(T, Vec<OwnedFd>)>,
|
result: color_eyre::eyre::Result<(T, Vec<OwnedFd>)>,
|
||||||
) -> Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError> {
|
) -> Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError> {
|
||||||
let (value, fds) = result.map_err(|e| ScenegraphError::MethodError {
|
let (value, fds) = result.map_err(|e| ScenegraphError::MemberError {
|
||||||
error: e.to_string(),
|
error: e.to_string(),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let serialized_value = serialize(value).map_err(|e| ScenegraphError::MethodError {
|
let serialized_value = serialize(value).map_err(|e| ScenegraphError::MemberError {
|
||||||
error: format!("Internal: Serialization failed: {e}"),
|
error: format!("Internal: Serialization failed: {e}"),
|
||||||
})?;
|
})?;
|
||||||
Ok((serialized_value, fds))
|
Ok((serialized_value, fds))
|
||||||
@@ -86,19 +86,21 @@ fn map_method_return<T: Serialize>(
|
|||||||
impl scenegraph::Scenegraph for Scenegraph {
|
impl scenegraph::Scenegraph for Scenegraph {
|
||||||
fn send_signal(
|
fn send_signal(
|
||||||
&self,
|
&self,
|
||||||
node: u64,
|
node_id: u64,
|
||||||
|
aspect_id: u64,
|
||||||
method: u64,
|
method: u64,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
fds: Vec<OwnedFd>,
|
fds: Vec<OwnedFd>,
|
||||||
) -> Result<(), ScenegraphError> {
|
) -> Result<(), ScenegraphError> {
|
||||||
let Some(client) = self.get_client() else {
|
let Some(client) = self.get_client() else {
|
||||||
return Err(ScenegraphError::SignalNotFound);
|
return Err(ScenegraphError::NodeNotFound);
|
||||||
};
|
};
|
||||||
debug_span!("Handle signal", node, method).in_scope(|| {
|
debug_span!("Handle signal", aspect_id, node_id, method).in_scope(|| {
|
||||||
self.get_node(node)
|
self.get_node(node_id)
|
||||||
.ok_or(ScenegraphError::NodeNotFound)?
|
.ok_or(ScenegraphError::NodeNotFound)?
|
||||||
.send_local_signal(
|
.send_local_signal(
|
||||||
client,
|
client,
|
||||||
|
aspect_id,
|
||||||
method,
|
method,
|
||||||
Message {
|
Message {
|
||||||
data: data.to_vec(),
|
data: data.to_vec(),
|
||||||
@@ -109,23 +111,25 @@ impl scenegraph::Scenegraph for Scenegraph {
|
|||||||
}
|
}
|
||||||
fn execute_method(
|
fn execute_method(
|
||||||
&self,
|
&self,
|
||||||
node: u64,
|
node_id: u64,
|
||||||
|
aspect_id: u64,
|
||||||
method: u64,
|
method: u64,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
fds: Vec<OwnedFd>,
|
fds: Vec<OwnedFd>,
|
||||||
response: oneshot::Sender<Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError>>,
|
response: oneshot::Sender<Result<(Vec<u8>, Vec<OwnedFd>), ScenegraphError>>,
|
||||||
) {
|
) {
|
||||||
let Some(client) = self.get_client() else {
|
let Some(client) = self.get_client() else {
|
||||||
let _ = response.send(Err(ScenegraphError::MethodNotFound));
|
let _ = response.send(Err(ScenegraphError::NodeNotFound));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
debug!(node, method, "Handle method");
|
debug!(aspect_id, node_id, method, "Handle method");
|
||||||
let Some(node) = self.get_node(node) else {
|
let Some(node) = self.get_node(node_id) else {
|
||||||
let _ = response.send(Err(ScenegraphError::NodeNotFound));
|
let _ = response.send(Err(ScenegraphError::NodeNotFound));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
node.execute_local_method(
|
node.execute_local_method(
|
||||||
client,
|
client,
|
||||||
|
aspect_id,
|
||||||
method,
|
method,
|
||||||
Message {
|
Message {
|
||||||
data: data.to_vec(),
|
data: data.to_vec(),
|
||||||
|
|||||||
20
src/main.rs
20
src/main.rs
@@ -23,8 +23,10 @@ use std::sync::Arc;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use stereokit_rust::material::Material;
|
use stereokit_rust::material::Material;
|
||||||
use stereokit_rust::shader::Shader;
|
use stereokit_rust::shader::Shader;
|
||||||
use stereokit_rust::sk::{sk_quit, AppMode, DepthMode, OriginMode, QuitReason, SkSettings};
|
use stereokit_rust::sk::{
|
||||||
use stereokit_rust::system::{LogLevel, Renderer};
|
sk_quit, AppMode, DepthMode, DisplayBlend, OriginMode, QuitReason, SkSettings,
|
||||||
|
};
|
||||||
|
use stereokit_rust::system::{Handed, Input, LogLevel, Renderer};
|
||||||
use stereokit_rust::tex::{SHCubemap, Tex, TexFormat, TexType};
|
use stereokit_rust::tex::{SHCubemap, Tex, TexFormat, TexType};
|
||||||
use stereokit_rust::ui::Ui;
|
use stereokit_rust::ui::Ui;
|
||||||
use stereokit_rust::util::{Color128, Time};
|
use stereokit_rust::util::{Color128, Time};
|
||||||
@@ -174,6 +176,7 @@ fn stereokit_loop(
|
|||||||
) {
|
) {
|
||||||
let sk = SkSettings::default()
|
let sk = SkSettings::default()
|
||||||
.app_name("Stardust XR")
|
.app_name("Stardust XR")
|
||||||
|
.blend_preference(DisplayBlend::AnyTransparent)
|
||||||
.mode(if args.flatscreen {
|
.mode(if args.flatscreen {
|
||||||
AppMode::Simulator
|
AppMode::Simulator
|
||||||
} else {
|
} else {
|
||||||
@@ -201,13 +204,21 @@ fn stereokit_loop(
|
|||||||
Material::default().shader(Shader::pbr_clip());
|
Material::default().shader(Shader::pbr_clip());
|
||||||
Ui::enable_far_interact(false);
|
Ui::enable_far_interact(false);
|
||||||
|
|
||||||
|
let left_hand_material = Material::find("default/material_hand").unwrap();
|
||||||
|
let mut right_hand_material = left_hand_material.copy();
|
||||||
|
right_hand_material.id("right_hand");
|
||||||
|
Input::hand_material(Handed::Right, Some(Material::find("right_hand").unwrap()));
|
||||||
|
|
||||||
|
Input::hand_visible(Handed::Left, false);
|
||||||
|
Input::hand_visible(Handed::Right, false);
|
||||||
|
|
||||||
// Skytex/light stuff
|
// Skytex/light stuff
|
||||||
{
|
{
|
||||||
if let Some(sky) = project_dirs
|
if let Some(sky) = project_dirs
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|dirs| dirs.config_dir().join("skytex.hdr"))
|
.map(|dirs| dirs.config_dir().join("skytex.hdr"))
|
||||||
.filter(|f| f.exists())
|
.filter(|f| f.exists())
|
||||||
.and_then(|p| SHCubemap::from_cubemap_equirectangular(p, true, 100).ok())
|
.and_then(|p| SHCubemap::from_cubemap(p, true, 100).ok())
|
||||||
{
|
{
|
||||||
sky.render_as_sky();
|
sky.render_as_sky();
|
||||||
} else {
|
} else {
|
||||||
@@ -231,6 +242,7 @@ fn stereokit_loop(
|
|||||||
let mut objects = ServerObjects::new(
|
let mut objects = ServerObjects::new(
|
||||||
dbus_connection.clone(),
|
dbus_connection.clone(),
|
||||||
&sk,
|
&sk,
|
||||||
|
[left_hand_material, right_hand_material],
|
||||||
args.disable_controllers,
|
args.disable_controllers,
|
||||||
args.disable_hands,
|
args.disable_hands,
|
||||||
);
|
);
|
||||||
@@ -262,8 +274,6 @@ fn stereokit_loop(
|
|||||||
}
|
}
|
||||||
|
|
||||||
info!("Cleanly shut down StereoKit");
|
info!("Cleanly shut down StereoKit");
|
||||||
#[cfg(feature = "wayland")]
|
|
||||||
drop(wayland);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn adaptive_sleep(
|
fn adaptive_sleep(
|
||||||
|
|||||||
@@ -69,7 +69,30 @@ impl Alias {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Alias {
|
impl Aspect for Alias {
|
||||||
const NAME: &'static str = "Alias";
|
fn id(&self) -> u64 {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
fn as_any(self: Arc<Self>) -> Arc<dyn std::any::Any + Send + Sync + 'static> {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
fn run_signal(
|
||||||
|
&self,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
_node: Arc<Node>,
|
||||||
|
_signal: u64,
|
||||||
|
_message: super::Message,
|
||||||
|
) -> Result<(), stardust_xr::scenegraph::ScenegraphError> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn run_method(
|
||||||
|
&self,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
_node: Arc<Node>,
|
||||||
|
_method: u64,
|
||||||
|
_message: super::Message,
|
||||||
|
_response: crate::core::scenegraph::MethodResponseSender,
|
||||||
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_original(node: Arc<Node>, stop_on_disabled: bool) -> Option<Arc<Node>> {
|
pub fn get_original(node: Arc<Node>, stop_on_disabled: bool) -> Option<Arc<Node>> {
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ use crate::core::client::Client;
|
|||||||
use crate::core::destroy_queue;
|
use crate::core::destroy_queue;
|
||||||
use crate::core::registry::Registry;
|
use crate::core::registry::Registry;
|
||||||
use crate::core::resource::get_resource_file;
|
use crate::core::resource::get_resource_file;
|
||||||
use crate::create_interface;
|
use crate::nodes::spatial::{Spatial, Transform, SPATIAL_ASPECT_ALIAS_INFO};
|
||||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
|
||||||
use crate::nodes::spatial::{Spatial, Transform};
|
|
||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{eyre, Result};
|
||||||
use glam::{vec3, Vec4Swizzles};
|
use glam::{vec3, Vec4Swizzles};
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
@@ -49,7 +47,6 @@ impl Sound {
|
|||||||
};
|
};
|
||||||
let sound_arc = SOUND_REGISTRY.add(sound);
|
let sound_arc = SOUND_REGISTRY.add(sound);
|
||||||
node.add_aspect_raw(sound_arc.clone());
|
node.add_aspect_raw(sound_arc.clone());
|
||||||
<Sound as SoundAspect>::add_node_members(node);
|
|
||||||
Ok(sound_arc)
|
Ok(sound_arc)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +69,7 @@ impl Sound {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Sound {
|
impl Aspect for Sound {
|
||||||
const NAME: &'static str = "Sound";
|
impl_aspect_for_sound_aspect! {}
|
||||||
}
|
}
|
||||||
impl SoundAspect for Sound {
|
impl SoundAspect for Sound {
|
||||||
fn play(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
fn play(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
||||||
@@ -88,6 +85,9 @@ impl SoundAspect for Sound {
|
|||||||
}
|
}
|
||||||
impl Drop for Sound {
|
impl Drop for Sound {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
|
if let Some(instance) = self.instance.lock().take() {
|
||||||
|
instance.stop();
|
||||||
|
}
|
||||||
if let Some(sk_sound) = self.sk_sound.take() {
|
if let Some(sk_sound) = self.sk_sound.take() {
|
||||||
destroy_queue::add(sk_sound);
|
destroy_queue::add(sk_sound);
|
||||||
}
|
}
|
||||||
@@ -101,9 +101,7 @@ pub fn update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_interface!(AudioInterface);
|
impl InterfaceAspect for Interface {
|
||||||
struct AudioInterface;
|
|
||||||
impl InterfaceAspect for AudioInterface {
|
|
||||||
#[doc = "Create a sound node. WAV and MP3 are supported."]
|
#[doc = "Create a sound node. WAV and MP3 are supported."]
|
||||||
fn create_sound(
|
fn create_sound(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use super::spatial::{parse_transform, Spatial};
|
|||||||
use super::{Alias, Aspect, Node};
|
use super::{Alias, Aspect, Node};
|
||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
use crate::core::registry::Registry;
|
use crate::core::registry::Registry;
|
||||||
use crate::create_interface;
|
|
||||||
use crate::nodes::fields::FIELD_ALIAS_INFO;
|
use crate::nodes::fields::FIELD_ALIAS_INFO;
|
||||||
use crate::nodes::spatial::Transform;
|
use crate::nodes::spatial::Transform;
|
||||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
||||||
@@ -71,7 +70,6 @@ impl PulseSender {
|
|||||||
field_aliases: AliasList::default(),
|
field_aliases: AliasList::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// <PulseSender as PulseSenderAspect>::add_node_members(node);
|
|
||||||
let sender = PULSE_SENDER_REGISTRY.add(sender);
|
let sender = PULSE_SENDER_REGISTRY.add(sender);
|
||||||
node.add_aspect_raw(sender.clone());
|
node.add_aspect_raw(sender.clone());
|
||||||
for receiver in PULSE_RECEIVER_REGISTRY.get_valid_contents() {
|
for receiver in PULSE_RECEIVER_REGISTRY.get_valid_contents() {
|
||||||
@@ -134,7 +132,7 @@ impl PulseSender {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for PulseSender {
|
impl Aspect for PulseSender {
|
||||||
const NAME: &'static str = "PulseSender";
|
impl_aspect_for_pulse_sender_aspect! {}
|
||||||
}
|
}
|
||||||
impl PulseSenderAspect for PulseSender {}
|
impl PulseSenderAspect for PulseSender {}
|
||||||
impl Drop for PulseSender {
|
impl Drop for PulseSender {
|
||||||
@@ -161,7 +159,6 @@ impl PulseReceiver {
|
|||||||
};
|
};
|
||||||
let receiver = PULSE_RECEIVER_REGISTRY.add(receiver);
|
let receiver = PULSE_RECEIVER_REGISTRY.add(receiver);
|
||||||
|
|
||||||
<PulseReceiver as PulseReceiverAspect>::add_node_members(node);
|
|
||||||
node.add_aspect_raw(receiver.clone());
|
node.add_aspect_raw(receiver.clone());
|
||||||
for sender in PULSE_SENDER_REGISTRY.get_valid_contents() {
|
for sender in PULSE_SENDER_REGISTRY.get_valid_contents() {
|
||||||
sender.handle_new_receiver(&receiver);
|
sender.handle_new_receiver(&receiver);
|
||||||
@@ -170,7 +167,7 @@ impl PulseReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for PulseReceiver {
|
impl Aspect for PulseReceiver {
|
||||||
const NAME: &'static str = "PulseReceiver";
|
impl_aspect_for_pulse_receiver_aspect! {}
|
||||||
}
|
}
|
||||||
impl PulseReceiverAspect for PulseReceiver {
|
impl PulseReceiverAspect for PulseReceiver {
|
||||||
fn send_data(
|
fn send_data(
|
||||||
@@ -199,9 +196,7 @@ impl Drop for PulseReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_interface!(DataInterface);
|
impl InterfaceAspect for Interface {
|
||||||
struct DataInterface;
|
|
||||||
impl InterfaceAspect for DataInterface {
|
|
||||||
fn create_pulse_sender(
|
fn create_pulse_sender(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use super::{Line, LinesAspect};
|
use super::{Line, LinesAspect};
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{client::Client, registry::Registry},
|
core::{client::Client, registry::Registry},
|
||||||
nodes::{spatial::Spatial, Aspect, Node},
|
nodes::{spatial::Spatial, Node},
|
||||||
};
|
};
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use glam::Vec3;
|
use glam::Vec3;
|
||||||
@@ -40,7 +40,6 @@ impl Lines {
|
|||||||
space: node.get_aspect::<Spatial>()?.clone(),
|
space: node.get_aspect::<Spatial>()?.clone(),
|
||||||
data: Mutex::new(lines),
|
data: Mutex::new(lines),
|
||||||
});
|
});
|
||||||
<Lines as LinesAspect>::add_node_members(node);
|
|
||||||
node.add_aspect_raw(lines.clone());
|
node.add_aspect_raw(lines.clone());
|
||||||
|
|
||||||
Ok(lines)
|
Ok(lines)
|
||||||
@@ -83,9 +82,6 @@ impl Lines {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Lines {
|
|
||||||
const NAME: &'static str = "Lines";
|
|
||||||
}
|
|
||||||
impl LinesAspect for Lines {
|
impl LinesAspect for Lines {
|
||||||
fn set_lines(node: Arc<Node>, _calling_client: Arc<Client>, lines: Vec<Line>) -> Result<()> {
|
fn set_lines(node: Arc<Node>, _calling_client: Arc<Client>, lines: Vec<Line>) -> Result<()> {
|
||||||
let lines_aspect = node.get_aspect::<Lines>()?;
|
let lines_aspect = node.get_aspect::<Lines>()?;
|
||||||
|
|||||||
@@ -8,14 +8,12 @@ pub mod text;
|
|||||||
use self::{lines::Lines, model::Model, text::Text};
|
use self::{lines::Lines, model::Model, text::Text};
|
||||||
use super::{
|
use super::{
|
||||||
spatial::{Spatial, Transform},
|
spatial::{Spatial, Transform},
|
||||||
Node,
|
Aspect, Node,
|
||||||
};
|
};
|
||||||
|
use crate::core::{client::Client, resource::get_resource_file};
|
||||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
||||||
use crate::{
|
|
||||||
core::{client::Client, resource::get_resource_file},
|
|
||||||
create_interface,
|
|
||||||
};
|
|
||||||
use color_eyre::eyre::{self, Result};
|
use color_eyre::eyre::{self, Result};
|
||||||
|
use model::ModelPart;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use stardust_xr::values::ResourceID;
|
use stardust_xr::values::ResourceID;
|
||||||
use std::{ffi::OsStr, path::PathBuf, sync::Arc};
|
use std::{ffi::OsStr, path::PathBuf, sync::Arc};
|
||||||
@@ -28,12 +26,12 @@ pub fn draw(token: &MainThreadToken) {
|
|||||||
text::draw_all(token);
|
text::draw_all(token);
|
||||||
|
|
||||||
if let Some(skytex) = QUEUED_SKYTEX.lock().take() {
|
if let Some(skytex) = QUEUED_SKYTEX.lock().take() {
|
||||||
if let Ok(skytex) = SHCubemap::from_cubemap_equirectangular(skytex, true, 100) {
|
if let Ok(skytex) = SHCubemap::from_cubemap(skytex, true, 100) {
|
||||||
Renderer::skytex(skytex.tex);
|
Renderer::skytex(skytex.tex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(skylight) = QUEUED_SKYLIGHT.lock().take() {
|
if let Some(skylight) = QUEUED_SKYLIGHT.lock().take() {
|
||||||
if let Ok(skylight) = SHCubemap::from_cubemap_equirectangular(skylight, true, 100) {
|
if let Ok(skylight) = SHCubemap::from_cubemap(skylight, true, 100) {
|
||||||
Renderer::skylight(skylight.sh);
|
Renderer::skylight(skylight.sh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,10 +41,20 @@ static QUEUED_SKYLIGHT: Mutex<Option<PathBuf>> = Mutex::new(None);
|
|||||||
static QUEUED_SKYTEX: Mutex<Option<PathBuf>> = Mutex::new(None);
|
static QUEUED_SKYTEX: Mutex<Option<PathBuf>> = Mutex::new(None);
|
||||||
|
|
||||||
stardust_xr_server_codegen::codegen_drawable_protocol!();
|
stardust_xr_server_codegen::codegen_drawable_protocol!();
|
||||||
create_interface!(DrawableInterface);
|
impl Aspect for Lines {
|
||||||
|
impl_aspect_for_lines_aspect! {}
|
||||||
|
}
|
||||||
|
impl Aspect for Model {
|
||||||
|
impl_aspect_for_model_aspect! {}
|
||||||
|
}
|
||||||
|
impl Aspect for ModelPart {
|
||||||
|
impl_aspect_for_model_part_aspect! {}
|
||||||
|
}
|
||||||
|
impl Aspect for Text {
|
||||||
|
impl_aspect_for_text_aspect! {}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct DrawableInterface;
|
impl InterfaceAspect for Interface {
|
||||||
impl InterfaceAspect for DrawableInterface {
|
|
||||||
fn set_sky_tex(_node: Arc<Node>, calling_client: Arc<Client>, tex: ResourceID) -> Result<()> {
|
fn set_sky_tex(_node: Arc<Node>, calling_client: Arc<Client>, tex: ResourceID) -> Result<()> {
|
||||||
let resource_path = get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
|
let resource_path = get_resource_file(&tex, &calling_client, &[OsStr::new("hdr")])
|
||||||
.ok_or(eyre::eyre!("Could not find resource"))?;
|
.ok_or(eyre::eyre!("Could not find resource"))?;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::core::registry::Registry;
|
|||||||
use crate::core::resource::get_resource_file;
|
use crate::core::resource::get_resource_file;
|
||||||
use crate::nodes::alias::{Alias, AliasList};
|
use crate::nodes::alias::{Alias, AliasList};
|
||||||
use crate::nodes::spatial::Spatial;
|
use crate::nodes::spatial::Spatial;
|
||||||
use crate::nodes::{Aspect, Node};
|
use crate::nodes::Node;
|
||||||
use color_eyre::eyre::{bail, eyre, Result};
|
use color_eyre::eyre::{bail, eyre, Result};
|
||||||
use glam::{Mat4, Vec2, Vec3};
|
use glam::{Mat4, Vec2, Vec3};
|
||||||
use once_cell::sync::{Lazy, OnceCell};
|
use once_cell::sync::{Lazy, OnceCell};
|
||||||
@@ -24,6 +24,7 @@ impl Hash for MaterialWrapper {
|
|||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
self.0.get_shader().0.as_ptr().hash(state);
|
self.0.get_shader().0.as_ptr().hash(state);
|
||||||
for param in self.0.get_all_param_info() {
|
for param in self.0.get_all_param_info() {
|
||||||
|
param.value.hash(state);
|
||||||
param.to_string().hash(state)
|
param.to_string().hash(state)
|
||||||
}
|
}
|
||||||
self.0.get_chain().map(MaterialWrapper).hash(state)
|
self.0.get_chain().map(MaterialWrapper).hash(state)
|
||||||
@@ -204,7 +205,6 @@ impl ModelPart {
|
|||||||
pending_material_replacement: Mutex::new(None),
|
pending_material_replacement: Mutex::new(None),
|
||||||
aliases: AliasList::default(),
|
aliases: AliasList::default(),
|
||||||
});
|
});
|
||||||
<ModelPart as ModelPartAspect>::add_node_members(&node);
|
|
||||||
node.add_aspect_raw(model_part.clone());
|
node.add_aspect_raw(model_part.clone());
|
||||||
parts.push(model_part.clone());
|
parts.push(model_part.clone());
|
||||||
Some(model_part)
|
Some(model_part)
|
||||||
@@ -278,9 +278,6 @@ impl ModelPart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for ModelPart {
|
|
||||||
const NAME: &'static str = "ModelPart";
|
|
||||||
}
|
|
||||||
impl ModelPartAspect for ModelPart {
|
impl ModelPartAspect for ModelPart {
|
||||||
#[doc = "Set this model part's material to one that cuts a hole in the world. Often used for overlays/passthrough where you want to show the background through an object."]
|
#[doc = "Set this model part's material to one that cuts a hole in the world. Often used for overlays/passthrough where you want to show the background through an object."]
|
||||||
fn apply_holdout_material(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
fn apply_holdout_material(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
||||||
@@ -327,7 +324,6 @@ impl Model {
|
|||||||
sk_model: OnceCell::new(),
|
sk_model: OnceCell::new(),
|
||||||
parts: Mutex::new(Vec::default()),
|
parts: Mutex::new(Vec::default()),
|
||||||
});
|
});
|
||||||
<Model as ModelAspect>::add_node_members(node);
|
|
||||||
MODEL_REGISTRY.add_raw(&model);
|
MODEL_REGISTRY.add_raw(&model);
|
||||||
|
|
||||||
// technically doing this in anything but the main thread isn't a good idea but dangit we need those model nodes ASAP
|
// technically doing this in anything but the main thread isn't a good idea but dangit we need those model nodes ASAP
|
||||||
@@ -361,9 +357,6 @@ impl Model {
|
|||||||
// TODO: proper hread safety in stereokit_rust (probably just bind stereokit directly)
|
// TODO: proper hread safety in stereokit_rust (probably just bind stereokit directly)
|
||||||
unsafe impl Send for Model {}
|
unsafe impl Send for Model {}
|
||||||
unsafe impl Sync for Model {}
|
unsafe impl Sync for Model {}
|
||||||
impl Aspect for Model {
|
|
||||||
const NAME: &'static str = "Model";
|
|
||||||
}
|
|
||||||
impl ModelAspect for Model {
|
impl ModelAspect for Model {
|
||||||
#[doc = "Bind a model part to the node with the ID input."]
|
#[doc = "Bind a model part to the node with the ID input."]
|
||||||
fn bind_model_part(
|
fn bind_model_part(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
core::{client::Client, destroy_queue, registry::Registry, resource::get_resource_file},
|
core::{client::Client, destroy_queue, registry::Registry, resource::get_resource_file},
|
||||||
nodes::{spatial::Spatial, Aspect, Node},
|
nodes::{spatial::Spatial, Node},
|
||||||
};
|
};
|
||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{eyre, Result};
|
||||||
use glam::{vec3, Mat4, Vec2};
|
use glam::{vec3, Mat4, Vec2};
|
||||||
@@ -53,7 +53,6 @@ impl Text {
|
|||||||
text: Mutex::new(text),
|
text: Mutex::new(text),
|
||||||
data: Mutex::new(style),
|
data: Mutex::new(style),
|
||||||
});
|
});
|
||||||
<Text as TextAspect>::add_node_members(node);
|
|
||||||
node.add_aspect_raw(text.clone());
|
node.add_aspect_raw(text.clone());
|
||||||
|
|
||||||
Ok(text)
|
Ok(text)
|
||||||
@@ -132,9 +131,6 @@ impl Text {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Text {
|
|
||||||
const NAME: &'static str = "Text";
|
|
||||||
}
|
|
||||||
impl TextAspect for Text {
|
impl TextAspect for Text {
|
||||||
fn set_character_height(
|
fn set_character_height(
|
||||||
node: Arc<Node>,
|
node: Arc<Node>,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use super::spatial::{
|
|||||||
};
|
};
|
||||||
use super::{Aspect, Node};
|
use super::{Aspect, Node};
|
||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
use crate::create_interface;
|
|
||||||
use crate::nodes::spatial::Transform;
|
use crate::nodes::spatial::Transform;
|
||||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
||||||
use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO;
|
||||||
@@ -145,15 +144,59 @@ impl Field {
|
|||||||
shape: Mutex::new(shape),
|
shape: Mutex::new(shape),
|
||||||
};
|
};
|
||||||
let field = node.add_aspect(field);
|
let field = node.add_aspect(field);
|
||||||
<Field as FieldRefAspect>::add_node_members(node);
|
node.add_aspect(FieldRef);
|
||||||
<Field as FieldAspect>::add_node_members(node);
|
|
||||||
Ok(field)
|
Ok(field)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Field {
|
impl Aspect for Field {
|
||||||
const NAME: &'static str = "Field";
|
impl_aspect_for_field_aspect! {}
|
||||||
}
|
}
|
||||||
impl FieldRefAspect for Field {
|
impl FieldAspect for Field {
|
||||||
|
fn set_shape(node: Arc<Node>, _calling_client: Arc<Client>, shape: Shape) -> Result<()> {
|
||||||
|
let field = node.get_aspect::<Field>()?;
|
||||||
|
*field.shape.lock() = shape;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn export_field(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<u64> {
|
||||||
|
let id = rand::random();
|
||||||
|
EXPORTED_FIELDS.lock().insert(id, node);
|
||||||
|
Ok(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl FieldTrait for Field {
|
||||||
|
fn spatial_ref(&self) -> &Spatial {
|
||||||
|
&self.spatial
|
||||||
|
}
|
||||||
|
fn local_distance(&self, p: Vec3A) -> f32 {
|
||||||
|
match self.shape.lock().clone() {
|
||||||
|
Shape::Box(size) => {
|
||||||
|
let q = vec3(
|
||||||
|
p.x.abs() - (size.x * 0.5_f32),
|
||||||
|
p.y.abs() - (size.y * 0.5_f32),
|
||||||
|
p.z.abs() - (size.z * 0.5_f32),
|
||||||
|
);
|
||||||
|
let v = vec3a(q.x.max(0_f32), q.y.max(0_f32), q.z.max(0_f32));
|
||||||
|
v.length() + q.x.max(q.y.max(q.z)).min(0_f32)
|
||||||
|
}
|
||||||
|
Shape::Cylinder(CylinderShape { length, radius }) => {
|
||||||
|
let d = vec2(p.xy().length().abs() - radius, p.z.abs() - (length * 0.5));
|
||||||
|
d.x.max(d.y).min(0.0) + d.max(vec2(0.0, 0.0)).length()
|
||||||
|
}
|
||||||
|
Shape::Sphere(radius) => p.length() - radius,
|
||||||
|
Shape::Torus(TorusShape { radius_a, radius_b }) => {
|
||||||
|
let q = vec2(p.xz().length() - radius_a, p.y);
|
||||||
|
q.length() - radius_b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct FieldRef;
|
||||||
|
impl Aspect for FieldRef {
|
||||||
|
impl_aspect_for_field_ref_aspect! {}
|
||||||
|
}
|
||||||
|
impl FieldRefAspect for FieldRef {
|
||||||
async fn distance(
|
async fn distance(
|
||||||
node: Arc<Node>,
|
node: Arc<Node>,
|
||||||
_calling_client: Arc<Client>,
|
_calling_client: Arc<Client>,
|
||||||
@@ -205,50 +248,8 @@ impl FieldRefAspect for Field {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl FieldAspect for Field {
|
|
||||||
fn set_shape(node: Arc<Node>, _calling_client: Arc<Client>, shape: Shape) -> Result<()> {
|
|
||||||
let field = node.get_aspect::<Field>()?;
|
|
||||||
*field.shape.lock() = shape;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn export_field(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<u64> {
|
impl InterfaceAspect for Interface {
|
||||||
let id = rand::random();
|
|
||||||
EXPORTED_FIELDS.lock().insert(id, node);
|
|
||||||
Ok(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl FieldTrait for Field {
|
|
||||||
fn spatial_ref(&self) -> &Spatial {
|
|
||||||
&self.spatial
|
|
||||||
}
|
|
||||||
fn local_distance(&self, p: Vec3A) -> f32 {
|
|
||||||
match self.shape.lock().clone() {
|
|
||||||
Shape::Box(size) => {
|
|
||||||
let q = vec3(
|
|
||||||
p.x.abs() - (size.x * 0.5_f32),
|
|
||||||
p.y.abs() - (size.y * 0.5_f32),
|
|
||||||
p.z.abs() - (size.z * 0.5_f32),
|
|
||||||
);
|
|
||||||
let v = vec3a(q.x.max(0_f32), q.y.max(0_f32), q.z.max(0_f32));
|
|
||||||
v.length() + q.x.max(q.y.max(q.z)).min(0_f32)
|
|
||||||
}
|
|
||||||
Shape::Cylinder(CylinderShape { length, radius }) => {
|
|
||||||
let d = vec2(p.xy().length().abs() - radius, p.z.abs() - (length * 0.5));
|
|
||||||
d.x.max(d.y).min(0.0) + d.max(vec2(0.0, 0.0)).length()
|
|
||||||
}
|
|
||||||
Shape::Sphere(radius) => p.length() - radius,
|
|
||||||
Shape::Torus(TorusShape { radius_a, radius_b }) => {
|
|
||||||
let q = vec2(p.xz().length() - radius_a, p.y);
|
|
||||||
q.length() - radius_b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
create_interface!(FieldInterface);
|
|
||||||
pub struct FieldInterface;
|
|
||||||
impl InterfaceAspect for FieldInterface {
|
|
||||||
async fn import_field_ref(
|
async fn import_field_ref(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use super::{InputHandlerAspect, INPUT_HANDLER_REGISTRY, INPUT_METHOD_REGISTRY};
|
use super::{InputHandlerAspect, INPUT_HANDLER_REGISTRY, INPUT_METHOD_REGISTRY};
|
||||||
use crate::nodes::{alias::AliasList, fields::Field, spatial::Spatial, Aspect, Node};
|
use crate::nodes::{alias::AliasList, fields::Field, spatial::Spatial, Node};
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -23,9 +23,6 @@ impl InputHandler {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for InputHandler {
|
|
||||||
const NAME: &'static str = "InputHandler";
|
|
||||||
}
|
|
||||||
impl InputHandlerAspect for InputHandler {}
|
impl InputHandlerAspect for InputHandler {}
|
||||||
impl PartialEq for InputHandler {
|
impl PartialEq for InputHandler {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::{
|
|||||||
alias::{Alias, AliasList},
|
alias::{Alias, AliasList},
|
||||||
fields::{Field, FIELD_ALIAS_INFO},
|
fields::{Field, FIELD_ALIAS_INFO},
|
||||||
spatial::Spatial,
|
spatial::Spatial,
|
||||||
Aspect, Node,
|
Node,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
@@ -45,13 +45,12 @@ impl InputMethod {
|
|||||||
internal_capture_requests: Registry::new(),
|
internal_capture_requests: Registry::new(),
|
||||||
captures: Registry::new(),
|
captures: Registry::new(),
|
||||||
};
|
};
|
||||||
<InputMethod as InputMethodRefAspect>::add_node_members(node);
|
|
||||||
<InputMethod as InputMethodAspect>::add_node_members(node);
|
|
||||||
for handler in INPUT_HANDLER_REGISTRY.get_valid_contents() {
|
for handler in INPUT_HANDLER_REGISTRY.get_valid_contents() {
|
||||||
method.handle_new_handler(&handler);
|
method.handle_new_handler(&handler);
|
||||||
}
|
}
|
||||||
let method = INPUT_METHOD_REGISTRY.add(method);
|
let method = INPUT_METHOD_REGISTRY.add(method);
|
||||||
node.add_aspect_raw(method.clone());
|
node.add_aspect_raw(method.clone());
|
||||||
|
node.add_aspect(InputMethodRef);
|
||||||
Ok(method)
|
Ok(method)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,25 +153,6 @@ impl InputMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for InputMethod {
|
|
||||||
const NAME: &'static str = "InputMethod";
|
|
||||||
}
|
|
||||||
impl InputMethodRefAspect for InputMethod {
|
|
||||||
#[doc = "Have the input handler that this method reference came from capture the method for the next frame."]
|
|
||||||
fn request_capture(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
handler: Arc<Node>,
|
|
||||||
) -> Result<()> {
|
|
||||||
let input_method = node.get_aspect::<InputMethod>()?;
|
|
||||||
let input_handler = handler.get_aspect::<InputHandler>()?;
|
|
||||||
|
|
||||||
input_method
|
|
||||||
.internal_capture_requests
|
|
||||||
.add_raw(&input_handler);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl InputMethodAspect for InputMethod {
|
impl InputMethodAspect for InputMethod {
|
||||||
#[doc = "Set the spatial input component of this input method. You must keep the same input data type throughout the entire thing."]
|
#[doc = "Set the spatial input component of this input method. You must keep the same input data type throughout the entire thing."]
|
||||||
fn set_input(
|
fn set_input(
|
||||||
@@ -231,3 +211,21 @@ impl Drop for InputMethod {
|
|||||||
INPUT_METHOD_REGISTRY.remove(self);
|
INPUT_METHOD_REGISTRY.remove(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct InputMethodRef;
|
||||||
|
impl InputMethodRefAspect for InputMethodRef {
|
||||||
|
#[doc = "Have the input handler that this method reference came from capture the method for the next frame."]
|
||||||
|
fn request_capture(
|
||||||
|
node: Arc<Node>,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
handler: Arc<Node>,
|
||||||
|
) -> Result<()> {
|
||||||
|
let input_method = node.get_aspect::<InputMethod>()?;
|
||||||
|
let input_handler = handler.get_aspect::<InputHandler>()?;
|
||||||
|
|
||||||
|
input_method
|
||||||
|
.internal_capture_requests
|
||||||
|
.add_raw(&input_handler);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub use method::*;
|
|||||||
|
|
||||||
use super::fields::Field;
|
use super::fields::Field;
|
||||||
use super::spatial::Spatial;
|
use super::spatial::Spatial;
|
||||||
use crate::create_interface;
|
use super::Aspect;
|
||||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
||||||
use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO;
|
||||||
use crate::{core::client::Client, nodes::Node};
|
use crate::{core::client::Client, nodes::Node};
|
||||||
@@ -25,6 +25,16 @@ pub static INPUT_HANDLER_REGISTRY: Registry<InputHandler> = Registry::new();
|
|||||||
|
|
||||||
stardust_xr_server_codegen::codegen_input_protocol!();
|
stardust_xr_server_codegen::codegen_input_protocol!();
|
||||||
|
|
||||||
|
impl Aspect for InputHandler {
|
||||||
|
impl_aspect_for_input_handler_aspect! {}
|
||||||
|
}
|
||||||
|
impl Aspect for InputMethod {
|
||||||
|
impl_aspect_for_input_method_aspect! {}
|
||||||
|
}
|
||||||
|
impl Aspect for InputMethodRef {
|
||||||
|
impl_aspect_for_input_method_ref_aspect! {}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait InputDataTrait {
|
pub trait InputDataTrait {
|
||||||
fn transform(&mut self, method: &InputMethod, handler: &InputHandler);
|
fn transform(&mut self, method: &InputMethod, handler: &InputHandler);
|
||||||
fn distance(&self, space: &Arc<Spatial>, field: &Field) -> f32;
|
fn distance(&self, space: &Arc<Spatial>, field: &Field) -> f32;
|
||||||
@@ -47,9 +57,7 @@ impl InputDataTrait for InputDataType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_interface!(InputInterface);
|
impl InterfaceAspect for Interface {
|
||||||
pub struct InputInterface;
|
|
||||||
impl InterfaceAspect for InputInterface {
|
|
||||||
#[doc = "Create an input method node"]
|
#[doc = "Create an input method node"]
|
||||||
fn create_input_method(
|
fn create_input_method(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use super::{
|
use super::{create_item_acceptor_flex, register_item_ui_flex, Item, ItemType};
|
||||||
create_item_acceptor_flex, register_item_ui_flex, Item, ItemAcceptor, ItemInterface, ItemType,
|
|
||||||
};
|
|
||||||
use crate::nodes::items::ITEM_ACCEPTOR_ASPECT_ALIAS_INFO;
|
use crate::nodes::items::ITEM_ACCEPTOR_ASPECT_ALIAS_INFO;
|
||||||
use crate::nodes::items::ITEM_ASPECT_ALIAS_INFO;
|
use crate::nodes::items::ITEM_ASPECT_ALIAS_INFO;
|
||||||
|
use crate::nodes::Aspect;
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{client::Client, registry::Registry, scenegraph::MethodResponseSender},
|
core::{client::Client, registry::Registry, scenegraph::MethodResponseSender},
|
||||||
create_interface,
|
|
||||||
nodes::{
|
nodes::{
|
||||||
drawable::{
|
drawable::{
|
||||||
model::{MaterialWrapper, ModelPart},
|
model::{MaterialWrapper, ModelPart},
|
||||||
@@ -48,6 +46,12 @@ lazy_static! {
|
|||||||
ui: Default::default(),
|
ui: Default::default(),
|
||||||
items: Registry::new(),
|
items: Registry::new(),
|
||||||
acceptors: Registry::new(),
|
acceptors: Registry::new(),
|
||||||
|
add_acceptor_aspect: |node| {
|
||||||
|
node.add_aspect(CameraItemAcceptor);
|
||||||
|
},
|
||||||
|
add_ui_aspect: |node| {
|
||||||
|
node.add_aspect(CameraItemUi);
|
||||||
|
},
|
||||||
new_acceptor_fn: |node, acceptor, acceptor_field| {
|
new_acceptor_fn: |node, acceptor, acceptor_field| {
|
||||||
let _ = camera_item_ui_client::create_acceptor(node, acceptor, acceptor_field);
|
let _ = camera_item_ui_client::create_acceptor(node, acceptor, acceptor_field);
|
||||||
}
|
}
|
||||||
@@ -70,22 +74,19 @@ pub struct CameraItem {
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
impl CameraItem {
|
impl CameraItem {
|
||||||
pub fn add_to(node: &Arc<Node>, proj_matrix: Mat4, px_size: Vector2<u32>) {
|
pub fn add_to(node: &Arc<Node>, proj_matrix: Mat4, px_size: Vector2<u32>) {
|
||||||
Item::add_to(
|
let item = Arc::new(CameraItem {
|
||||||
node,
|
space: node.get_aspect::<Spatial>().unwrap().clone(),
|
||||||
&ITEM_TYPE_INFO_CAMERA,
|
frame_info: Mutex::new(FrameInfo {
|
||||||
ItemType::Camera(CameraItem {
|
proj_matrix,
|
||||||
space: node.get_aspect::<Spatial>().unwrap().clone(),
|
px_size,
|
||||||
frame_info: Mutex::new(FrameInfo {
|
|
||||||
proj_matrix,
|
|
||||||
px_size,
|
|
||||||
}),
|
|
||||||
sk_tex: OnceCell::new(),
|
|
||||||
sk_mat: OnceCell::new(),
|
|
||||||
applied_to: Registry::new(),
|
|
||||||
apply_to: Registry::new(),
|
|
||||||
}),
|
}),
|
||||||
);
|
sk_tex: OnceCell::new(),
|
||||||
// <CameraItem as CameraItemAspect>::node_methods(node);
|
sk_mat: OnceCell::new(),
|
||||||
|
applied_to: Registry::new(),
|
||||||
|
apply_to: Registry::new(),
|
||||||
|
});
|
||||||
|
Item::add_to(node, &ITEM_TYPE_INFO_CAMERA, ItemType::Camera(item.clone()));
|
||||||
|
node.add_aspect_raw(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame_flex(
|
fn frame_flex(
|
||||||
@@ -167,9 +168,22 @@ impl CameraItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Aspect for CameraItem {
|
||||||
|
impl_aspect_for_camera_item_aspect! {}
|
||||||
|
}
|
||||||
impl CameraItemAspect for CameraItem {}
|
impl CameraItemAspect for CameraItem {}
|
||||||
|
|
||||||
impl CameraItemAcceptorAspect for ItemAcceptor {
|
pub struct CameraItemUi;
|
||||||
|
impl Aspect for CameraItemUi {
|
||||||
|
impl_aspect_for_camera_item_ui_aspect! {}
|
||||||
|
}
|
||||||
|
impl CameraItemUiAspect for CameraItemUi {}
|
||||||
|
|
||||||
|
pub struct CameraItemAcceptor;
|
||||||
|
impl Aspect for CameraItemAcceptor {
|
||||||
|
impl_aspect_for_camera_item_acceptor_aspect! {}
|
||||||
|
}
|
||||||
|
impl CameraItemAcceptorAspect for CameraItemAcceptor {
|
||||||
fn capture_item(node: Arc<Node>, _calling_client: Arc<Client>, item: Arc<Node>) -> Result<()> {
|
fn capture_item(node: Arc<Node>, _calling_client: Arc<Client>, item: Arc<Node>) -> Result<()> {
|
||||||
super::acceptor_capture_item_flex(node, item)
|
super::acceptor_capture_item_flex(node, item)
|
||||||
}
|
}
|
||||||
@@ -184,8 +198,7 @@ pub fn update(token: &MainThreadToken) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_interface!(ItemInterface);
|
impl InterfaceAspect for Interface {
|
||||||
impl InterfaceAspect for ItemInterface {
|
|
||||||
#[doc = "Create a camera item at a specific location"]
|
#[doc = "Create a camera item at a specific location"]
|
||||||
fn create_camera_item(
|
fn create_camera_item(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
@@ -206,19 +219,21 @@ impl InterfaceAspect for ItemInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Register this client to manage camera items and create default 3D UI for them."]
|
#[doc = "Register this client to manage camera items and create default 3D UI for them."]
|
||||||
fn register_camera_item_ui(_node: Arc<Node>, calling_client: Arc<Client>) -> Result<()> {
|
fn register_camera_item_ui(node: Arc<Node>, calling_client: Arc<Client>) -> Result<()> {
|
||||||
|
node.add_aspect(CameraItemUi);
|
||||||
register_item_ui_flex(calling_client, &ITEM_TYPE_INFO_CAMERA)
|
register_item_ui_flex(calling_client, &ITEM_TYPE_INFO_CAMERA)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Create an item acceptor to allow temporary ownership of a given type of item. Creates a node at `/item/camera/acceptor/<name>`."]
|
#[doc = "Create an item acceptor to allow temporary ownership of a given type of item. Creates a node at `/item/camera/acceptor/<name>`."]
|
||||||
fn create_camera_item_acceptor(
|
fn create_camera_item_acceptor(
|
||||||
_node: Arc<Node>,
|
node: Arc<Node>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
id: u64,
|
id: u64,
|
||||||
parent: Arc<Node>,
|
parent: Arc<Node>,
|
||||||
transform: Transform,
|
transform: Transform,
|
||||||
field: Arc<Node>,
|
field: Arc<Node>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
node.add_aspect(CameraItemAcceptor);
|
||||||
create_item_acceptor_flex(
|
create_item_acceptor_flex(
|
||||||
calling_client,
|
calling_client,
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ pub struct TypeInfo {
|
|||||||
pub ui: Mutex<Weak<ItemUI>>,
|
pub ui: Mutex<Weak<ItemUI>>,
|
||||||
pub items: Registry<Item>,
|
pub items: Registry<Item>,
|
||||||
pub acceptors: Registry<ItemAcceptor>,
|
pub acceptors: Registry<ItemAcceptor>,
|
||||||
|
pub add_ui_aspect: fn(node: &Node),
|
||||||
|
pub add_acceptor_aspect: fn(node: &Node),
|
||||||
pub new_acceptor_fn: fn(node: &Node, acceptor: &Arc<Node>, acceptor_field: &Arc<Node>),
|
pub new_acceptor_fn: fn(node: &Node, acceptor: &Arc<Node>, acceptor_field: &Arc<Node>),
|
||||||
}
|
}
|
||||||
impl Hash for TypeInfo {
|
impl Hash for TypeInfo {
|
||||||
@@ -81,7 +83,6 @@ impl Item {
|
|||||||
};
|
};
|
||||||
let item = type_info.items.add(item);
|
let item = type_info.items.add(item);
|
||||||
|
|
||||||
<Item as ItemAspect>::add_node_members(node);
|
|
||||||
if let Some(ui) = type_info.ui.lock().upgrade() {
|
if let Some(ui) = type_info.ui.lock().upgrade() {
|
||||||
ui.handle_create_item(&item);
|
ui.handle_create_item(&item);
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,7 @@ impl Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Item {
|
impl Aspect for Item {
|
||||||
const NAME: &'static str = "Item";
|
impl_aspect_for_item_aspect! {}
|
||||||
}
|
}
|
||||||
impl ItemAspect for Item {
|
impl ItemAspect for Item {
|
||||||
fn release(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
fn release(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
||||||
@@ -129,7 +130,7 @@ impl Drop for Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub enum ItemType {
|
pub enum ItemType {
|
||||||
Camera(CameraItem),
|
Camera(Arc<CameraItem>),
|
||||||
Panel(Arc<dyn PanelItemTrait>),
|
Panel(Arc<dyn PanelItemTrait>),
|
||||||
}
|
}
|
||||||
impl ItemType {
|
impl ItemType {
|
||||||
@@ -285,7 +286,7 @@ impl ItemUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for ItemUI {
|
impl Aspect for ItemUI {
|
||||||
const NAME: &'static str = "Item";
|
impl_aspect_for_item_ui_aspect! {}
|
||||||
}
|
}
|
||||||
impl Drop for ItemUI {
|
impl Drop for ItemUI {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
@@ -343,7 +344,7 @@ impl ItemAcceptor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for ItemAcceptor {
|
impl Aspect for ItemAcceptor {
|
||||||
const NAME: &'static str = "ItemAcceptor";
|
impl_aspect_for_item_acceptor_aspect! {}
|
||||||
}
|
}
|
||||||
impl ItemAcceptorAspect for ItemAcceptor {}
|
impl ItemAcceptorAspect for ItemAcceptor {}
|
||||||
impl Drop for ItemAcceptor {
|
impl Drop for ItemAcceptor {
|
||||||
@@ -364,6 +365,7 @@ pub fn register_item_ui_flex(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let ui = Node::from_id(&calling_client, type_info.ui_node_id, true).add_to_scenegraph()?;
|
let ui = Node::from_id(&calling_client, type_info.ui_node_id, true).add_to_scenegraph()?;
|
||||||
ItemUI::add_to(&ui, type_info)?;
|
ItemUI::add_to(&ui, type_info)?;
|
||||||
|
(type_info.add_ui_aspect)(&ui);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn create_item_acceptor_flex(
|
fn create_item_acceptor_flex(
|
||||||
@@ -381,6 +383,7 @@ fn create_item_acceptor_flex(
|
|||||||
let node = Node::from_id(&calling_client, id, true).add_to_scenegraph()?;
|
let node = Node::from_id(&calling_client, id, true).add_to_scenegraph()?;
|
||||||
Spatial::add_to(&node, Some(space.clone()), transform, false);
|
Spatial::add_to(&node, Some(space.clone()), transform, false);
|
||||||
ItemAcceptor::add_to(&node, type_info, field);
|
ItemAcceptor::add_to(&node, type_info, field);
|
||||||
|
(type_info.add_acceptor_aspect)(&node);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,6 +394,3 @@ fn acceptor_capture_item_flex(node: Arc<Node>, item: Arc<Node>) -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ItemInterface;
|
|
||||||
// create_interface!(ItemInterface);
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
use super::{create_item_acceptor_flex, register_item_ui_flex, ItemAcceptor, ItemInterface};
|
use super::camera::CameraItemAcceptor;
|
||||||
|
use super::{create_item_acceptor_flex, register_item_ui_flex};
|
||||||
use crate::nodes::items::ITEM_ACCEPTOR_ASPECT_ALIAS_INFO;
|
use crate::nodes::items::ITEM_ACCEPTOR_ASPECT_ALIAS_INFO;
|
||||||
use crate::nodes::items::ITEM_ASPECT_ALIAS_INFO;
|
use crate::nodes::items::ITEM_ASPECT_ALIAS_INFO;
|
||||||
|
use crate::nodes::Aspect;
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{
|
core::{
|
||||||
client::{get_env, state, Client, INTERNAL_CLIENT},
|
client::{get_env, state, Client, INTERNAL_CLIENT},
|
||||||
registry::Registry,
|
registry::Registry,
|
||||||
},
|
},
|
||||||
create_interface,
|
|
||||||
nodes::{
|
nodes::{
|
||||||
drawable::model::ModelPart,
|
drawable::model::ModelPart,
|
||||||
items::{Item, ItemType, TypeInfo},
|
items::{Item, ItemType, TypeInfo},
|
||||||
@@ -39,6 +40,12 @@ lazy_static! {
|
|||||||
ui: Default::default(),
|
ui: Default::default(),
|
||||||
items: Registry::new(),
|
items: Registry::new(),
|
||||||
acceptors: Registry::new(),
|
acceptors: Registry::new(),
|
||||||
|
add_acceptor_aspect: |node| {
|
||||||
|
node.add_aspect(PanelItemUi);
|
||||||
|
},
|
||||||
|
add_ui_aspect: |node| {
|
||||||
|
node.add_aspect(PanelItemAcceptor);
|
||||||
|
},
|
||||||
new_acceptor_fn: |node, acceptor, acceptor_field| {
|
new_acceptor_fn: |node, acceptor, acceptor_field| {
|
||||||
let _ = panel_item_ui_client::create_acceptor(node, acceptor, acceptor_field);
|
let _ = panel_item_ui_client::create_acceptor(node, acceptor, acceptor_field);
|
||||||
}
|
}
|
||||||
@@ -115,7 +122,7 @@ impl<B: Backend> PanelItem<B> {
|
|||||||
&ITEM_TYPE_INFO_PANEL,
|
&ITEM_TYPE_INFO_PANEL,
|
||||||
ItemType::Panel(generic_panel_item),
|
ItemType::Panel(generic_panel_item),
|
||||||
);
|
);
|
||||||
<Self as PanelItemAspect>::add_node_members(&node);
|
node.add_aspect_raw(panel_item.clone());
|
||||||
|
|
||||||
(node, panel_item)
|
(node, panel_item)
|
||||||
}
|
}
|
||||||
@@ -198,8 +205,9 @@ impl<B: Backend> PanelItem<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make these stupid vectors u32 in the protocol somehow!!!!!!!1
|
impl<B: Backend> Aspect for PanelItem<B> {
|
||||||
|
impl_aspect_for_panel_item_aspect! {}
|
||||||
|
}
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
impl<B: Backend> PanelItemAspect for PanelItem<B> {
|
impl<B: Backend> PanelItemAspect for PanelItem<B> {
|
||||||
#[doc = "Apply the cursor as a material to a model."]
|
#[doc = "Apply the cursor as a material to a model."]
|
||||||
@@ -405,7 +413,17 @@ impl<B: Backend> PanelItemAspect for PanelItem<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PanelItemAcceptorAspect for ItemAcceptor {
|
pub struct PanelItemUi;
|
||||||
|
impl Aspect for PanelItemUi {
|
||||||
|
impl_aspect_for_panel_item_ui_aspect! {}
|
||||||
|
}
|
||||||
|
impl PanelItemUiAspect for PanelItemUi {}
|
||||||
|
|
||||||
|
pub struct PanelItemAcceptor;
|
||||||
|
impl Aspect for PanelItemAcceptor {
|
||||||
|
impl_aspect_for_panel_item_acceptor_aspect! {}
|
||||||
|
}
|
||||||
|
impl PanelItemAcceptorAspect for PanelItemAcceptor {
|
||||||
fn capture_item(node: Arc<Node>, _calling_client: Arc<Client>, item: Arc<Node>) -> Result<()> {
|
fn capture_item(node: Arc<Node>, _calling_client: Arc<Client>, item: Arc<Node>) -> Result<()> {
|
||||||
super::acceptor_capture_item_flex(node, item)
|
super::acceptor_capture_item_flex(node, item)
|
||||||
}
|
}
|
||||||
@@ -435,22 +453,23 @@ impl<B: Backend> Drop for PanelItem<B> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_interface!(ItemInterface);
|
impl InterfaceAspect for Interface {
|
||||||
impl InterfaceAspect for ItemInterface {
|
|
||||||
#[doc = "Register this client to manage the items of a certain type and create default 3D UI for them."]
|
#[doc = "Register this client to manage the items of a certain type and create default 3D UI for them."]
|
||||||
fn register_panel_item_ui(_node: Arc<Node>, calling_client: Arc<Client>) -> Result<()> {
|
fn register_panel_item_ui(node: Arc<Node>, calling_client: Arc<Client>) -> Result<()> {
|
||||||
|
node.add_aspect(CameraItemAcceptor);
|
||||||
register_item_ui_flex(calling_client, &ITEM_TYPE_INFO_PANEL)
|
register_item_ui_flex(calling_client, &ITEM_TYPE_INFO_PANEL)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "Create an item acceptor to allow temporary ownership of a given type of item. Creates a node at `/item/<item_type>/acceptor/<name>`."]
|
#[doc = "Create an item acceptor to allow temporary ownership of a given type of item. Creates a node at `/item/<item_type>/acceptor/<name>`."]
|
||||||
fn create_panel_item_acceptor(
|
fn create_panel_item_acceptor(
|
||||||
_node: Arc<Node>,
|
node: Arc<Node>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
id: u64,
|
id: u64,
|
||||||
parent: Arc<Node>,
|
parent: Arc<Node>,
|
||||||
transform: Transform,
|
transform: Transform,
|
||||||
field: Arc<Node>,
|
field: Arc<Node>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
node.add_aspect(PanelItemAcceptor);
|
||||||
create_item_acceptor_flex(
|
create_item_acceptor_flex(
|
||||||
calling_client,
|
calling_client,
|
||||||
id,
|
id,
|
||||||
|
|||||||
135
src/nodes/mod.rs
135
src/nodes/mod.rs
@@ -21,7 +21,7 @@ use spatial::Spatial;
|
|||||||
use stardust_xr::messenger::MessageSenderHandle;
|
use stardust_xr::messenger::MessageSenderHandle;
|
||||||
use stardust_xr::scenegraph::ScenegraphError;
|
use stardust_xr::scenegraph::ScenegraphError;
|
||||||
use stardust_xr::schemas::flex::{deserialize, serialize};
|
use stardust_xr::schemas::flex::{deserialize, serialize};
|
||||||
use std::any::{Any, TypeId};
|
use std::any::Any;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::os::fd::OwnedFd;
|
use std::os::fd::OwnedFd;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
@@ -46,11 +46,26 @@ impl AsRef<[u8]> for Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Signal = fn(Arc<Node>, Arc<Client>, Message) -> Result<()>;
|
|
||||||
pub type Method = fn(Arc<Node>, Arc<Client>, Message, MethodResponseSender);
|
|
||||||
|
|
||||||
stardust_xr_server_codegen::codegen_node_protocol!();
|
stardust_xr_server_codegen::codegen_node_protocol!();
|
||||||
|
|
||||||
|
pub struct Owned;
|
||||||
|
impl Aspect for Owned {
|
||||||
|
impl_aspect_for_owned_aspect! {}
|
||||||
|
}
|
||||||
|
impl OwnedAspect for Owned {
|
||||||
|
fn set_enabled(node: Arc<Node>, _calling_client: Arc<Client>, enabled: bool) -> Result<()> {
|
||||||
|
node.set_enabled(enabled);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn destroy(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
||||||
|
if node.destroyable {
|
||||||
|
node.destroy();
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct OwnedNode(pub Arc<Node>);
|
pub struct OwnedNode(pub Arc<Node>);
|
||||||
impl Drop for OwnedNode {
|
impl Drop for OwnedNode {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
@@ -64,8 +79,6 @@ pub struct Node {
|
|||||||
client: Weak<Client>,
|
client: Weak<Client>,
|
||||||
message_sender_handle: Option<MessageSenderHandle>,
|
message_sender_handle: Option<MessageSenderHandle>,
|
||||||
|
|
||||||
local_signals: Mutex<FxHashMap<u64, Signal>>,
|
|
||||||
local_methods: Mutex<FxHashMap<u64, Method>>,
|
|
||||||
aliases: Registry<Alias>,
|
aliases: Registry<Alias>,
|
||||||
aspects: Aspects,
|
aspects: Aspects,
|
||||||
destroyable: bool,
|
destroyable: bool,
|
||||||
@@ -87,13 +100,11 @@ impl Node {
|
|||||||
client: Arc::downgrade(client),
|
client: Arc::downgrade(client),
|
||||||
message_sender_handle: client.message_sender_handle.clone(),
|
message_sender_handle: client.message_sender_handle.clone(),
|
||||||
id,
|
id,
|
||||||
local_signals: Default::default(),
|
|
||||||
local_methods: Default::default(),
|
|
||||||
aliases: Default::default(),
|
aliases: Default::default(),
|
||||||
aspects: Default::default(),
|
aspects: Default::default(),
|
||||||
destroyable,
|
destroyable,
|
||||||
};
|
};
|
||||||
<Node as OwnedAspect>::add_node_members(&node);
|
node.aspects.add(Owned);
|
||||||
node
|
node
|
||||||
}
|
}
|
||||||
pub fn add_to_scenegraph(self) -> Result<Arc<Node>> {
|
pub fn add_to_scenegraph(self) -> Result<Arc<Node>> {
|
||||||
@@ -118,7 +129,8 @@ impl Node {
|
|||||||
.global_transform()
|
.global_transform()
|
||||||
.to_scale_rotation_translation()
|
.to_scale_rotation_translation()
|
||||||
.0
|
.0
|
||||||
.length_squared() > 0.0
|
.length_squared()
|
||||||
|
> 0.0
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -146,13 +158,6 @@ impl Node {
|
|||||||
// Ok(serialize(pid)?.into())
|
// Ok(serialize(pid)?.into())
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn add_local_signal(&self, id: u64, signal: Signal) {
|
|
||||||
self.local_signals.lock().insert(id, signal);
|
|
||||||
}
|
|
||||||
pub fn add_local_method(&self, id: u64, method: Method) {
|
|
||||||
self.local_methods.lock().insert(id, method);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_aspect<A: Aspect>(&self, aspect: A) -> Arc<A> {
|
pub fn add_aspect<A: Aspect>(&self, aspect: A) -> Arc<A> {
|
||||||
self.aspects.add(aspect)
|
self.aspects.add(aspect)
|
||||||
}
|
}
|
||||||
@@ -166,40 +171,45 @@ impl Node {
|
|||||||
pub fn send_local_signal(
|
pub fn send_local_signal(
|
||||||
self: Arc<Self>,
|
self: Arc<Self>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
|
aspect_id: u64,
|
||||||
method: u64,
|
method: u64,
|
||||||
message: Message,
|
message: Message,
|
||||||
) -> Result<(), ScenegraphError> {
|
) -> Result<(), ScenegraphError> {
|
||||||
if let Ok(alias) = self.get_aspect::<Alias>() {
|
if let Ok(alias) = self.get_aspect::<Alias>() {
|
||||||
if !alias.info.server_signals.iter().any(|e| *e == method) {
|
if !alias.info.server_signals.iter().any(|e| *e == method) {
|
||||||
return Err(ScenegraphError::SignalNotFound);
|
return Err(ScenegraphError::MemberNotFound);
|
||||||
}
|
}
|
||||||
alias
|
alias
|
||||||
.original
|
.original
|
||||||
.upgrade()
|
.upgrade()
|
||||||
.ok_or(ScenegraphError::BrokenAlias)?
|
.ok_or(ScenegraphError::BrokenAlias)?
|
||||||
.send_local_signal(calling_client, method, message)
|
.send_local_signal(calling_client, aspect_id, method, message)
|
||||||
} else {
|
} else {
|
||||||
let signal = self
|
let aspect = self
|
||||||
.local_signals
|
.aspects
|
||||||
|
.0
|
||||||
.lock()
|
.lock()
|
||||||
.get(&method)
|
.get(&aspect_id)
|
||||||
.cloned()
|
.ok_or(ScenegraphError::AspectNotFound)?
|
||||||
.ok_or(ScenegraphError::SignalNotFound)?;
|
.clone();
|
||||||
signal(self, calling_client, message).map_err(|error| ScenegraphError::SignalError {
|
aspect
|
||||||
error: error.to_string(),
|
.run_signal(calling_client, self.clone(), method, message)
|
||||||
})
|
.map_err(|error| ScenegraphError::MemberError {
|
||||||
|
error: error.to_string(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn execute_local_method(
|
pub fn execute_local_method(
|
||||||
self: Arc<Self>,
|
self: Arc<Self>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
|
aspect_id: u64,
|
||||||
method: u64,
|
method: u64,
|
||||||
message: Message,
|
message: Message,
|
||||||
response: MethodResponseSender,
|
response: MethodResponseSender,
|
||||||
) {
|
) {
|
||||||
if let Ok(alias) = self.get_aspect::<Alias>() {
|
if let Ok(alias) = self.get_aspect::<Alias>() {
|
||||||
if !alias.info.server_methods.iter().any(|e| *e == method) {
|
if !alias.info.server_methods.iter().any(|e| *e == method) {
|
||||||
response.send(Err(ScenegraphError::MethodNotFound));
|
response.send(Err(ScenegraphError::MemberNotFound));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let Some(alias) = alias.original.upgrade() else {
|
let Some(alias) = alias.original.upgrade() else {
|
||||||
@@ -208,6 +218,7 @@ impl Node {
|
|||||||
};
|
};
|
||||||
alias.execute_local_method(
|
alias.execute_local_method(
|
||||||
calling_client,
|
calling_client,
|
||||||
|
aspect_id,
|
||||||
method,
|
method,
|
||||||
Message {
|
Message {
|
||||||
data: message.data.clone(),
|
data: message.data.clone(),
|
||||||
@@ -216,14 +227,19 @@ impl Node {
|
|||||||
response,
|
response,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let Some(method) = self.local_methods.lock().get(&method).cloned() else {
|
let Some(aspect) = self.aspects.0.lock().get(&aspect_id).cloned() else {
|
||||||
response.send(Err(ScenegraphError::MethodNotFound));
|
response.send(Err(ScenegraphError::AspectNotFound));
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
method(self, calling_client, message, response);
|
aspect.run_method(calling_client, self.clone(), method, message, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn send_remote_signal(&self, method: u64, message: impl Into<Message>) -> Result<()> {
|
pub fn send_remote_signal(
|
||||||
|
&self,
|
||||||
|
aspect_id: u64,
|
||||||
|
method: u64,
|
||||||
|
message: impl Into<Message>,
|
||||||
|
) -> Result<()> {
|
||||||
let message = message.into();
|
let message = message.into();
|
||||||
self.aliases
|
self.aliases
|
||||||
.get_valid_contents()
|
.get_valid_contents()
|
||||||
@@ -233,6 +249,7 @@ impl Node {
|
|||||||
.for_each(|node| {
|
.for_each(|node| {
|
||||||
// Beware! file descriptors will not be sent to aliases!!!
|
// Beware! file descriptors will not be sent to aliases!!!
|
||||||
let _ = node.send_remote_signal(
|
let _ = node.send_remote_signal(
|
||||||
|
aspect_id,
|
||||||
method,
|
method,
|
||||||
Message {
|
Message {
|
||||||
data: message.data.clone(),
|
data: message.data.clone(),
|
||||||
@@ -241,12 +258,13 @@ impl Node {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
if let Some(handle) = self.message_sender_handle.as_ref() {
|
if let Some(handle) = self.message_sender_handle.as_ref() {
|
||||||
handle.signal(self.id, method, &message.data, message.fds)?;
|
handle.signal(self.id, aspect_id, method, &message.data, message.fds)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
pub async fn execute_remote_method_typed<S: Serialize, D: DeserializeOwned>(
|
pub async fn execute_remote_method_typed<S: Serialize, D: DeserializeOwned>(
|
||||||
&self,
|
&self,
|
||||||
|
aspect_id: u64,
|
||||||
method: u64,
|
method: u64,
|
||||||
input: S,
|
input: S,
|
||||||
fds: Vec<OwnedFd>,
|
fds: Vec<OwnedFd>,
|
||||||
@@ -258,7 +276,7 @@ impl Node {
|
|||||||
|
|
||||||
let serialized = serialize(input)?;
|
let serialized = serialize(input)?;
|
||||||
let result = message_sender_handle
|
let result = message_sender_handle
|
||||||
.method(self.id, method, &serialized, fds)?
|
.method(self.id, aspect_id, method, &serialized, fds)?
|
||||||
.await
|
.await
|
||||||
.map_err(|e| eyre!(e))?;
|
.map_err(|e| eyre!(e))?;
|
||||||
|
|
||||||
@@ -271,25 +289,10 @@ impl Debug for Node {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("Node")
|
f.debug_struct("Node")
|
||||||
.field("id", &self.id)
|
.field("id", &self.id)
|
||||||
.field("local_signals", &self.local_signals.lock().keys())
|
|
||||||
.field("local_methods", &self.local_methods.lock().keys())
|
|
||||||
.field("destroyable", &self.destroyable)
|
.field("destroyable", &self.destroyable)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl OwnedAspect for Node {
|
|
||||||
fn set_enabled(node: Arc<Node>, _calling_client: Arc<Client>, enabled: bool) -> Result<()> {
|
|
||||||
node.set_enabled(enabled);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn destroy(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
|
||||||
if node.destroyable {
|
|
||||||
node.destroy();
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl Drop for Node {
|
impl Drop for Node {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Debug breakpoint
|
// Debug breakpoint
|
||||||
@@ -297,12 +300,27 @@ impl Drop for Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait Aspect: Any + Send + Sync + 'static {
|
pub trait Aspect: Any + Send + Sync + 'static {
|
||||||
const NAME: &'static str;
|
fn id(&self) -> u64;
|
||||||
|
fn as_any(self: Arc<Self>) -> Arc<dyn Any + Send + Sync + 'static>;
|
||||||
|
fn run_signal(
|
||||||
|
&self,
|
||||||
|
calling_client: Arc<Client>,
|
||||||
|
node: Arc<Node>,
|
||||||
|
signal: u64,
|
||||||
|
message: Message,
|
||||||
|
) -> Result<(), stardust_xr::scenegraph::ScenegraphError>;
|
||||||
|
fn run_method(
|
||||||
|
&self,
|
||||||
|
calling_client: Arc<Client>,
|
||||||
|
node: Arc<Node>,
|
||||||
|
method: u64,
|
||||||
|
message: Message,
|
||||||
|
response: MethodResponseSender,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct Aspects(Mutex<FxHashMap<TypeId, Arc<dyn Any + Send + Sync + 'static>>>);
|
struct Aspects(Mutex<FxHashMap<u64, Arc<dyn Aspect>>>);
|
||||||
|
|
||||||
impl Aspects {
|
impl Aspects {
|
||||||
fn add<A: Aspect>(&self, t: A) -> Arc<A> {
|
fn add<A: Aspect>(&self, t: A) -> Arc<A> {
|
||||||
let aspect = Arc::new(t);
|
let aspect = Arc::new(t);
|
||||||
@@ -310,18 +328,15 @@ impl Aspects {
|
|||||||
aspect
|
aspect
|
||||||
}
|
}
|
||||||
fn add_raw<A: Aspect>(&self, aspect: Arc<A>) {
|
fn add_raw<A: Aspect>(&self, aspect: Arc<A>) {
|
||||||
self.0.lock().insert(Self::type_key::<A>(), aspect);
|
let id = aspect.id();
|
||||||
|
self.0.lock().insert(id, aspect);
|
||||||
}
|
}
|
||||||
fn get<A: Aspect>(&self) -> Result<Arc<A>> {
|
fn get<A: Aspect>(&self) -> Result<Arc<A>> {
|
||||||
self.0
|
self.0
|
||||||
.lock()
|
.lock()
|
||||||
.get(&Self::type_key::<A>())
|
.values()
|
||||||
.and_then(|a| Arc::downcast(a.clone()).ok())
|
.find_map(|a| Arc::downcast(a.clone().as_any()).ok())
|
||||||
.ok_or(eyre!("Couldn't get aspect {}", A::NAME.to_lowercase()))
|
.ok_or(eyre!("Couldn't get aspect"))
|
||||||
}
|
|
||||||
|
|
||||||
fn type_key<A: 'static>() -> TypeId {
|
|
||||||
TypeId::of::<A>()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Drop for Aspects {
|
impl Drop for Aspects {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use super::spatial::Spatial;
|
use super::spatial::Spatial;
|
||||||
use super::Node;
|
use super::{Aspect, Node};
|
||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
use crate::core::client_state::ClientStateParsed;
|
use crate::core::client_state::ClientStateParsed;
|
||||||
use crate::core::registry::Registry;
|
use crate::core::registry::Registry;
|
||||||
@@ -23,14 +23,14 @@ pub struct Root {
|
|||||||
impl Root {
|
impl Root {
|
||||||
pub fn create(client: &Arc<Client>, transform: Mat4) -> Result<Arc<Self>> {
|
pub fn create(client: &Arc<Client>, transform: Mat4) -> Result<Arc<Self>> {
|
||||||
let node = Node::from_id(client, 0, false);
|
let node = Node::from_id(client, 0, false);
|
||||||
<Self as RootAspect>::add_node_members(&node);
|
|
||||||
let node = node.add_to_scenegraph()?;
|
let node = node.add_to_scenegraph()?;
|
||||||
let _ = Spatial::add_to(&node, None, transform, false);
|
let _ = Spatial::add_to(&node, None, transform, false);
|
||||||
|
let root_aspect = node.add_aspect(Root {
|
||||||
Ok(ROOT_REGISTRY.add(Root {
|
node: node.clone(),
|
||||||
node,
|
|
||||||
connect_instant: Instant::now(),
|
connect_instant: Instant::now(),
|
||||||
}))
|
});
|
||||||
|
ROOT_REGISTRY.add_raw(&root_aspect);
|
||||||
|
Ok(root_aspect)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_frame_events(delta: f64) {
|
pub fn send_frame_events(delta: f64) {
|
||||||
@@ -54,6 +54,9 @@ impl Root {
|
|||||||
Ok(root_client::save_state(&self.node).await?.0)
|
Ok(root_client::save_state(&self.node).await?.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Aspect for Root {
|
||||||
|
impl_aspect_for_root_aspect! {}
|
||||||
|
}
|
||||||
impl RootAspect for Root {
|
impl RootAspect for Root {
|
||||||
async fn get_state(_node: Arc<Node>, calling_client: Arc<Client>) -> Result<ClientState> {
|
async fn get_state(_node: Arc<Node>, calling_client: Arc<Client>) -> Result<ClientState> {
|
||||||
let Some(state) = calling_client.state.get() else {
|
let Some(state) = calling_client.state.get() else {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use super::fields::{Field, FieldTrait};
|
|||||||
use super::Aspect;
|
use super::Aspect;
|
||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
use crate::core::registry::Registry;
|
use crate::core::registry::Registry;
|
||||||
use crate::create_interface;
|
|
||||||
use crate::nodes::{Node, OWNED_ASPECT_ALIAS_INFO};
|
use crate::nodes::{Node, OWNED_ASPECT_ALIAS_INFO};
|
||||||
use color_eyre::eyre::{eyre, OptionExt, Result};
|
use color_eyre::eyre::{eyre, OptionExt, Result};
|
||||||
use glam::{vec3a, Mat4, Quat, Vec3};
|
use glam::{vec3a, Mat4, Quat, Vec3};
|
||||||
@@ -38,6 +37,9 @@ impl Transform {
|
|||||||
Mat4::from_scale_rotation_translation(scale.into(), rotation.into(), position.into())
|
Mat4::from_scale_rotation_translation(scale.into(), rotation.into(), position.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl Aspect for Zone {
|
||||||
|
impl_aspect_for_zone_aspect! {}
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
pub static ref EXPORTED_SPATIALS: Mutex<FxHashMap<u64, Arc<Node>>> = Mutex::new(FxHashMap::default());
|
pub static ref EXPORTED_SPATIALS: Mutex<FxHashMap<u64, Arc<Node>>> = Mutex::new(FxHashMap::default());
|
||||||
@@ -74,16 +76,14 @@ impl Spatial {
|
|||||||
zoneable: bool,
|
zoneable: bool,
|
||||||
) -> Arc<Spatial> {
|
) -> Arc<Spatial> {
|
||||||
let spatial = Spatial::new(Arc::downgrade(node), parent.clone(), transform);
|
let spatial = Spatial::new(Arc::downgrade(node), parent.clone(), transform);
|
||||||
<Spatial as SpatialAspect>::add_node_members(node);
|
|
||||||
if zoneable {
|
if zoneable {
|
||||||
ZONEABLE_REGISTRY.add_raw(&spatial);
|
ZONEABLE_REGISTRY.add_raw(&spatial);
|
||||||
}
|
}
|
||||||
if let Some(parent) = parent {
|
if let Some(parent) = parent {
|
||||||
parent.children.add_raw(&spatial);
|
parent.children.add_raw(&spatial);
|
||||||
}
|
}
|
||||||
<Spatial as SpatialRefAspect>::add_node_members(node);
|
|
||||||
<Spatial as SpatialAspect>::add_node_members(node);
|
|
||||||
node.add_aspect_raw(spatial.clone());
|
node.add_aspect_raw(spatial.clone());
|
||||||
|
node.add_aspect(SpatialRef);
|
||||||
spatial
|
spatial
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,66 +242,7 @@ impl Spatial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Spatial {
|
impl Aspect for Spatial {
|
||||||
const NAME: &'static str = "Spatial";
|
impl_aspect_for_spatial_aspect! {}
|
||||||
}
|
|
||||||
impl SpatialRefAspect for Spatial {
|
|
||||||
async fn get_local_bounding_box(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
) -> Result<BoundingBox> {
|
|
||||||
let this_spatial = node.get_aspect::<Spatial>()?;
|
|
||||||
let bounds = this_spatial.get_bounding_box();
|
|
||||||
|
|
||||||
Ok(BoundingBox {
|
|
||||||
center: Vec3::from(bounds.center).into(),
|
|
||||||
size: Vec3::from(bounds.dimensions).into(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_relative_bounding_box(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
relative_to: Arc<Node>,
|
|
||||||
) -> Result<BoundingBox> {
|
|
||||||
let this_spatial = node.get_aspect::<Spatial>()?;
|
|
||||||
let relative_spatial = relative_to.get_aspect::<Spatial>()?;
|
|
||||||
let center = Spatial::space_to_space_matrix(Some(&this_spatial), Some(&relative_spatial))
|
|
||||||
.transform_point3([0.0; 3].into());
|
|
||||||
let mut bounds = Bounds {
|
|
||||||
center: center.into(),
|
|
||||||
dimensions: [0.0; 3].into(),
|
|
||||||
};
|
|
||||||
bounds.grown_box(
|
|
||||||
this_spatial.get_bounding_box(),
|
|
||||||
Spatial::space_to_space_matrix(Some(&this_spatial), Some(&relative_spatial)),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(BoundingBox {
|
|
||||||
center: Vec3::from(bounds.center).into(),
|
|
||||||
size: Vec3::from(bounds.dimensions).into(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_transform(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
relative_to: Arc<Node>,
|
|
||||||
) -> Result<Transform> {
|
|
||||||
let this_spatial = node.get_aspect::<Spatial>()?;
|
|
||||||
let relative_spatial = relative_to.get_aspect::<Spatial>()?;
|
|
||||||
|
|
||||||
let (scale, rotation, position) = Spatial::space_to_space_matrix(
|
|
||||||
Some(this_spatial.as_ref()),
|
|
||||||
Some(relative_spatial.as_ref()),
|
|
||||||
)
|
|
||||||
.to_scale_rotation_translation();
|
|
||||||
|
|
||||||
Ok(Transform {
|
|
||||||
translation: Some(position.into()),
|
|
||||||
rotation: Some(rotation.into()),
|
|
||||||
scale: Some(scale.into()),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
impl SpatialAspect for Spatial {
|
impl SpatialAspect for Spatial {
|
||||||
fn set_local_transform(
|
fn set_local_transform(
|
||||||
@@ -389,6 +330,70 @@ impl Drop for Spatial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct SpatialRef;
|
||||||
|
impl Aspect for SpatialRef {
|
||||||
|
impl_aspect_for_spatial_ref_aspect! {}
|
||||||
|
}
|
||||||
|
impl SpatialRefAspect for SpatialRef {
|
||||||
|
async fn get_local_bounding_box(
|
||||||
|
node: Arc<Node>,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
) -> Result<BoundingBox> {
|
||||||
|
let this_spatial = node.get_aspect::<Spatial>()?;
|
||||||
|
let bounds = this_spatial.get_bounding_box();
|
||||||
|
|
||||||
|
Ok(BoundingBox {
|
||||||
|
center: Vec3::from(bounds.center).into(),
|
||||||
|
size: Vec3::from(bounds.dimensions).into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_relative_bounding_box(
|
||||||
|
node: Arc<Node>,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
relative_to: Arc<Node>,
|
||||||
|
) -> Result<BoundingBox> {
|
||||||
|
let this_spatial = node.get_aspect::<Spatial>()?;
|
||||||
|
let relative_spatial = relative_to.get_aspect::<Spatial>()?;
|
||||||
|
let center = Spatial::space_to_space_matrix(Some(&this_spatial), Some(&relative_spatial))
|
||||||
|
.transform_point3([0.0; 3].into());
|
||||||
|
let mut bounds = Bounds {
|
||||||
|
center: center.into(),
|
||||||
|
dimensions: [0.0; 3].into(),
|
||||||
|
};
|
||||||
|
bounds.grown_box(
|
||||||
|
this_spatial.get_bounding_box(),
|
||||||
|
Spatial::space_to_space_matrix(Some(&this_spatial), Some(&relative_spatial)),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(BoundingBox {
|
||||||
|
center: Vec3::from(bounds.center).into(),
|
||||||
|
size: Vec3::from(bounds.dimensions).into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_transform(
|
||||||
|
node: Arc<Node>,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
relative_to: Arc<Node>,
|
||||||
|
) -> Result<Transform> {
|
||||||
|
let this_spatial = node.get_aspect::<Spatial>()?;
|
||||||
|
let relative_spatial = relative_to.get_aspect::<Spatial>()?;
|
||||||
|
|
||||||
|
let (scale, rotation, position) = Spatial::space_to_space_matrix(
|
||||||
|
Some(this_spatial.as_ref()),
|
||||||
|
Some(relative_spatial.as_ref()),
|
||||||
|
)
|
||||||
|
.to_scale_rotation_translation();
|
||||||
|
|
||||||
|
Ok(Transform {
|
||||||
|
translation: Some(position.into()),
|
||||||
|
rotation: Some(rotation.into()),
|
||||||
|
scale: Some(scale.into()),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_transform(transform: Transform, position: bool, rotation: bool, scale: bool) -> Mat4 {
|
pub fn parse_transform(transform: Transform, position: bool, rotation: bool, scale: bool) -> Mat4 {
|
||||||
let position = position
|
let position = position
|
||||||
.then_some(transform.translation)
|
.then_some(transform.translation)
|
||||||
@@ -406,8 +411,7 @@ pub fn parse_transform(transform: Transform, position: bool, rotation: bool, sca
|
|||||||
Mat4::from_scale_rotation_translation(scale.into(), rotation.into(), position.into())
|
Mat4::from_scale_rotation_translation(scale.into(), rotation.into(), position.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SpatialInterface;
|
impl InterfaceAspect for Interface {
|
||||||
impl InterfaceAspect for SpatialInterface {
|
|
||||||
fn create_spatial(
|
fn create_spatial(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
@@ -460,5 +464,3 @@ impl InterfaceAspect for SpatialInterface {
|
|||||||
.ok_or_eyre("Couldn't find spatial with that ID")
|
.ok_or_eyre("Couldn't find spatial with that ID")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_interface!(SpatialInterface);
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use crate::{
|
|||||||
nodes::{
|
nodes::{
|
||||||
alias::{get_original, Alias, AliasList},
|
alias::{get_original, Alias, AliasList},
|
||||||
fields::{Field, FieldTrait},
|
fields::{Field, FieldTrait},
|
||||||
Aspect, Node,
|
Node,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
@@ -73,7 +73,6 @@ impl Zone {
|
|||||||
intersecting: AliasList::default(),
|
intersecting: AliasList::default(),
|
||||||
captured: AliasList::default(),
|
captured: AliasList::default(),
|
||||||
});
|
});
|
||||||
<Zone as ZoneAspect>::add_node_members(node);
|
|
||||||
node.add_aspect_raw(zone.clone());
|
node.add_aspect_raw(zone.clone());
|
||||||
zone
|
zone
|
||||||
}
|
}
|
||||||
@@ -124,9 +123,6 @@ impl Zone {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Zone {
|
|
||||||
const NAME: &'static str = "Zone";
|
|
||||||
}
|
|
||||||
impl ZoneAspect for Zone {
|
impl ZoneAspect for Zone {
|
||||||
fn update(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
fn update(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<()> {
|
||||||
let zone = node.get_aspect::<Zone>()?;
|
let zone = node.get_aspect::<Zone>()?;
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ use color_eyre::eyre::Result;
|
|||||||
use glam::{Mat4, Quat, Vec3};
|
use glam::{Mat4, Quat, Vec3};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use stardust_xr::values::Datamap;
|
use stardust_xr::values::Datamap;
|
||||||
use std::f32::INFINITY;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use stereokit_rust::material::Material;
|
||||||
use stereokit_rust::sk::{DisplayMode, MainThreadToken, Sk};
|
use stereokit_rust::sk::{DisplayMode, MainThreadToken, Sk};
|
||||||
use stereokit_rust::system::{HandJoint, HandSource, Handed, Input, LinePoint, Lines};
|
use stereokit_rust::system::{HandJoint, HandSource, Handed, Input, LinePoint, Lines};
|
||||||
use stereokit_rust::util::Color128;
|
use stereokit_rust::util::Color128;
|
||||||
@@ -63,8 +63,8 @@ impl SkHand {
|
|||||||
});
|
});
|
||||||
let datamap = Datamap::from_typed(HandDatamap::default())?;
|
let datamap = Datamap::from_typed(HandDatamap::default())?;
|
||||||
let input = InputMethod::add_to(&_node.0, hand, datamap)?;
|
let input = InputMethod::add_to(&_node.0, hand, datamap)?;
|
||||||
|
Input::hand_visible(handed, true);
|
||||||
|
|
||||||
Input::hand_visible(handed, false);
|
|
||||||
Ok(SkHand {
|
Ok(SkHand {
|
||||||
_node,
|
_node,
|
||||||
palm_spatial,
|
palm_spatial,
|
||||||
@@ -75,7 +75,7 @@ impl SkHand {
|
|||||||
datamap: Default::default(),
|
datamap: Default::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn update(&mut self, sk: &Sk, token: &MainThreadToken) {
|
pub fn update(&mut self, sk: &Sk, token: &MainThreadToken, material: &mut Material) {
|
||||||
let sk_hand = Input::hand(self.handed);
|
let sk_hand = Input::hand(self.handed);
|
||||||
let real_hand = Input::hand_source(self.handed) as u32 == HandSource::Articulated as u32;
|
let real_hand = Input::hand_source(self.handed) as u32 == HandSource::Articulated as u32;
|
||||||
if let InputDataType::Hand(hand) = &mut *self.input.data.lock() {
|
if let InputDataType::Hand(hand) = &mut *self.input.data.lock() {
|
||||||
@@ -122,15 +122,12 @@ impl SkHand {
|
|||||||
|
|
||||||
hand.elbow = None;
|
hand.elbow = None;
|
||||||
|
|
||||||
self.draw(
|
let hand_color = if self.capture_manager.capture.is_none() {
|
||||||
token,
|
Color128::new_rgb(1.0, 1.0, 1.0)
|
||||||
if self.capture_manager.capture.is_none() {
|
} else {
|
||||||
Color128::new_rgb(1.0, 1.0, 1.0)
|
Color128::new_rgb(0.0, 1.0, 0.75)
|
||||||
} else {
|
};
|
||||||
Color128::new_rgb(0.0, 1.0, 0.75)
|
material.color_tint(hand_color);
|
||||||
},
|
|
||||||
hand,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.datamap.pinch_strength = sk_hand.pinch_activation;
|
self.datamap.pinch_strength = sk_hand.pinch_activation;
|
||||||
@@ -166,65 +163,10 @@ impl SkHand {
|
|||||||
let sorted_handlers = get_sorted_handlers(&self.input, distance_calculator);
|
let sorted_handlers = get_sorted_handlers(&self.input, distance_calculator);
|
||||||
self.input.set_handler_order(sorted_handlers.iter());
|
self.input.set_handler_order(sorted_handlers.iter());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fn draw(&self, token: &MainThreadToken, color: Color128, hand: &Hand) {
|
impl Drop for SkHand {
|
||||||
// thumb
|
fn drop(&mut self) {
|
||||||
Lines::add_list(
|
Input::hand_visible(self.handed, false);
|
||||||
token,
|
|
||||||
&[
|
|
||||||
joint_to_line_point(&hand.thumb.tip, color),
|
|
||||||
joint_to_line_point(&hand.thumb.distal, color),
|
|
||||||
joint_to_line_point(&hand.thumb.proximal, color),
|
|
||||||
joint_to_line_point(&hand.thumb.metacarpal, color),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
// index
|
|
||||||
Lines::add_list(
|
|
||||||
token,
|
|
||||||
&[
|
|
||||||
joint_to_line_point(&hand.index.tip, color),
|
|
||||||
joint_to_line_point(&hand.index.distal, color),
|
|
||||||
joint_to_line_point(&hand.index.intermediate, color),
|
|
||||||
joint_to_line_point(&hand.index.proximal, color),
|
|
||||||
joint_to_line_point(&hand.index.metacarpal, color),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
// middle
|
|
||||||
Lines::add_list(
|
|
||||||
token,
|
|
||||||
&[
|
|
||||||
joint_to_line_point(&hand.middle.tip, color),
|
|
||||||
joint_to_line_point(&hand.middle.distal, color),
|
|
||||||
joint_to_line_point(&hand.middle.intermediate, color),
|
|
||||||
joint_to_line_point(&hand.middle.proximal, color),
|
|
||||||
joint_to_line_point(&hand.middle.metacarpal, color),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
// ring
|
|
||||||
Lines::add_list(
|
|
||||||
token,
|
|
||||||
&[
|
|
||||||
joint_to_line_point(&hand.ring.tip, color),
|
|
||||||
joint_to_line_point(&hand.ring.distal, color),
|
|
||||||
joint_to_line_point(&hand.ring.intermediate, color),
|
|
||||||
joint_to_line_point(&hand.ring.proximal, color),
|
|
||||||
joint_to_line_point(&hand.ring.metacarpal, color),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
// palm
|
|
||||||
Lines::add_list(
|
|
||||||
token,
|
|
||||||
&[
|
|
||||||
joint_to_line_point(&hand.wrist, color),
|
|
||||||
joint_to_line_point(&hand.thumb.metacarpal, color),
|
|
||||||
joint_to_line_point(&hand.index.metacarpal, color),
|
|
||||||
joint_to_line_point(&hand.middle.metacarpal, color),
|
|
||||||
joint_to_line_point(&hand.ring.metacarpal, color),
|
|
||||||
joint_to_line_point(&hand.little.metacarpal, color),
|
|
||||||
joint_to_line_point(&hand.wrist, color),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use input::{
|
|||||||
use play_space::PlaySpaceBounds;
|
use play_space::PlaySpaceBounds;
|
||||||
use std::{marker::PhantomData, sync::Arc};
|
use std::{marker::PhantomData, sync::Arc};
|
||||||
use stereokit_rust::{
|
use stereokit_rust::{
|
||||||
|
material::Material,
|
||||||
sk::{DisplayMode, MainThreadToken, Sk},
|
sk::{DisplayMode, MainThreadToken, Sk},
|
||||||
system::{Handed, Input, Key, World},
|
system::{Handed, Input, Key, World},
|
||||||
util::Device,
|
util::Device,
|
||||||
@@ -45,6 +46,7 @@ pub struct ServerObjects {
|
|||||||
connection: Connection,
|
connection: Connection,
|
||||||
hmd: (Arc<Spatial>, ObjectHandle<SpatialRef>),
|
hmd: (Arc<Spatial>, ObjectHandle<SpatialRef>),
|
||||||
play_space: Option<(Arc<Spatial>, ObjectHandle<SpatialRef>)>,
|
play_space: Option<(Arc<Spatial>, ObjectHandle<SpatialRef>)>,
|
||||||
|
hand_materials: [Material; 2],
|
||||||
inputs: Inputs,
|
inputs: Inputs,
|
||||||
disable_controllers: bool,
|
disable_controllers: bool,
|
||||||
disable_hands: bool,
|
disable_hands: bool,
|
||||||
@@ -53,6 +55,7 @@ impl ServerObjects {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
sk: &Sk,
|
sk: &Sk,
|
||||||
|
hand_materials: [Material; 2],
|
||||||
disable_controllers: bool,
|
disable_controllers: bool,
|
||||||
disable_hands: bool,
|
disable_hands: bool,
|
||||||
) -> ServerObjects {
|
) -> ServerObjects {
|
||||||
@@ -106,6 +109,7 @@ impl ServerObjects {
|
|||||||
connection,
|
connection,
|
||||||
hmd,
|
hmd,
|
||||||
play_space,
|
play_space,
|
||||||
|
hand_materials,
|
||||||
inputs,
|
inputs,
|
||||||
disable_controllers,
|
disable_controllers,
|
||||||
disable_hands,
|
disable_hands,
|
||||||
@@ -132,6 +136,7 @@ impl ServerObjects {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::collapsible_if)]
|
||||||
if sk.get_active_display_mode() != DisplayMode::MixedReality {
|
if sk.get_active_display_mode() != DisplayMode::MixedReality {
|
||||||
if Input::key(Key::F6).is_just_inactive() {
|
if Input::key(Key::F6).is_just_inactive() {
|
||||||
self.inputs = Inputs::MousePointer(MousePointer::new().unwrap());
|
self.inputs = Inputs::MousePointer(MousePointer::new().unwrap());
|
||||||
@@ -142,12 +147,12 @@ impl ServerObjects {
|
|||||||
// SkController::new(Handed::Right).unwrap(),
|
// SkController::new(Handed::Right).unwrap(),
|
||||||
// ));
|
// ));
|
||||||
// }
|
// }
|
||||||
if Input::key(Key::F8).is_just_inactive() {
|
// if Input::key(Key::F8).is_just_inactive() {
|
||||||
self.inputs = Inputs::Hands {
|
// self.inputs = Inputs::Hands {
|
||||||
left: SkHand::new(&self.connection, Handed::Left).unwrap(),
|
// left: SkHand::new(&self.connection, Handed::Left).unwrap(),
|
||||||
right: SkHand::new(&self.connection, Handed::Right).unwrap(),
|
// right: SkHand::new(&self.connection, Handed::Right).unwrap(),
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
match &mut self.inputs {
|
match &mut self.inputs {
|
||||||
@@ -162,9 +167,11 @@ impl ServerObjects {
|
|||||||
controller_left.update(token);
|
controller_left.update(token);
|
||||||
controller_right.update(token);
|
controller_right.update(token);
|
||||||
}
|
}
|
||||||
|
Input::hand_visible(Handed::Left, !self.disable_hands);
|
||||||
|
Input::hand_visible(Handed::Right, !self.disable_hands);
|
||||||
if !self.disable_hands {
|
if !self.disable_hands {
|
||||||
hand_left.update(sk, token);
|
hand_left.update(sk, token, &mut self.hand_materials[0]);
|
||||||
hand_right.update(sk, token);
|
hand_right.update(sk, token, &mut self.hand_materials[1]);
|
||||||
}
|
}
|
||||||
if let Some(eye_pointer) = eye_pointer {
|
if let Some(eye_pointer) = eye_pointer {
|
||||||
eye_pointer.update();
|
eye_pointer.update();
|
||||||
@@ -176,8 +183,8 @@ impl ServerObjects {
|
|||||||
// right.update(token);
|
// right.update(token);
|
||||||
// }
|
// }
|
||||||
Inputs::Hands { left, right } => {
|
Inputs::Hands { left, right } => {
|
||||||
left.update(sk, token);
|
left.update(sk, token, &mut self.hand_materials[0]);
|
||||||
right.update(sk, token);
|
right.update(sk, token, &mut self.hand_materials[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,13 +87,12 @@ impl UnownedFd {
|
|||||||
}
|
}
|
||||||
impl Drop for UnownedFd {
|
impl Drop for UnownedFd {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
self.0.take().unwrap().into_inner().into_raw_fd();
|
let _ = self.0.take().unwrap().into_inner().into_raw_fd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Wayland {
|
pub struct Wayland {
|
||||||
display: Arc<DisplayWrapper>,
|
display: Arc<DisplayWrapper>,
|
||||||
pub socket_name: Option<String>,
|
|
||||||
join_handle: JoinHandle<Result<()>>,
|
join_handle: JoinHandle<Result<()>>,
|
||||||
renderer: GlesRenderer,
|
renderer: GlesRenderer,
|
||||||
output: Output,
|
output: Output,
|
||||||
@@ -133,7 +132,6 @@ impl Wayland {
|
|||||||
|
|
||||||
Ok(Wayland {
|
Ok(Wayland {
|
||||||
display,
|
display,
|
||||||
socket_name,
|
|
||||||
join_handle,
|
join_handle,
|
||||||
renderer,
|
renderer,
|
||||||
output,
|
output,
|
||||||
|
|||||||
Reference in New Issue
Block a user