Add active Brokkr sync pass
This commit is contained in:
parent
f07ccef598
commit
5b713f76fa
8 changed files with 1694 additions and 3 deletions
683
Cargo.lock
generated
683
Cargo.lock
generated
|
|
@ -2,19 +2,253 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
||||
|
||||
[[package]]
|
||||
name = "brokkr-daemon"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cultcache-rs",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dad887fd958be91b5098c0248def011f4523ab786cd411be668777e55063501f"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||
|
||||
[[package]]
|
||||
name = "cultcache-rs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chrono",
|
||||
"cultcache-rs-derive",
|
||||
"fs2",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"serde_json",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cultcache-rs-derive"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6"
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
||||
|
||||
[[package]]
|
||||
name = "fs2"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasip2",
|
||||
"wasip3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "id-arena"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.17.1",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -23,12 +257,78 @@ version = "1.0.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03d04c30968dffe80775bd4d7fb676131cd04a1fb46d2686dbffbaec2d9dfd31"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-util",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "leb128fmt"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.186"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.2.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.106"
|
||||
|
|
@ -47,6 +347,56 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rmp"
|
||||
version = "0.8.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ba8be72d372b2c9b35542551678538b562e7cf86c3315773cae48dfbfe7790c"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rmp-serde"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72f81bee8c8ef9b577d1681a70ebbc962c232461e397b22c208c43c04b67a155"
|
||||
dependencies = [
|
||||
"rmp",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.228"
|
||||
|
|
@ -57,6 +407,16 @@ dependencies = [
|
|||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_bytes"
|
||||
version = "0.11.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
|
|
@ -90,6 +450,18 @@ dependencies = [
|
|||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.117"
|
||||
|
|
@ -101,12 +473,323 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.23.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "144d6b123cef80b301b8f72a9e2ca4370ddec21950d0a103dd22c437006d2db7"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.4+wasi-0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
|
||||
dependencies = [
|
||||
"wit-bindgen 0.57.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasip3"
|
||||
version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
|
||||
dependencies = [
|
||||
"wit-bindgen 0.51.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.125"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ddb3f79143bced6de84270411622a2699cee572fc0875aeaf1e7867cf9fca1a"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.125"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e21a184b13fb19e157296e2c46056aec9092264fab83e4ba59e68c61b323c3d"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.125"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fecefd9c35bd935a20fc3fc344b5f29138961e4f47fb03297d88f2587afb5ebd"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.125"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23939e44bb9a5d7576fa2b563dc2e136628f1224e88a8deed09e04858b77871f"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-encoder"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
|
||||
dependencies = [
|
||||
"leb128fmt",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-metadata"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"indexmap",
|
||||
"wasm-encoder",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"hashbrown 0.15.5",
|
||||
"indexmap",
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-link",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.60.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.59.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
|
||||
dependencies = [
|
||||
"wit-bindgen-rust-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.57.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-core"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"prettyplease",
|
||||
"syn",
|
||||
"wasm-metadata",
|
||||
"wit-bindgen-core",
|
||||
"wit-component",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rust-macro"
|
||||
version = "0.51.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wit-bindgen-core",
|
||||
"wit-bindgen-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-component"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
"indexmap",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"wasm-encoder",
|
||||
"wasm-metadata",
|
||||
"wasmparser",
|
||||
"wit-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-parser"
|
||||
version = "0.244.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"id-arena",
|
||||
"indexmap",
|
||||
"log",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"unicode-xid",
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.21"
|
||||
|
|
|
|||
|
|
@ -6,5 +6,10 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
cultcache-rs = { path = "../../cultcache-rs" }
|
||||
rmp-serde = "1.3"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use cultcache_rs::{CacheBackingStore, CultCacheEnvelope, SingleFileMessagePackBackingStore};
|
||||
use serde::Serialize;
|
||||
use serde_json::{Value, json};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
const PROVIDER_SCHEMA: &str = "gamecult.brokkr.provider_advertisement.v0";
|
||||
const PROVIDER_ID: &str = "brokkr.creative_tool_broker";
|
||||
|
|
@ -124,8 +128,11 @@ fn main() -> Result<()> {
|
|||
match command.as_str() {
|
||||
"provider" | "smoke" => print_provider(),
|
||||
"sync-contract" => print_sync_contract(),
|
||||
"sync-once" => sync_once(SyncArgs::parse(args.collect())?),
|
||||
_ => {
|
||||
eprintln!("usage: brokkr-daemon [provider|smoke|sync-contract]");
|
||||
eprintln!(
|
||||
"usage: brokkr-daemon [provider|smoke|sync-contract|sync-once --unity-cache PATH --blender-cache PATH [--dry-run]]"
|
||||
);
|
||||
std::process::exit(2);
|
||||
}
|
||||
}
|
||||
|
|
@ -144,6 +151,12 @@ fn print_sync_contract() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn sync_once(args: SyncArgs) -> Result<()> {
|
||||
let report = run_sync_once(&args)?;
|
||||
println!("{}", serde_json::to_string_pretty(&report)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn build_provider_advertisement() -> ProviderAdvertisement {
|
||||
ProviderAdvertisement {
|
||||
schema: PROVIDER_SCHEMA,
|
||||
|
|
@ -442,6 +455,732 @@ fn build_unity_quest_routes() -> Vec<RealtimeRoute> {
|
|||
]
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
struct SyncArgs {
|
||||
unity_cache: PathBuf,
|
||||
blender_cache: PathBuf,
|
||||
dry_run: bool,
|
||||
}
|
||||
|
||||
impl SyncArgs {
|
||||
fn parse(args: Vec<String>) -> Result<Self> {
|
||||
let mut unity_cache = None;
|
||||
let mut blender_cache = None;
|
||||
let mut dry_run = false;
|
||||
let mut index = 0;
|
||||
|
||||
while index < args.len() {
|
||||
match args[index].as_str() {
|
||||
"--unity-cache" => {
|
||||
index += 1;
|
||||
unity_cache = args.get(index).map(PathBuf::from);
|
||||
}
|
||||
"--blender-cache" => {
|
||||
index += 1;
|
||||
blender_cache = args.get(index).map(PathBuf::from);
|
||||
}
|
||||
"--dry-run" => dry_run = true,
|
||||
other => return Err(anyhow!("unknown sync-once argument: {other}")),
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
unity_cache: unity_cache.ok_or_else(|| anyhow!("sync-once requires --unity-cache"))?,
|
||||
blender_cache: blender_cache
|
||||
.ok_or_else(|| anyhow!("sync-once requires --blender-cache"))?,
|
||||
dry_run,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct SyncPassReport {
|
||||
schema: &'static str,
|
||||
status: &'static str,
|
||||
dry_run: bool,
|
||||
object_bindings_seen: usize,
|
||||
sync_vars_seen: usize,
|
||||
unity_commands_written: usize,
|
||||
blender_commands_written: usize,
|
||||
receipts_written: usize,
|
||||
messages: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct CacheDocument {
|
||||
key: String,
|
||||
value: Value,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct ObjectBinding {
|
||||
binding_id: String,
|
||||
session_id: String,
|
||||
display_name: String,
|
||||
unity_object_id: String,
|
||||
unity_path: String,
|
||||
blender_object_name: String,
|
||||
enabled: bool,
|
||||
authority: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct SyncVarBinding {
|
||||
sync_var_id: String,
|
||||
session_id: String,
|
||||
binding_id: String,
|
||||
kind: String,
|
||||
unity_property_path: String,
|
||||
blender_property_path: String,
|
||||
authority: String,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct TimelineBinding {
|
||||
binding_id: String,
|
||||
session_id: String,
|
||||
unity_timeline_object_id: String,
|
||||
unity_cinemachine_object_id: String,
|
||||
blender_scene_name: String,
|
||||
blender_action_name: String,
|
||||
clock_authority: String,
|
||||
frame_rate: f64,
|
||||
sync_frame: bool,
|
||||
sync_camera: bool,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct UnityObject {
|
||||
object_id: String,
|
||||
name: String,
|
||||
path: String,
|
||||
active_self: bool,
|
||||
local_position: Vec<f64>,
|
||||
local_euler_angles: Vec<f64>,
|
||||
local_scale: Vec<f64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct BlenderObject {
|
||||
name: String,
|
||||
location: Vec<f64>,
|
||||
rotation_euler: Vec<f64>,
|
||||
scale: Vec<f64>,
|
||||
visible: bool,
|
||||
materials: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct BlenderTimeline {
|
||||
scene_name: String,
|
||||
frame_current: i64,
|
||||
}
|
||||
|
||||
fn run_sync_once(args: &SyncArgs) -> Result<SyncPassReport> {
|
||||
let mut unity_store = MirrorStore::open(&args.unity_cache)?;
|
||||
let mut blender_store = MirrorStore::open(&args.blender_cache)?;
|
||||
let mut documents = Vec::new();
|
||||
documents.extend(unity_store.documents()?);
|
||||
documents.extend(blender_store.documents()?);
|
||||
|
||||
let object_bindings: Vec<_> = documents
|
||||
.iter()
|
||||
.filter(|document| document.key.starts_with("sync/bindings/objects/"))
|
||||
.filter_map(|document| parse_object_binding(&document.value))
|
||||
.collect();
|
||||
let sync_vars: Vec<_> = documents
|
||||
.iter()
|
||||
.filter(|document| document.key.starts_with("sync/vars/"))
|
||||
.filter_map(|document| parse_sync_var(&document.value))
|
||||
.collect();
|
||||
let timeline_bindings: Vec<_> = documents
|
||||
.iter()
|
||||
.filter(|document| document.key.starts_with("sync/bindings/timelines/"))
|
||||
.filter_map(|document| parse_timeline_binding(&document.value))
|
||||
.collect();
|
||||
let unity_objects = parse_unity_objects(&documents);
|
||||
let blender_objects = parse_blender_objects(&documents);
|
||||
let blender_timeline = parse_blender_timeline(&documents);
|
||||
|
||||
let mut report = SyncPassReport {
|
||||
schema: "brokkr.sync.pass_report.v0",
|
||||
status: "ok",
|
||||
dry_run: args.dry_run,
|
||||
object_bindings_seen: object_bindings.len(),
|
||||
sync_vars_seen: sync_vars.len(),
|
||||
unity_commands_written: 0,
|
||||
blender_commands_written: 0,
|
||||
receipts_written: 0,
|
||||
messages: Vec::new(),
|
||||
};
|
||||
|
||||
let mut emitted_command_ids = BTreeSet::new();
|
||||
|
||||
for binding in object_bindings.iter().filter(|binding| binding.enabled) {
|
||||
let binding_vars: Vec<_> = sync_vars
|
||||
.iter()
|
||||
.filter(|sync_var| {
|
||||
sync_var.binding_id == binding.binding_id
|
||||
&& sync_var.session_id == binding.session_id
|
||||
&& sync_var.enabled
|
||||
})
|
||||
.collect();
|
||||
|
||||
for sync_var in binding_vars {
|
||||
let authority = if sync_var.authority.trim().is_empty() {
|
||||
binding.authority.as_str()
|
||||
} else {
|
||||
sync_var.authority.as_str()
|
||||
};
|
||||
match (authority, sync_var.kind.as_str()) {
|
||||
("unity-to-blender", "transform") => {
|
||||
let Some(source) = find_unity_object(&unity_objects, binding) else {
|
||||
report.messages.push(format!(
|
||||
"missing Unity object for binding {}",
|
||||
binding.binding_id
|
||||
));
|
||||
continue;
|
||||
};
|
||||
let command_id = stable_id([
|
||||
"sync",
|
||||
&binding.binding_id,
|
||||
&sync_var.sync_var_id,
|
||||
"unity-to-blender-transform",
|
||||
]);
|
||||
if emitted_command_ids.insert(command_id.clone()) {
|
||||
let command = json!({
|
||||
"schema": "brokkr.blender.command_intent.v0",
|
||||
"commandId": command_id,
|
||||
"action": "setObjectTransform",
|
||||
"targetObjectName": binding.blender_object_name,
|
||||
"location": source.local_position,
|
||||
"rotationEuler": source.local_euler_angles,
|
||||
"scale": source.local_scale,
|
||||
});
|
||||
if !args.dry_run {
|
||||
blender_store.put_json_document(
|
||||
"brokkr.blender.command_intent.v0",
|
||||
&format!(
|
||||
"blender/commands/{}",
|
||||
command["commandId"].as_str().unwrap_or("sync")
|
||||
),
|
||||
&command,
|
||||
)?;
|
||||
}
|
||||
report.blender_commands_written += 1;
|
||||
}
|
||||
}
|
||||
("unity-to-blender", "active-state") => {
|
||||
let Some(source) = find_unity_object(&unity_objects, binding) else {
|
||||
continue;
|
||||
};
|
||||
let command_id = stable_id([
|
||||
"sync",
|
||||
&binding.binding_id,
|
||||
&sync_var.sync_var_id,
|
||||
"unity-to-blender-active",
|
||||
]);
|
||||
if emitted_command_ids.insert(command_id.clone()) {
|
||||
let command = json!({
|
||||
"schema": "brokkr.blender.command_intent.v0",
|
||||
"commandId": command_id,
|
||||
"action": "setObjectVisibility",
|
||||
"targetObjectName": binding.blender_object_name,
|
||||
"visible": source.active_self,
|
||||
});
|
||||
if !args.dry_run {
|
||||
blender_store.put_json_document(
|
||||
"brokkr.blender.command_intent.v0",
|
||||
&format!(
|
||||
"blender/commands/{}",
|
||||
command["commandId"].as_str().unwrap_or("sync")
|
||||
),
|
||||
&command,
|
||||
)?;
|
||||
}
|
||||
report.blender_commands_written += 1;
|
||||
}
|
||||
}
|
||||
("blender-to-unity", "transform") => {
|
||||
let Some(source) = blender_objects.get(&binding.blender_object_name) else {
|
||||
report.messages.push(format!(
|
||||
"missing Blender object {} for binding {}",
|
||||
binding.blender_object_name, binding.binding_id
|
||||
));
|
||||
continue;
|
||||
};
|
||||
let command_id = stable_id([
|
||||
"sync",
|
||||
&binding.binding_id,
|
||||
&sync_var.sync_var_id,
|
||||
"blender-to-unity-transform",
|
||||
]);
|
||||
if emitted_command_ids.insert(command_id.clone()) {
|
||||
let command = unity_transform_command(
|
||||
&command_id,
|
||||
&binding.unity_object_id,
|
||||
&source.location,
|
||||
&source.rotation_euler,
|
||||
&source.scale,
|
||||
);
|
||||
if !args.dry_run {
|
||||
unity_store.put_messagepack_document(
|
||||
"brokkr.unity.command_intent.v0",
|
||||
&format!("unity/commands/{command_id}"),
|
||||
&command,
|
||||
)?;
|
||||
}
|
||||
report.unity_commands_written += 1;
|
||||
}
|
||||
}
|
||||
("blender-to-unity", "material") => {
|
||||
let Some(source) = blender_objects.get(&binding.blender_object_name) else {
|
||||
continue;
|
||||
};
|
||||
let material = source.materials.first().cloned().unwrap_or_default();
|
||||
report.messages.push(format!(
|
||||
"material sync requested for {} -> {} (source name={}, visible={}, material={}) but Unity material import mapping is not implemented yet",
|
||||
binding.blender_object_name,
|
||||
binding.unity_object_id,
|
||||
source.name,
|
||||
source.visible,
|
||||
material
|
||||
));
|
||||
}
|
||||
_ => report.messages.push(format!(
|
||||
"unsupported sync var {} kind={} authority={} unityPath={} blenderPath={}",
|
||||
sync_var.sync_var_id,
|
||||
sync_var.kind,
|
||||
authority,
|
||||
sync_var.unity_property_path,
|
||||
sync_var.blender_property_path
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for timeline in timeline_bindings.iter().filter(|binding| binding.enabled) {
|
||||
if timeline.sync_frame {
|
||||
let Some(source) = blender_timeline
|
||||
.iter()
|
||||
.find(|candidate| candidate.scene_name == timeline.blender_scene_name)
|
||||
.or_else(|| blender_timeline.first())
|
||||
else {
|
||||
report.messages.push(
|
||||
"timeline sync requested but no Blender scene snapshot is available"
|
||||
.to_string(),
|
||||
);
|
||||
continue;
|
||||
};
|
||||
let command_id = stable_id([
|
||||
"sync",
|
||||
&timeline.binding_id,
|
||||
"timeline-frame",
|
||||
&source.frame_current.to_string(),
|
||||
]);
|
||||
let seconds = source.frame_current as f64 / timeline.frame_rate.max(0.001);
|
||||
let command = unity_property_command(
|
||||
&command_id,
|
||||
&timeline.unity_timeline_object_id,
|
||||
"m_Time",
|
||||
&format!("{seconds:.6}"),
|
||||
);
|
||||
if !args.dry_run {
|
||||
unity_store.put_messagepack_document(
|
||||
"brokkr.unity.command_intent.v0",
|
||||
&format!("unity/commands/{command_id}"),
|
||||
&command,
|
||||
)?;
|
||||
}
|
||||
report.unity_commands_written += 1;
|
||||
}
|
||||
|
||||
if timeline.sync_camera {
|
||||
report.messages.push(format!(
|
||||
"Cinemachine syncvar is visible for binding {} session={} unityCamera={} blenderAction={} clockAuthority={} but camera lens/body mapping still needs a Cinemachine-specific command writer",
|
||||
timeline.binding_id,
|
||||
timeline.session_id,
|
||||
timeline.unity_cinemachine_object_id,
|
||||
timeline.blender_action_name,
|
||||
timeline.clock_authority
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let receipt = json!({
|
||||
"schema": "brokkr.sync.receipt.v0",
|
||||
"receiptId": stable_id(["sync-receipt", &chrono_like_timestamp_id()]),
|
||||
"sessionId": object_bindings
|
||||
.first()
|
||||
.map(|binding| binding.session_id.as_str())
|
||||
.or_else(|| timeline_bindings.first().map(|binding| binding.session_id.as_str()))
|
||||
.unwrap_or("default"),
|
||||
"status": report.status,
|
||||
"message": format!(
|
||||
"wrote {} Unity command(s) and {} Blender command(s)",
|
||||
report.unity_commands_written, report.blender_commands_written
|
||||
),
|
||||
"observedAt": chrono_like_now(),
|
||||
});
|
||||
if !args.dry_run {
|
||||
unity_store.put_json_document(
|
||||
"brokkr.sync.receipt.v0",
|
||||
&format!(
|
||||
"sync/receipts/{}",
|
||||
receipt["receiptId"].as_str().unwrap_or("sync-receipt")
|
||||
),
|
||||
&receipt,
|
||||
)?;
|
||||
}
|
||||
report.receipts_written += 1;
|
||||
|
||||
Ok(report)
|
||||
}
|
||||
|
||||
struct MirrorStore {
|
||||
store: SingleFileMessagePackBackingStore,
|
||||
}
|
||||
|
||||
impl MirrorStore {
|
||||
fn open(path: &Path) -> Result<Self> {
|
||||
Ok(Self {
|
||||
store: SingleFileMessagePackBackingStore::new(path),
|
||||
})
|
||||
}
|
||||
|
||||
fn documents(&mut self) -> Result<Vec<CacheDocument>> {
|
||||
let mut documents = Vec::new();
|
||||
for envelope in self.store.pull_all()? {
|
||||
let value = decode_payload(&envelope).with_context(|| {
|
||||
format!("failed to decode {} at {}", envelope.r#type, envelope.key)
|
||||
})?;
|
||||
documents.push(CacheDocument {
|
||||
key: envelope.key,
|
||||
value,
|
||||
});
|
||||
}
|
||||
Ok(documents)
|
||||
}
|
||||
|
||||
fn put_json_document(&mut self, schema: &str, key: &str, value: &Value) -> Result<()> {
|
||||
let payload = serde_json::to_vec(value)?;
|
||||
self.store.push(&CultCacheEnvelope {
|
||||
key: key.to_string(),
|
||||
r#type: schema.to_string(),
|
||||
payload,
|
||||
stored_at: chrono_like_now(),
|
||||
schema_id: Some(schema.to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
fn put_messagepack_document(&mut self, schema: &str, key: &str, value: &Value) -> Result<()> {
|
||||
let payload = rmp_serde::to_vec(value)?;
|
||||
self.store.push(&CultCacheEnvelope {
|
||||
key: key.to_string(),
|
||||
r#type: schema.to_string(),
|
||||
payload,
|
||||
stored_at: chrono_like_now(),
|
||||
schema_id: Some(schema.to_string()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn decode_payload(envelope: &CultCacheEnvelope) -> Result<Value> {
|
||||
serde_json::from_slice(&envelope.payload)
|
||||
.or_else(|_| rmp_serde::from_slice(&envelope.payload))
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"payload is neither MessagePack nor JSON for {}",
|
||||
envelope.key
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_object_binding(value: &Value) -> Option<ObjectBinding> {
|
||||
Some(ObjectBinding {
|
||||
binding_id: field_string(value, 1, "bindingId")?,
|
||||
session_id: field_string(value, 2, "sessionId").unwrap_or_else(|| "default".to_string()),
|
||||
display_name: field_string(value, 3, "displayName").unwrap_or_default(),
|
||||
unity_object_id: field_string(value, 4, "unityObjectId").unwrap_or_default(),
|
||||
unity_path: field_string(value, 5, "unityPath").unwrap_or_default(),
|
||||
blender_object_name: field_string(value, 6, "blenderObjectName").unwrap_or_default(),
|
||||
enabled: field_bool(value, 8, "enabled").unwrap_or(true),
|
||||
authority: field_string(value, 9, "authority")
|
||||
.unwrap_or_else(|| "unity-to-blender".to_string()),
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_sync_var(value: &Value) -> Option<SyncVarBinding> {
|
||||
Some(SyncVarBinding {
|
||||
sync_var_id: field_string(value, 1, "syncVarId")?,
|
||||
session_id: field_string(value, 2, "sessionId").unwrap_or_else(|| "default".to_string()),
|
||||
binding_id: field_string(value, 3, "bindingId")?,
|
||||
kind: field_string(value, 5, "kind")?,
|
||||
unity_property_path: field_string(value, 6, "unityPropertyPath").unwrap_or_default(),
|
||||
blender_property_path: field_string(value, 7, "blenderPropertyPath").unwrap_or_default(),
|
||||
authority: field_string(value, 8, "authority").unwrap_or_default(),
|
||||
enabled: field_bool(value, 9, "enabled").unwrap_or(true),
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_timeline_binding(value: &Value) -> Option<TimelineBinding> {
|
||||
Some(TimelineBinding {
|
||||
binding_id: field_string(value, 1, "bindingId")?,
|
||||
session_id: field_string(value, 2, "sessionId").unwrap_or_else(|| "default".to_string()),
|
||||
unity_timeline_object_id: field_string(value, 4, "unityTimelineObjectId")
|
||||
.unwrap_or_default(),
|
||||
unity_cinemachine_object_id: field_string(value, 5, "unityCinemachineObjectId")
|
||||
.unwrap_or_default(),
|
||||
blender_scene_name: field_string(value, 6, "blenderSceneName").unwrap_or_default(),
|
||||
blender_action_name: field_string(value, 7, "blenderActionName").unwrap_or_default(),
|
||||
clock_authority: field_string(value, 8, "clockAuthority")
|
||||
.unwrap_or_else(|| "blender".to_string()),
|
||||
frame_rate: field_f64(value, 9, "frameRate").unwrap_or(24.0),
|
||||
sync_frame: field_bool(value, 10, "syncFrame").unwrap_or(false),
|
||||
sync_camera: field_bool(value, 11, "syncCamera").unwrap_or(false),
|
||||
enabled: field_bool(value, 12, "enabled").unwrap_or(true),
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_unity_objects(documents: &[CacheDocument]) -> Vec<UnityObject> {
|
||||
let Some(snapshot) = documents
|
||||
.iter()
|
||||
.find(|document| document.key == "unity/host/current")
|
||||
.map(|document| &document.value)
|
||||
else {
|
||||
return Vec::new();
|
||||
};
|
||||
let Some(objects) = field_array(snapshot, 12, "sceneObjects") else {
|
||||
return Vec::new();
|
||||
};
|
||||
objects
|
||||
.iter()
|
||||
.filter_map(|value| {
|
||||
Some(UnityObject {
|
||||
object_id: field_string(value, 0, "objectId")?,
|
||||
name: field_string(value, 1, "name").unwrap_or_default(),
|
||||
path: field_string(value, 2, "path").unwrap_or_default(),
|
||||
active_self: field_bool(value, 4, "activeSelf").unwrap_or(true),
|
||||
local_position: field_vec3(value, 10, "localPosition").unwrap_or_default(),
|
||||
local_euler_angles: field_vec3(value, 11, "localEulerAngles").unwrap_or_default(),
|
||||
local_scale: field_vec3(value, 12, "localScale")
|
||||
.unwrap_or_else(|| vec![1.0, 1.0, 1.0]),
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn parse_blender_objects(documents: &[CacheDocument]) -> BTreeMap<String, BlenderObject> {
|
||||
let Some(snapshot) = documents
|
||||
.iter()
|
||||
.find(|document| document.key == "blender/host/current")
|
||||
.map(|document| &document.value)
|
||||
else {
|
||||
return BTreeMap::new();
|
||||
};
|
||||
let Some(objects) = field_array(snapshot, 17, "objects") else {
|
||||
return BTreeMap::new();
|
||||
};
|
||||
objects
|
||||
.iter()
|
||||
.filter_map(|value| {
|
||||
let name = field_string(value, 0, "name")?;
|
||||
Some((
|
||||
name.clone(),
|
||||
BlenderObject {
|
||||
name,
|
||||
location: field_vec3(value, 4, "location").unwrap_or_default(),
|
||||
rotation_euler: field_vec3(value, 5, "rotationEuler").unwrap_or_default(),
|
||||
scale: field_vec3(value, 6, "scale").unwrap_or_else(|| vec![1.0, 1.0, 1.0]),
|
||||
visible: field_bool(value, 7, "visible").unwrap_or(true),
|
||||
materials: field_array(value, 10, "materials")
|
||||
.map(|items| {
|
||||
items
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.map(str::to_string)
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
},
|
||||
))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn parse_blender_timeline(documents: &[CacheDocument]) -> Vec<BlenderTimeline> {
|
||||
let Some(snapshot) = documents
|
||||
.iter()
|
||||
.find(|document| document.key == "blender/host/current")
|
||||
.map(|document| &document.value)
|
||||
else {
|
||||
return Vec::new();
|
||||
};
|
||||
let Some(scenes) = field_array(snapshot, 16, "scenes") else {
|
||||
return Vec::new();
|
||||
};
|
||||
scenes
|
||||
.iter()
|
||||
.filter_map(|value| {
|
||||
Some(BlenderTimeline {
|
||||
scene_name: field_string(value, 0, "name")?,
|
||||
frame_current: field_i64(value, 1, "frameCurrent").unwrap_or(0),
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn find_unity_object<'a>(
|
||||
objects: &'a [UnityObject],
|
||||
binding: &ObjectBinding,
|
||||
) -> Option<&'a UnityObject> {
|
||||
objects
|
||||
.iter()
|
||||
.find(|object| {
|
||||
!binding.unity_object_id.is_empty() && object.object_id == binding.unity_object_id
|
||||
})
|
||||
.or_else(|| {
|
||||
objects
|
||||
.iter()
|
||||
.find(|object| !binding.unity_path.is_empty() && object.path == binding.unity_path)
|
||||
})
|
||||
.or_else(|| {
|
||||
objects.iter().find(|object| {
|
||||
!binding.display_name.is_empty() && object.name == binding.display_name
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn unity_transform_command(
|
||||
command_id: &str,
|
||||
target_object_id: &str,
|
||||
location: &[f64],
|
||||
rotation: &[f64],
|
||||
scale: &[f64],
|
||||
) -> Value {
|
||||
json!([
|
||||
"brokkr.unity.command_intent.v0",
|
||||
command_id,
|
||||
"setGameObjectTransform",
|
||||
target_object_id,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
vec3_csv(location),
|
||||
vec3_csv(rotation),
|
||||
vec3_csv(scale)
|
||||
])
|
||||
}
|
||||
|
||||
fn unity_property_command(
|
||||
command_id: &str,
|
||||
target_object_id: &str,
|
||||
property_path: &str,
|
||||
value: &str,
|
||||
) -> Value {
|
||||
json!([
|
||||
"brokkr.unity.command_intent.v0",
|
||||
command_id,
|
||||
"setComponentProperty",
|
||||
target_object_id,
|
||||
"",
|
||||
"",
|
||||
property_path,
|
||||
value,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
])
|
||||
}
|
||||
|
||||
fn field_string(value: &Value, slot: usize, name: &str) -> Option<String> {
|
||||
value
|
||||
.get(name)
|
||||
.and_then(Value::as_str)
|
||||
.or_else(|| value.as_array()?.get(slot)?.as_str())
|
||||
.map(str::to_string)
|
||||
}
|
||||
|
||||
fn field_bool(value: &Value, slot: usize, name: &str) -> Option<bool> {
|
||||
value
|
||||
.get(name)
|
||||
.and_then(Value::as_bool)
|
||||
.or_else(|| value.as_array()?.get(slot)?.as_bool())
|
||||
}
|
||||
|
||||
fn field_f64(value: &Value, slot: usize, name: &str) -> Option<f64> {
|
||||
value
|
||||
.get(name)
|
||||
.and_then(Value::as_f64)
|
||||
.or_else(|| value.as_array()?.get(slot)?.as_f64())
|
||||
}
|
||||
|
||||
fn field_i64(value: &Value, slot: usize, name: &str) -> Option<i64> {
|
||||
value
|
||||
.get(name)
|
||||
.and_then(Value::as_i64)
|
||||
.or_else(|| value.as_array()?.get(slot)?.as_i64())
|
||||
}
|
||||
|
||||
fn field_array<'a>(value: &'a Value, slot: usize, name: &str) -> Option<&'a Vec<Value>> {
|
||||
value
|
||||
.get(name)
|
||||
.and_then(Value::as_array)
|
||||
.or_else(|| value.as_array()?.get(slot)?.as_array())
|
||||
}
|
||||
|
||||
fn field_vec3(value: &Value, slot: usize, name: &str) -> Option<Vec<f64>> {
|
||||
let raw = value.get(name).or_else(|| value.as_array()?.get(slot))?;
|
||||
if let Some(items) = raw.as_array() {
|
||||
return Some(items.iter().filter_map(Value::as_f64).take(3).collect());
|
||||
}
|
||||
raw.as_str().map(parse_vec3)
|
||||
}
|
||||
|
||||
fn parse_vec3(value: &str) -> Vec<f64> {
|
||||
value
|
||||
.trim_matches(|candidate| candidate == '(' || candidate == ')')
|
||||
.split(',')
|
||||
.filter_map(|part| part.trim().parse::<f64>().ok())
|
||||
.take(3)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn vec3_csv(values: &[f64]) -> String {
|
||||
let x = values.first().copied().unwrap_or(0.0);
|
||||
let y = values.get(1).copied().unwrap_or(0.0);
|
||||
let z = values.get(2).copied().unwrap_or(0.0);
|
||||
format!("{x},{y},{z}")
|
||||
}
|
||||
|
||||
fn stable_id<const N: usize>(parts: [&str; N]) -> String {
|
||||
parts
|
||||
.iter()
|
||||
.map(|part| part.replace([' ', '/', '\\'], "_"))
|
||||
.collect::<Vec<_>>()
|
||||
.join(":")
|
||||
}
|
||||
|
||||
fn chrono_like_now() -> String {
|
||||
let now = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default();
|
||||
format!("{}.{:09}Z", now.as_secs(), now.subsec_nanos())
|
||||
}
|
||||
|
||||
fn chrono_like_timestamp_id() -> String {
|
||||
chrono_like_now().replace(['.', ':', 'Z'], "_")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
@ -561,4 +1300,173 @@ mod tests {
|
|||
.contains(&"cinemachine-virtual-camera")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sync_once_writes_unity_transform_to_blender_command() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let unity_path = temp.path().join("unity.ccmp");
|
||||
let blender_path = temp.path().join("blender.ccmp");
|
||||
seed_sync_stores(&unity_path, &blender_path, "unity-to-blender")?;
|
||||
assert_seed_contains_sync_docs(&unity_path)?;
|
||||
|
||||
let report = run_sync_once(&SyncArgs {
|
||||
unity_cache: unity_path.clone(),
|
||||
blender_cache: blender_path.clone(),
|
||||
dry_run: false,
|
||||
})?;
|
||||
|
||||
assert_eq!(report.blender_commands_written, 1, "{report:#?}");
|
||||
let mut blender_store = MirrorStore::open(&blender_path)?;
|
||||
let command = blender_store
|
||||
.documents()?
|
||||
.into_iter()
|
||||
.find(|document| document.key.starts_with("blender/commands/"))
|
||||
.expect("Brokkr should emit a Blender command");
|
||||
|
||||
assert_eq!(command.value["action"], "setObjectTransform");
|
||||
assert_eq!(command.value["targetObjectName"], "Cube");
|
||||
assert_eq!(command.value["location"], json!([1.0, 2.0, 3.0]));
|
||||
assert_eq!(command.value["rotationEuler"], json!([4.0, 5.0, 6.0]));
|
||||
assert_eq!(command.value["scale"], json!([1.0, 1.0, 1.0]));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sync_once_writes_blender_transform_to_unity_command() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let unity_path = temp.path().join("unity.ccmp");
|
||||
let blender_path = temp.path().join("blender.ccmp");
|
||||
seed_sync_stores(&unity_path, &blender_path, "blender-to-unity")?;
|
||||
assert_seed_contains_sync_docs(&unity_path)?;
|
||||
|
||||
let report = run_sync_once(&SyncArgs {
|
||||
unity_cache: unity_path.clone(),
|
||||
blender_cache: blender_path,
|
||||
dry_run: false,
|
||||
})?;
|
||||
|
||||
assert_eq!(report.unity_commands_written, 1, "{report:#?}");
|
||||
let mut unity_store = MirrorStore::open(&unity_path)?;
|
||||
let command = unity_store
|
||||
.documents()?
|
||||
.into_iter()
|
||||
.find(|document| document.key.starts_with("unity/commands/"))
|
||||
.expect("Brokkr should emit a Unity command");
|
||||
|
||||
assert_eq!(
|
||||
command.value.as_array().and_then(|items| items.get(2)),
|
||||
Some(&json!("setGameObjectTransform"))
|
||||
);
|
||||
assert_eq!(
|
||||
command.value.as_array().and_then(|items| items.get(3)),
|
||||
Some(&json!("unity-cube"))
|
||||
);
|
||||
assert_eq!(
|
||||
command.value.as_array().and_then(|items| items.get(10)),
|
||||
Some(&json!("10,20,30"))
|
||||
);
|
||||
assert_eq!(
|
||||
command.value.as_array().and_then(|items| items.get(11)),
|
||||
Some(&json!("0.1,0.2,0.3"))
|
||||
);
|
||||
assert_eq!(
|
||||
command.value.as_array().and_then(|items| items.get(12)),
|
||||
Some(&json!("2,2,2"))
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn seed_sync_stores(unity_path: &Path, blender_path: &Path, authority: &str) -> Result<()> {
|
||||
let mut unity_store = MirrorStore::open(unity_path)?;
|
||||
let mut blender_store = MirrorStore::open(blender_path)?;
|
||||
|
||||
unity_store.put_json_document(
|
||||
"brokkr.unity.host_snapshot.v0",
|
||||
"unity/host/current",
|
||||
&json!({
|
||||
"sceneObjects": [{
|
||||
"objectId": "unity-cube",
|
||||
"name": "Cube",
|
||||
"path": "/Cube",
|
||||
"activeSelf": true,
|
||||
"localPosition": [1.0, 2.0, 3.0],
|
||||
"localEulerAngles": [4.0, 5.0, 6.0],
|
||||
"localScale": [1.0, 1.0, 1.0]
|
||||
}]
|
||||
}),
|
||||
)?;
|
||||
unity_store.put_json_document(
|
||||
"brokkr.sync.object_binding.v0",
|
||||
"sync/bindings/objects/binding-cube",
|
||||
&json!({
|
||||
"schema": "brokkr.sync.object_binding.v0",
|
||||
"bindingId": "binding-cube",
|
||||
"sessionId": "session-main",
|
||||
"displayName": "Cube",
|
||||
"unityObjectId": "unity-cube",
|
||||
"unityPath": "/Cube",
|
||||
"blenderObjectName": "Cube",
|
||||
"enabled": true,
|
||||
"authority": authority
|
||||
}),
|
||||
)?;
|
||||
unity_store.put_json_document(
|
||||
"brokkr.sync.var.v0",
|
||||
"sync/vars/var-cube-transform",
|
||||
&json!({
|
||||
"schema": "brokkr.sync.var.v0",
|
||||
"syncVarId": "var-cube-transform",
|
||||
"sessionId": "session-main",
|
||||
"bindingId": "binding-cube",
|
||||
"displayName": "Transform",
|
||||
"kind": "transform",
|
||||
"unityPropertyPath": "Transform",
|
||||
"blenderPropertyPath": "location,rotationEuler,scale",
|
||||
"authority": authority,
|
||||
"enabled": true
|
||||
}),
|
||||
)?;
|
||||
|
||||
blender_store.put_json_document(
|
||||
"brokkr.blender.host_snapshot.v0",
|
||||
"blender/host/current",
|
||||
&json!({
|
||||
"objects": [{
|
||||
"name": "Cube",
|
||||
"location": [10.0, 20.0, 30.0],
|
||||
"rotationEuler": [0.1, 0.2, 0.3],
|
||||
"scale": [2.0, 2.0, 2.0],
|
||||
"visible": true,
|
||||
"materials": ["Mat"]
|
||||
}],
|
||||
"scenes": [{
|
||||
"name": "Scene",
|
||||
"frameCurrent": 48
|
||||
}]
|
||||
}),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn assert_seed_contains_sync_docs(unity_path: &Path) -> Result<()> {
|
||||
let mut unity_store = MirrorStore::open(unity_path)?;
|
||||
let keys: Vec<_> = unity_store
|
||||
.documents()?
|
||||
.into_iter()
|
||||
.map(|document| document.key)
|
||||
.collect();
|
||||
assert!(
|
||||
keys.iter()
|
||||
.any(|key| key == "sync/bindings/objects/binding-cube"),
|
||||
"{keys:#?}"
|
||||
);
|
||||
assert!(
|
||||
keys.iter().any(|key| key == "sync/vars/var-cube-transform"),
|
||||
"{keys:#?}"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ All Unity writes use `brokkr.unity.command_intent.v0` and receive
|
|||
|
||||
- `createGameObject`
|
||||
- `attachComponent`
|
||||
- `setGameObjectTransform`
|
||||
- `setComponentProperty`
|
||||
- `instantiatePrefab`
|
||||
- `createPrefabVariant`
|
||||
|
|
|
|||
|
|
@ -327,6 +327,8 @@ class BrokkrBlenderTarget:
|
|||
return self._delete_object(context, command)
|
||||
if action == "setObjectTransform":
|
||||
return self._set_object_transform(context, command)
|
||||
if action == "setObjectVisibility":
|
||||
return self._set_object_visibility(context, command)
|
||||
if action == "selectObject":
|
||||
return self._select_object(context, command)
|
||||
if action == "assignMaterial":
|
||||
|
|
@ -374,6 +376,16 @@ class BrokkrBlenderTarget:
|
|||
|
||||
return self._receipt(command, "accepted", "Blender object transform updated.", obj.name)
|
||||
|
||||
def _set_object_visibility(self, context: Any, command: dict[str, Any]) -> dict[str, Any]:
|
||||
obj = self._resolve_object(command)
|
||||
if obj is None:
|
||||
return self._receipt(command, "failed", "Target Blender object was not found.", "")
|
||||
|
||||
visible = bool(command.get("visible", True))
|
||||
obj.hide_viewport = not visible
|
||||
obj.hide_render = not visible
|
||||
return self._receipt(command, "accepted", "Blender object visibility updated.", obj.name)
|
||||
|
||||
def _select_object(self, context: Any, command: dict[str, Any]) -> dict[str, Any]:
|
||||
obj = self._resolve_object(command)
|
||||
if obj is None:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ namespace GameCult.Brokkr.Editor
|
|||
{
|
||||
"createGameObject" => CreateGameObject(command),
|
||||
"attachComponent" => AttachComponent(command),
|
||||
"setGameObjectTransform" => SetGameObjectTransform(command),
|
||||
"setComponentProperty" => SetComponentProperty(command),
|
||||
"instantiatePrefab" => InstantiatePrefab(command),
|
||||
"createPrefabVariant" => CreatePrefabVariant(command),
|
||||
|
|
@ -89,6 +90,49 @@ namespace GameCult.Brokkr.Editor
|
|||
return Accepted(command, "Serialized property updated.", command.targetObjectId);
|
||||
}
|
||||
|
||||
private static BrokkrUnityCommandReceipt SetGameObjectTransform(BrokkrUnityCommand command)
|
||||
{
|
||||
var gameObject = ResolveGameObject(command.targetObjectId);
|
||||
if (gameObject == null)
|
||||
{
|
||||
return Failed(command, "Target GameObject was not found.");
|
||||
}
|
||||
|
||||
Undo.RecordObject(gameObject.transform, "Brokkr Set GameObject Transform");
|
||||
if (!string.IsNullOrWhiteSpace(command.localPosition))
|
||||
{
|
||||
if (!TryParseVector3(command.localPosition, out var localPosition))
|
||||
{
|
||||
return Failed(command, $"Expected localPosition as x,y,z: {command.localPosition}");
|
||||
}
|
||||
|
||||
gameObject.transform.localPosition = localPosition;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.localEulerAngles))
|
||||
{
|
||||
if (!TryParseVector3(command.localEulerAngles, out var localEulerAngles))
|
||||
{
|
||||
return Failed(command, $"Expected localEulerAngles as x,y,z: {command.localEulerAngles}");
|
||||
}
|
||||
|
||||
gameObject.transform.localEulerAngles = localEulerAngles;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.localScale))
|
||||
{
|
||||
if (!TryParseVector3(command.localScale, out var localScale))
|
||||
{
|
||||
return Failed(command, $"Expected localScale as x,y,z: {command.localScale}");
|
||||
}
|
||||
|
||||
gameObject.transform.localScale = localScale;
|
||||
}
|
||||
|
||||
EditorSceneManager.MarkSceneDirty(gameObject.scene);
|
||||
return Accepted(command, "GameObject transform updated.", command.targetObjectId);
|
||||
}
|
||||
|
||||
private static BrokkrUnityCommandReceipt InstantiatePrefab(BrokkrUnityCommand command)
|
||||
{
|
||||
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(command.assetPath);
|
||||
|
|
@ -209,6 +253,26 @@ namespace GameCult.Brokkr.Editor
|
|||
}
|
||||
}
|
||||
|
||||
private static bool TryParseVector3(string value, out Vector3 vector)
|
||||
{
|
||||
vector = default;
|
||||
var parts = value.Split(',');
|
||||
if (parts.Length != 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!float.TryParse(parts[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var x) ||
|
||||
!float.TryParse(parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var y) ||
|
||||
!float.TryParse(parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var z))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
vector = new Vector3(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static BrokkrUnityCommandReceipt Accepted(BrokkrUnityCommand command, string message, string objectId)
|
||||
{
|
||||
return Receipt(command, "accepted", message, objectId);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,10 @@ namespace GameCult.Brokkr.Editor
|
|||
layer = gameObject.layer,
|
||||
childCount = gameObject.transform.childCount,
|
||||
parentId = parentId,
|
||||
components = CaptureComponents(gameObject)
|
||||
components = CaptureComponents(gameObject),
|
||||
localPosition = WriteVector3(gameObject.transform.localPosition),
|
||||
localEulerAngles = WriteVector3(gameObject.transform.localEulerAngles),
|
||||
localScale = WriteVector3(gameObject.transform.localScale)
|
||||
});
|
||||
|
||||
for (var childIndex = 0; childIndex < gameObject.transform.childCount; childIndex++)
|
||||
|
|
@ -234,5 +237,14 @@ namespace GameCult.Brokkr.Editor
|
|||
_ => ""
|
||||
};
|
||||
}
|
||||
|
||||
private static string WriteVector3(Vector3 value)
|
||||
{
|
||||
return string.Join(
|
||||
",",
|
||||
value.x.ToString(CultureInfo.InvariantCulture),
|
||||
value.y.ToString(CultureInfo.InvariantCulture),
|
||||
value.z.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ namespace GameCult.Brokkr
|
|||
[Key(7)] public int childCount;
|
||||
[Key(8)] public string parentId = "";
|
||||
[Key(9)] public BrokkrComponentSnapshot[] components = Array.Empty<BrokkrComponentSnapshot>();
|
||||
[Key(10)] public string localPosition = "";
|
||||
[Key(11)] public string localEulerAngles = "";
|
||||
[Key(12)] public string localScale = "";
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -100,6 +103,9 @@ namespace GameCult.Brokkr
|
|||
[Key(7)] public string value = "";
|
||||
[Key(8)] public string assetPath = "";
|
||||
[Key(9)] public string parentObjectId = "";
|
||||
[Key(10)] public string localPosition = "";
|
||||
[Key(11)] public string localEulerAngles = "";
|
||||
[Key(12)] public string localScale = "";
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
Loading…
Reference in a new issue