@bloomengine/engine 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/native/ios/Cargo.lock +63 -61
- package/native/ios/Cargo.toml +1 -0
- package/native/ios/src/lib.rs +600 -1
- package/package.json +1 -1
package/native/ios/Cargo.lock
CHANGED
|
@@ -40,9 +40,9 @@ dependencies = [
|
|
|
40
40
|
|
|
41
41
|
[[package]]
|
|
42
42
|
name = "autocfg"
|
|
43
|
-
version = "1.5.
|
|
43
|
+
version = "1.5.1"
|
|
44
44
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
-
checksum = "
|
|
45
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
46
46
|
|
|
47
47
|
[[package]]
|
|
48
48
|
name = "base64"
|
|
@@ -73,9 +73,9 @@ checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51"
|
|
|
73
73
|
|
|
74
74
|
[[package]]
|
|
75
75
|
name = "bitflags"
|
|
76
|
-
version = "2.
|
|
76
|
+
version = "2.12.1"
|
|
77
77
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
78
|
-
checksum = "
|
|
78
|
+
checksum = "84d7ced0ae9557296835c32bf1b1e02b44c746701f898460fb000d7eaa84f00a"
|
|
79
79
|
|
|
80
80
|
[[package]]
|
|
81
81
|
name = "block2"
|
|
@@ -91,6 +91,7 @@ name = "bloom-ios"
|
|
|
91
91
|
version = "0.1.0"
|
|
92
92
|
dependencies = [
|
|
93
93
|
"bloom-shared",
|
|
94
|
+
"image",
|
|
94
95
|
"objc2",
|
|
95
96
|
"objc2-foundation",
|
|
96
97
|
"raw-window-handle",
|
|
@@ -118,9 +119,9 @@ dependencies = [
|
|
|
118
119
|
|
|
119
120
|
[[package]]
|
|
120
121
|
name = "bumpalo"
|
|
121
|
-
version = "3.20.
|
|
122
|
+
version = "3.20.3"
|
|
122
123
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
123
|
-
checksum = "
|
|
124
|
+
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
|
124
125
|
|
|
125
126
|
[[package]]
|
|
126
127
|
name = "bytemuck"
|
|
@@ -156,9 +157,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
|
|
156
157
|
|
|
157
158
|
[[package]]
|
|
158
159
|
name = "cc"
|
|
159
|
-
version = "1.2.
|
|
160
|
+
version = "1.2.63"
|
|
160
161
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
161
|
-
checksum = "
|
|
162
|
+
checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f"
|
|
162
163
|
dependencies = [
|
|
163
164
|
"find-msvc-tools",
|
|
164
165
|
"shlex",
|
|
@@ -263,9 +264,9 @@ dependencies = [
|
|
|
263
264
|
|
|
264
265
|
[[package]]
|
|
265
266
|
name = "either"
|
|
266
|
-
version = "1.
|
|
267
|
+
version = "1.16.0"
|
|
267
268
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
268
|
-
checksum = "
|
|
269
|
+
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
|
269
270
|
|
|
270
271
|
[[package]]
|
|
271
272
|
name = "enum-primitive-derive"
|
|
@@ -497,9 +498,9 @@ dependencies = [
|
|
|
497
498
|
|
|
498
499
|
[[package]]
|
|
499
500
|
name = "hashbrown"
|
|
500
|
-
version = "0.17.
|
|
501
|
+
version = "0.17.1"
|
|
501
502
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
502
|
-
checksum = "
|
|
503
|
+
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
|
503
504
|
|
|
504
505
|
[[package]]
|
|
505
506
|
name = "hexf-parse"
|
|
@@ -543,7 +544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
543
544
|
checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9"
|
|
544
545
|
dependencies = [
|
|
545
546
|
"equivalent",
|
|
546
|
-
"hashbrown 0.17.
|
|
547
|
+
"hashbrown 0.17.1",
|
|
547
548
|
]
|
|
548
549
|
|
|
549
550
|
[[package]]
|
|
@@ -597,9 +598,9 @@ dependencies = [
|
|
|
597
598
|
|
|
598
599
|
[[package]]
|
|
599
600
|
name = "js-sys"
|
|
600
|
-
version = "0.3.
|
|
601
|
+
version = "0.3.99"
|
|
601
602
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
602
|
-
checksum = "
|
|
603
|
+
checksum = "142bc4740e452c1e57ade0cbc129f139c9093e354346f0872ef985f4f5cf5f11"
|
|
603
604
|
dependencies = [
|
|
604
605
|
"cfg-if",
|
|
605
606
|
"futures-util",
|
|
@@ -643,9 +644,9 @@ dependencies = [
|
|
|
643
644
|
|
|
644
645
|
[[package]]
|
|
645
646
|
name = "libc"
|
|
646
|
-
version = "0.2.
|
|
647
|
+
version = "0.2.186"
|
|
647
648
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
648
|
-
checksum = "
|
|
649
|
+
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
|
649
650
|
|
|
650
651
|
[[package]]
|
|
651
652
|
name = "libloading"
|
|
@@ -680,9 +681,9 @@ dependencies = [
|
|
|
680
681
|
|
|
681
682
|
[[package]]
|
|
682
683
|
name = "log"
|
|
683
|
-
version = "0.4.
|
|
684
|
+
version = "0.4.32"
|
|
684
685
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
685
|
-
checksum = "
|
|
686
|
+
checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a"
|
|
686
687
|
|
|
687
688
|
[[package]]
|
|
688
689
|
name = "mach2"
|
|
@@ -695,9 +696,9 @@ dependencies = [
|
|
|
695
696
|
|
|
696
697
|
[[package]]
|
|
697
698
|
name = "memchr"
|
|
698
|
-
version = "2.8.
|
|
699
|
+
version = "2.8.1"
|
|
699
700
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
700
|
-
checksum = "
|
|
701
|
+
checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8"
|
|
701
702
|
|
|
702
703
|
[[package]]
|
|
703
704
|
name = "minimp3"
|
|
@@ -741,9 +742,9 @@ dependencies = [
|
|
|
741
742
|
|
|
742
743
|
[[package]]
|
|
743
744
|
name = "naga"
|
|
744
|
-
version = "29.0.
|
|
745
|
+
version = "29.0.3"
|
|
745
746
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
746
|
-
checksum = "
|
|
747
|
+
checksum = "0dd91265cc2454558f659b3b4b9640f0ddb8cc6521277f166b8a8c181c898079"
|
|
747
748
|
dependencies = [
|
|
748
749
|
"arrayvec",
|
|
749
750
|
"bit-set",
|
|
@@ -952,9 +953,9 @@ dependencies = [
|
|
|
952
953
|
|
|
953
954
|
[[package]]
|
|
954
955
|
name = "profiling"
|
|
955
|
-
version = "1.0.
|
|
956
|
+
version = "1.0.18"
|
|
956
957
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
957
|
-
checksum = "
|
|
958
|
+
checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5"
|
|
958
959
|
|
|
959
960
|
[[package]]
|
|
960
961
|
name = "pxfm"
|
|
@@ -1060,9 +1061,9 @@ dependencies = [
|
|
|
1060
1061
|
|
|
1061
1062
|
[[package]]
|
|
1062
1063
|
name = "serde_json"
|
|
1063
|
-
version = "1.0.
|
|
1064
|
+
version = "1.0.150"
|
|
1064
1065
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1065
|
-
checksum = "
|
|
1066
|
+
checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9"
|
|
1066
1067
|
dependencies = [
|
|
1067
1068
|
"itoa",
|
|
1068
1069
|
"memchr",
|
|
@@ -1073,9 +1074,9 @@ dependencies = [
|
|
|
1073
1074
|
|
|
1074
1075
|
[[package]]
|
|
1075
1076
|
name = "shlex"
|
|
1076
|
-
version = "
|
|
1077
|
+
version = "2.0.1"
|
|
1077
1078
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1078
|
-
checksum = "
|
|
1079
|
+
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
1079
1080
|
|
|
1080
1081
|
[[package]]
|
|
1081
1082
|
name = "simd-adler32"
|
|
@@ -1248,9 +1249,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
|
1248
1249
|
|
|
1249
1250
|
[[package]]
|
|
1250
1251
|
name = "wasm-bindgen"
|
|
1251
|
-
version = "0.2.
|
|
1252
|
+
version = "0.2.122"
|
|
1252
1253
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1253
|
-
checksum = "
|
|
1254
|
+
checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409"
|
|
1254
1255
|
dependencies = [
|
|
1255
1256
|
"cfg-if",
|
|
1256
1257
|
"once_cell",
|
|
@@ -1261,9 +1262,9 @@ dependencies = [
|
|
|
1261
1262
|
|
|
1262
1263
|
[[package]]
|
|
1263
1264
|
name = "wasm-bindgen-futures"
|
|
1264
|
-
version = "0.4.
|
|
1265
|
+
version = "0.4.72"
|
|
1265
1266
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1266
|
-
checksum = "
|
|
1267
|
+
checksum = "9473dbd2991ae90b6291c3c32c30c6187ac49aa32f9905d1cce280ec1e110b0f"
|
|
1267
1268
|
dependencies = [
|
|
1268
1269
|
"js-sys",
|
|
1269
1270
|
"wasm-bindgen",
|
|
@@ -1271,9 +1272,9 @@ dependencies = [
|
|
|
1271
1272
|
|
|
1272
1273
|
[[package]]
|
|
1273
1274
|
name = "wasm-bindgen-macro"
|
|
1274
|
-
version = "0.2.
|
|
1275
|
+
version = "0.2.122"
|
|
1275
1276
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1276
|
-
checksum = "
|
|
1277
|
+
checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6"
|
|
1277
1278
|
dependencies = [
|
|
1278
1279
|
"quote",
|
|
1279
1280
|
"wasm-bindgen-macro-support",
|
|
@@ -1281,9 +1282,9 @@ dependencies = [
|
|
|
1281
1282
|
|
|
1282
1283
|
[[package]]
|
|
1283
1284
|
name = "wasm-bindgen-macro-support"
|
|
1284
|
-
version = "0.2.
|
|
1285
|
+
version = "0.2.122"
|
|
1285
1286
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1286
|
-
checksum = "
|
|
1287
|
+
checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e"
|
|
1287
1288
|
dependencies = [
|
|
1288
1289
|
"bumpalo",
|
|
1289
1290
|
"proc-macro2",
|
|
@@ -1294,9 +1295,9 @@ dependencies = [
|
|
|
1294
1295
|
|
|
1295
1296
|
[[package]]
|
|
1296
1297
|
name = "wasm-bindgen-shared"
|
|
1297
|
-
version = "0.2.
|
|
1298
|
+
version = "0.2.122"
|
|
1298
1299
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1299
|
-
checksum = "
|
|
1300
|
+
checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437"
|
|
1300
1301
|
dependencies = [
|
|
1301
1302
|
"unicode-ident",
|
|
1302
1303
|
]
|
|
@@ -1315,9 +1316,9 @@ dependencies = [
|
|
|
1315
1316
|
|
|
1316
1317
|
[[package]]
|
|
1317
1318
|
name = "web-sys"
|
|
1318
|
-
version = "0.3.
|
|
1319
|
+
version = "0.3.99"
|
|
1319
1320
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1320
|
-
checksum = "
|
|
1321
|
+
checksum = "6d621441cfc37b84979402712047321980c178f299193a3589d05b99e8763436"
|
|
1321
1322
|
dependencies = [
|
|
1322
1323
|
"js-sys",
|
|
1323
1324
|
"wasm-bindgen",
|
|
@@ -1325,9 +1326,9 @@ dependencies = [
|
|
|
1325
1326
|
|
|
1326
1327
|
[[package]]
|
|
1327
1328
|
name = "wgpu"
|
|
1328
|
-
version = "29.0.
|
|
1329
|
+
version = "29.0.3"
|
|
1329
1330
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1330
|
-
checksum = "
|
|
1331
|
+
checksum = "bb3feacc458f7bee8bc1737149b42b6c731aa461039a4264a67bb6681646b250"
|
|
1331
1332
|
dependencies = [
|
|
1332
1333
|
"arrayvec",
|
|
1333
1334
|
"bitflags",
|
|
@@ -1355,9 +1356,9 @@ dependencies = [
|
|
|
1355
1356
|
|
|
1356
1357
|
[[package]]
|
|
1357
1358
|
name = "wgpu-core"
|
|
1358
|
-
version = "29.0.
|
|
1359
|
+
version = "29.0.3"
|
|
1359
1360
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1360
|
-
checksum = "
|
|
1361
|
+
checksum = "02da3ad1b568337f25513b317870960ef87073ea0945502e44b864b67a8c77b7"
|
|
1361
1362
|
dependencies = [
|
|
1362
1363
|
"arrayvec",
|
|
1363
1364
|
"bit-set",
|
|
@@ -1388,36 +1389,36 @@ dependencies = [
|
|
|
1388
1389
|
|
|
1389
1390
|
[[package]]
|
|
1390
1391
|
name = "wgpu-core-deps-apple"
|
|
1391
|
-
version = "29.0.
|
|
1392
|
+
version = "29.0.3"
|
|
1392
1393
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1393
|
-
checksum = "
|
|
1394
|
+
checksum = "62e51b5447e144b3dbba4feb01f80f4fa21696fa0cd99afb2c3df1affd6fdb28"
|
|
1394
1395
|
dependencies = [
|
|
1395
1396
|
"wgpu-hal",
|
|
1396
1397
|
]
|
|
1397
1398
|
|
|
1398
1399
|
[[package]]
|
|
1399
1400
|
name = "wgpu-core-deps-emscripten"
|
|
1400
|
-
version = "29.0.
|
|
1401
|
+
version = "29.0.3"
|
|
1401
1402
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1402
|
-
checksum = "
|
|
1403
|
+
checksum = "3487cd6293a963bc5c0c0396f6a2192043c50003c07f4efdccbad3d90ec9d819"
|
|
1403
1404
|
dependencies = [
|
|
1404
1405
|
"wgpu-hal",
|
|
1405
1406
|
]
|
|
1406
1407
|
|
|
1407
1408
|
[[package]]
|
|
1408
1409
|
name = "wgpu-core-deps-windows-linux-android"
|
|
1409
|
-
version = "29.0.
|
|
1410
|
+
version = "29.0.3"
|
|
1410
1411
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1411
|
-
checksum = "
|
|
1412
|
+
checksum = "1bfb01076d0aa08b0ba9bd741e178b5cc440f5abe99d9581323a4c8b5d1a1916"
|
|
1412
1413
|
dependencies = [
|
|
1413
1414
|
"wgpu-hal",
|
|
1414
1415
|
]
|
|
1415
1416
|
|
|
1416
1417
|
[[package]]
|
|
1417
1418
|
name = "wgpu-hal"
|
|
1418
|
-
version = "29.0.
|
|
1419
|
+
version = "29.0.3"
|
|
1419
1420
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1420
|
-
checksum = "
|
|
1421
|
+
checksum = "31f8e1a9e7a8512f276f7c62e018c7fa8d60954303fed2e5750114332049193f"
|
|
1421
1422
|
dependencies = [
|
|
1422
1423
|
"android_system_properties",
|
|
1423
1424
|
"arrayvec",
|
|
@@ -1464,13 +1465,14 @@ dependencies = [
|
|
|
1464
1465
|
"wgpu-types",
|
|
1465
1466
|
"windows",
|
|
1466
1467
|
"windows-core",
|
|
1468
|
+
"windows-result",
|
|
1467
1469
|
]
|
|
1468
1470
|
|
|
1469
1471
|
[[package]]
|
|
1470
1472
|
name = "wgpu-naga-bridge"
|
|
1471
|
-
version = "29.0.
|
|
1473
|
+
version = "29.0.3"
|
|
1472
1474
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1473
|
-
checksum = "
|
|
1475
|
+
checksum = "59c654c483f058800972c3645e95388a7eca31bf9fe1933bc20e036588a0be02"
|
|
1474
1476
|
dependencies = [
|
|
1475
1477
|
"naga",
|
|
1476
1478
|
"wgpu-types",
|
|
@@ -1478,9 +1480,9 @@ dependencies = [
|
|
|
1478
1480
|
|
|
1479
1481
|
[[package]]
|
|
1480
1482
|
name = "wgpu-types"
|
|
1481
|
-
version = "29.0.
|
|
1483
|
+
version = "29.0.3"
|
|
1482
1484
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1483
|
-
checksum = "
|
|
1485
|
+
checksum = "a9bcc31518a0e9735aefebedb5f7a9ef3ed1c42549c9f4c882fa9060ceaac639"
|
|
1484
1486
|
dependencies = [
|
|
1485
1487
|
"bitflags",
|
|
1486
1488
|
"bytemuck",
|
|
@@ -1648,18 +1650,18 @@ checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f"
|
|
|
1648
1650
|
|
|
1649
1651
|
[[package]]
|
|
1650
1652
|
name = "zerocopy"
|
|
1651
|
-
version = "0.8.
|
|
1653
|
+
version = "0.8.50"
|
|
1652
1654
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1653
|
-
checksum = "
|
|
1655
|
+
checksum = "3b065d4f0e55f82fae73202e189638116a87c55ab6b8e6c2721e13dd9d854ad1"
|
|
1654
1656
|
dependencies = [
|
|
1655
1657
|
"zerocopy-derive",
|
|
1656
1658
|
]
|
|
1657
1659
|
|
|
1658
1660
|
[[package]]
|
|
1659
1661
|
name = "zerocopy-derive"
|
|
1660
|
-
version = "0.8.
|
|
1662
|
+
version = "0.8.50"
|
|
1661
1663
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1662
|
-
checksum = "
|
|
1664
|
+
checksum = "0b631b19d36a892ab55420c92dbc83ccd79274f25be714855d3074aa71cab639"
|
|
1663
1665
|
dependencies = [
|
|
1664
1666
|
"proc-macro2",
|
|
1665
1667
|
"quote",
|
package/native/ios/Cargo.toml
CHANGED
|
@@ -20,6 +20,7 @@ jolt = ["bloom-shared/jolt"]
|
|
|
20
20
|
panic = "abort"
|
|
21
21
|
|
|
22
22
|
[dependencies]
|
|
23
|
+
image = { version = "0.25", default-features = false, features = ["hdr"] }
|
|
23
24
|
bloom-shared = { path = "../shared", default-features = false, features = ["mp3"] }
|
|
24
25
|
objc2 = "0.6"
|
|
25
26
|
objc2-foundation = { version = "0.3", features = ["NSDate", "NSRunLoop", "NSString", "NSThread", "NSObject"] }
|
package/native/ios/src/lib.rs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
use bloom_shared::engine::EngineState;
|
|
2
2
|
use bloom_shared::renderer::Renderer;
|
|
3
|
-
use bloom_shared::string_header::str_from_header;
|
|
3
|
+
use bloom_shared::string_header::{str_from_header, alloc_perry_string};
|
|
4
4
|
use bloom_shared::audio::{parse_wav, parse_ogg, parse_mp3, SoundData};
|
|
5
5
|
|
|
6
6
|
use objc2::encode::{Encode, Encoding, RefEncode};
|
|
@@ -2256,3 +2256,602 @@ fn bloom_jolt_ffi_physics() -> &'static mut bloom_shared::physics_jolt::JoltPhys
|
|
|
2256
2256
|
|
|
2257
2257
|
#[cfg(feature = "jolt")]
|
|
2258
2258
|
bloom_shared::define_physics_ffi!();
|
|
2259
|
+
|
|
2260
|
+
// ---- FFI parity port from macos (iOS crate drift fix) ----
|
|
2261
|
+
#[no_mangle]
|
|
2262
|
+
pub extern "C" fn bloom_take_screenshot(path_ptr: *const u8) {
|
|
2263
|
+
let path = str_from_header(path_ptr).to_string();
|
|
2264
|
+
let eng = engine();
|
|
2265
|
+
eng.renderer.screenshot_requested = true;
|
|
2266
|
+
eng.renderer.pending_screenshot_path = Some(path);
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
#[no_mangle]
|
|
2270
|
+
pub extern "C" fn bloom_set_env_clear_from_hdr(path_ptr: *const u8) {
|
|
2271
|
+
use image::ImageDecoder;
|
|
2272
|
+
let path = str_from_header(path_ptr).to_string();
|
|
2273
|
+
let file = match std::fs::File::open(&path) {
|
|
2274
|
+
Ok(f) => f,
|
|
2275
|
+
Err(_) => return,
|
|
2276
|
+
};
|
|
2277
|
+
let decoder = match image::codecs::hdr::HdrDecoder::new(std::io::BufReader::new(file)) {
|
|
2278
|
+
Ok(d) => d,
|
|
2279
|
+
Err(_) => return,
|
|
2280
|
+
};
|
|
2281
|
+
let (w, h) = decoder.dimensions();
|
|
2282
|
+
let byte_len = (w as usize) * (h as usize) * 3 * 4;
|
|
2283
|
+
let mut buf = vec![0u8; byte_len];
|
|
2284
|
+
if decoder.read_image(&mut buf).is_err() {
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
// Reinterpret the byte buffer as f32 RGB triples for the renderer.
|
|
2288
|
+
let rgb_f32: Vec<f32> = buf
|
|
2289
|
+
.chunks_exact(4)
|
|
2290
|
+
.map(|c| f32::from_le_bytes([c[0], c[1], c[2], c[3]]))
|
|
2291
|
+
.collect();
|
|
2292
|
+
engine().renderer.load_env_from_hdr(w, h, &rgb_f32);
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
#[no_mangle]
|
|
2296
|
+
pub extern "C" fn bloom_set_fog(r: f64, g: f64, b: f64, density: f64, height_ref: f64, height_falloff: f64) {
|
|
2297
|
+
let r_ = engine();
|
|
2298
|
+
r_.renderer.set_fog_color(r as f32, g as f32, b as f32);
|
|
2299
|
+
r_.renderer.set_fog_density(density as f32);
|
|
2300
|
+
r_.renderer.set_fog_height_falloff(height_ref as f32, height_falloff as f32);
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
#[no_mangle]
|
|
2304
|
+
pub extern "C" fn bloom_set_chromatic_aberration(strength: f64) {
|
|
2305
|
+
engine().renderer.set_chromatic_aberration(strength as f32);
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
#[no_mangle]
|
|
2309
|
+
pub extern "C" fn bloom_set_vignette(strength: f64, softness: f64) {
|
|
2310
|
+
engine().renderer.set_vignette(strength as f32, softness as f32);
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
#[no_mangle]
|
|
2314
|
+
pub extern "C" fn bloom_set_film_grain(strength: f64) {
|
|
2315
|
+
engine().renderer.set_film_grain(strength as f32);
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
#[no_mangle]
|
|
2319
|
+
pub extern "C" fn bloom_set_sun_shafts(strength: f64, decay: f64, r: f64, g: f64, b: f64) {
|
|
2320
|
+
let eng = engine();
|
|
2321
|
+
eng.renderer.set_sun_shaft_strength(strength as f32);
|
|
2322
|
+
eng.renderer.set_sun_shaft_decay(decay as f32);
|
|
2323
|
+
eng.renderer.set_sun_shaft_color(r as f32, g as f32, b as f32);
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
#[no_mangle]
|
|
2327
|
+
pub extern "C" fn bloom_set_auto_exposure(on: f64) {
|
|
2328
|
+
engine().renderer.set_auto_exposure(on != 0.0);
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
#[no_mangle]
|
|
2332
|
+
pub extern "C" fn bloom_set_taa_enabled(on: f64) {
|
|
2333
|
+
engine().renderer.set_taa_enabled(on != 0.0);
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
#[no_mangle]
|
|
2337
|
+
pub extern "C" fn bloom_set_render_scale(scale: f64) {
|
|
2338
|
+
engine().renderer.set_render_scale(scale as f32);
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
#[no_mangle]
|
|
2342
|
+
pub extern "C" fn bloom_get_render_scale() -> f64 {
|
|
2343
|
+
engine().renderer.render_scale() as f64
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
#[no_mangle]
|
|
2347
|
+
pub extern "C" fn bloom_set_upscale_mode(mode: f64) {
|
|
2348
|
+
engine().renderer.set_upscale_mode(mode as u32);
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
#[no_mangle]
|
|
2352
|
+
pub extern "C" fn bloom_set_cas_strength(strength: f64) {
|
|
2353
|
+
engine().renderer.set_cas_strength(strength as f32);
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
#[no_mangle]
|
|
2357
|
+
pub extern "C" fn bloom_get_physical_width() -> f64 {
|
|
2358
|
+
engine().renderer.physical_width() as f64
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
#[no_mangle]
|
|
2362
|
+
pub extern "C" fn bloom_get_physical_height() -> f64 {
|
|
2363
|
+
engine().renderer.physical_height() as f64
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
#[no_mangle]
|
|
2367
|
+
pub extern "C" fn bloom_set_auto_resolution(target_hz: f64, enabled: f64) {
|
|
2368
|
+
let eng = engine();
|
|
2369
|
+
if enabled != 0.0 {
|
|
2370
|
+
let current = eng.renderer.render_scale();
|
|
2371
|
+
eng.drs.enable(target_hz as f32, current);
|
|
2372
|
+
} else {
|
|
2373
|
+
eng.drs.disable();
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
#[no_mangle]
|
|
2378
|
+
pub extern "C" fn bloom_set_manual_exposure(value: f64) {
|
|
2379
|
+
engine().renderer.set_manual_exposure(value as f32);
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
#[no_mangle]
|
|
2383
|
+
pub extern "C" fn bloom_set_env_intensity(intensity: f64) {
|
|
2384
|
+
engine().renderer.set_env_intensity(intensity as f32);
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
#[no_mangle]
|
|
2388
|
+
pub extern "C" fn bloom_set_ssgi_enabled(enabled: f64) {
|
|
2389
|
+
engine().renderer.set_ssgi_enabled(enabled != 0.0);
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
#[no_mangle]
|
|
2393
|
+
pub extern "C" fn bloom_set_ssgi_intensity(intensity: f64) {
|
|
2394
|
+
engine().renderer.set_ssgi_intensity(intensity as f32);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
#[no_mangle]
|
|
2398
|
+
pub extern "C" fn bloom_set_ssgi_radius(radius: f64) {
|
|
2399
|
+
engine().renderer.set_ssgi_radius(radius as f32);
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
#[no_mangle]
|
|
2403
|
+
pub extern "C" fn bloom_set_dof(enabled: f64, focus_distance: f64, aperture: f64) {
|
|
2404
|
+
let r = &mut engine().renderer;
|
|
2405
|
+
r.set_dof_enabled(enabled != 0.0);
|
|
2406
|
+
r.set_dof_focus_distance(focus_distance as f32);
|
|
2407
|
+
r.set_dof_aperture(aperture as f32);
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
#[no_mangle]
|
|
2411
|
+
pub extern "C" fn bloom_splat_impulse(x: f64, z: f64, radius: f64, strength: f64) {
|
|
2412
|
+
engine().renderer.impulse_field.submit_splat(
|
|
2413
|
+
x as f32, z as f32, radius as f32, strength as f32,
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
#[no_mangle]
|
|
2418
|
+
pub extern "C" fn bloom_profiler_frame_history() -> *const u8 {
|
|
2419
|
+
let hist = engine().profiler.frame_history();
|
|
2420
|
+
let mut s = String::with_capacity(hist.len() * 24);
|
|
2421
|
+
for (cpu, gpu) in &hist {
|
|
2422
|
+
s.push_str(&format!("{:.2}|{:.2}\n", cpu, gpu));
|
|
2423
|
+
}
|
|
2424
|
+
alloc_perry_string(&s)
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
#[no_mangle]
|
|
2428
|
+
pub extern "C" fn bloom_profiler_overlay_text() -> *const u8 {
|
|
2429
|
+
let snap = engine().profiler.snapshot();
|
|
2430
|
+
let mut s = String::with_capacity(snap.len() * 48);
|
|
2431
|
+
for (label, cpu, gpu) in &snap {
|
|
2432
|
+
s.push_str(label);
|
|
2433
|
+
s.push('|');
|
|
2434
|
+
s.push_str(&format!("{:.2}", cpu));
|
|
2435
|
+
s.push('|');
|
|
2436
|
+
match gpu {
|
|
2437
|
+
Some(g) => s.push_str(&format!("{:.2}", g)),
|
|
2438
|
+
None => s.push_str("-1"),
|
|
2439
|
+
}
|
|
2440
|
+
s.push('\n');
|
|
2441
|
+
}
|
|
2442
|
+
alloc_perry_string(&s)
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
#[no_mangle]
|
|
2446
|
+
pub extern "C" fn bloom_register_frame_callback(priority: f64, callback: extern "C" fn(f64)) -> f64 {
|
|
2447
|
+
engine().frame_callbacks.register(priority as i32, callback) as f64
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
#[no_mangle]
|
|
2451
|
+
pub extern "C" fn bloom_unregister_frame_callback(id: f64) {
|
|
2452
|
+
engine().frame_callbacks.unregister(id as u64);
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
#[no_mangle]
|
|
2456
|
+
pub extern "C" fn bloom_add_directional_light(
|
|
2457
|
+
dx: f64, dy: f64, dz: f64,
|
|
2458
|
+
r: f64, g: f64, b: f64,
|
|
2459
|
+
intensity: f64,
|
|
2460
|
+
) {
|
|
2461
|
+
engine().renderer.add_directional_light(
|
|
2462
|
+
dx as f32, dy as f32, dz as f32,
|
|
2463
|
+
r as f32, g as f32, b as f32,
|
|
2464
|
+
intensity as f32,
|
|
2465
|
+
);
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
#[no_mangle]
|
|
2469
|
+
pub extern "C" fn bloom_add_point_light(
|
|
2470
|
+
x: f64, y: f64, z: f64, range: f64,
|
|
2471
|
+
r: f64, g: f64, b: f64,
|
|
2472
|
+
intensity: f64,
|
|
2473
|
+
) {
|
|
2474
|
+
engine().renderer.add_point_light(
|
|
2475
|
+
x as f32, y as f32, z as f32, range as f32,
|
|
2476
|
+
r as f32, g as f32, b as f32,
|
|
2477
|
+
intensity as f32,
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
#[no_mangle]
|
|
2482
|
+
pub extern "C" fn bloom_scene_create_node() -> f64 {
|
|
2483
|
+
engine().scene.create_node()
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
#[no_mangle]
|
|
2487
|
+
pub extern "C" fn bloom_scene_destroy_node(handle: f64) {
|
|
2488
|
+
engine().scene.destroy_node(handle);
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
#[no_mangle]
|
|
2492
|
+
pub extern "C" fn bloom_scene_set_visible(handle: f64, visible: f64) {
|
|
2493
|
+
engine().scene.set_visible(handle, visible != 0.0);
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
#[no_mangle]
|
|
2497
|
+
pub extern "C" fn bloom_scene_set_cast_shadow(handle: f64, cast: f64) {
|
|
2498
|
+
engine().scene.set_cast_shadow(handle, cast != 0.0);
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
#[no_mangle]
|
|
2502
|
+
pub extern "C" fn bloom_scene_set_receive_shadow(handle: f64, receive: f64) {
|
|
2503
|
+
engine().scene.set_receive_shadow(handle, receive != 0.0);
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
#[no_mangle]
|
|
2507
|
+
pub extern "C" fn bloom_scene_set_parent(handle: f64, parent: f64) {
|
|
2508
|
+
engine().scene.set_parent(handle, parent);
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
#[no_mangle]
|
|
2512
|
+
pub extern "C" fn bloom_scene_set_transform(handle: f64, mat_ptr: *const f64) {
|
|
2513
|
+
if mat_ptr.is_null() { return; }
|
|
2514
|
+
let slice = unsafe { std::slice::from_raw_parts(mat_ptr, 16) };
|
|
2515
|
+
let mut mat = [[0.0f32; 4]; 4];
|
|
2516
|
+
for col in 0..4 {
|
|
2517
|
+
for row in 0..4 {
|
|
2518
|
+
mat[col][row] = slice[col * 4 + row] as f32;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
engine().scene.set_transform(handle, mat);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
#[no_mangle]
|
|
2525
|
+
pub extern "C" fn bloom_scene_update_geometry(
|
|
2526
|
+
handle: f64,
|
|
2527
|
+
vert_ptr: *const f64,
|
|
2528
|
+
vert_count: f64,
|
|
2529
|
+
idx_ptr: *const f64,
|
|
2530
|
+
idx_count: f64,
|
|
2531
|
+
) {
|
|
2532
|
+
if vert_ptr.is_null() || idx_ptr.is_null() { return; }
|
|
2533
|
+
let nv = vert_count as usize;
|
|
2534
|
+
let ni = idx_count as usize;
|
|
2535
|
+
|
|
2536
|
+
let vert_floats = unsafe { std::slice::from_raw_parts(vert_ptr, nv * 12) };
|
|
2537
|
+
let idx_floats = unsafe { std::slice::from_raw_parts(idx_ptr, ni) };
|
|
2538
|
+
|
|
2539
|
+
let mut vertices = Vec::with_capacity(nv);
|
|
2540
|
+
for i in 0..nv {
|
|
2541
|
+
let base = i * 12;
|
|
2542
|
+
vertices.push(bloom_shared::renderer::Vertex3D {
|
|
2543
|
+
position: [vert_floats[base] as f32, vert_floats[base+1] as f32, vert_floats[base+2] as f32],
|
|
2544
|
+
normal: [vert_floats[base+3] as f32, vert_floats[base+4] as f32, vert_floats[base+5] as f32],
|
|
2545
|
+
color: [vert_floats[base+6] as f32, vert_floats[base+7] as f32, vert_floats[base+8] as f32, vert_floats[base+9] as f32],
|
|
2546
|
+
uv: [vert_floats[base+10] as f32, vert_floats[base+11] as f32],
|
|
2547
|
+
joints: [0.0; 4],
|
|
2548
|
+
weights: [0.0; 4],
|
|
2549
|
+
tangent: [0.0; 4],
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
let indices: Vec<u32> = idx_floats.iter().map(|&v| v as u32).collect();
|
|
2554
|
+
|
|
2555
|
+
engine().scene.update_geometry(handle, vertices, indices);
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
#[no_mangle]
|
|
2559
|
+
pub extern "C" fn bloom_scene_set_material_color(handle: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
2560
|
+
engine().scene.set_material_color(handle, r as f32, g as f32, b as f32, a as f32);
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
#[no_mangle]
|
|
2564
|
+
pub extern "C" fn bloom_scene_set_material_pbr(handle: f64, roughness: f64, metalness: f64) {
|
|
2565
|
+
engine().scene.set_material_pbr(handle, roughness as f32, metalness as f32);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
#[no_mangle]
|
|
2569
|
+
pub extern "C" fn bloom_scene_set_material_texture(handle: f64, texture_idx: f64) {
|
|
2570
|
+
engine().scene.set_material_texture(handle, texture_idx as u32);
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
#[no_mangle]
|
|
2574
|
+
pub extern "C" fn bloom_scene_node_count() -> f64 {
|
|
2575
|
+
engine().scene.node_count() as f64
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
#[no_mangle]
|
|
2579
|
+
pub extern "C" fn bloom_scene_node_vertex_count(handle: f64) -> f64 {
|
|
2580
|
+
match engine().scene.nodes.get(handle) {
|
|
2581
|
+
Some(node) => node.vertices.len() as f64,
|
|
2582
|
+
None => -1.0,
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
#[no_mangle]
|
|
2587
|
+
pub extern "C" fn bloom_scene_node_index_count(handle: f64) -> f64 {
|
|
2588
|
+
match engine().scene.nodes.get(handle) {
|
|
2589
|
+
Some(node) => node.indices.len() as f64,
|
|
2590
|
+
None => -1.0,
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
#[no_mangle]
|
|
2595
|
+
pub extern "C" fn bloom_scene_set_material_water(handle: f64, wave_amp: f64, wave_speed: f64, r: f64, g: f64, b: f64, a: f64) {
|
|
2596
|
+
engine().scene.set_material_water(handle, wave_amp as f32, wave_speed as f32, r as f32, g as f32, b as f32, a as f32);
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
#[no_mangle]
|
|
2600
|
+
pub extern "C" fn bloom_gen_mesh_spline_ribbon(points_ptr: *const u8, point_count: f64, widths_ptr: *const u8, width_count: f64) -> f64 {
|
|
2601
|
+
let n = point_count as usize;
|
|
2602
|
+
let wn = width_count as usize;
|
|
2603
|
+
let points = unsafe { std::slice::from_raw_parts(points_ptr as *const f32, n * 3) };
|
|
2604
|
+
let widths = unsafe { std::slice::from_raw_parts(widths_ptr as *const f32, wn) };
|
|
2605
|
+
engine().models.gen_mesh_spline_ribbon(points, widths)
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
#[no_mangle]
|
|
2609
|
+
pub extern "C" fn bloom_load_render_texture(width: f64, height: f64) -> f64 {
|
|
2610
|
+
let w = width as u32;
|
|
2611
|
+
let h = height as u32;
|
|
2612
|
+
let eng = engine();
|
|
2613
|
+
let rt_handle = eng.textures.load_render_texture(w, h);
|
|
2614
|
+
|
|
2615
|
+
// Create the GPU texture via the renderer's public method.
|
|
2616
|
+
let (bind_group_idx, _tex_vec_idx) = eng.renderer.create_render_texture(w, h);
|
|
2617
|
+
|
|
2618
|
+
// Register as a texture handle so drawTexture can sample it.
|
|
2619
|
+
let tex_handle = eng.textures.textures.alloc(bloom_shared::textures::TextureData {
|
|
2620
|
+
bind_group_idx, width: w, height: h,
|
|
2621
|
+
});
|
|
2622
|
+
eng.textures.set_render_texture_handle(rt_handle, tex_handle);
|
|
2623
|
+
|
|
2624
|
+
rt_handle
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
#[no_mangle]
|
|
2628
|
+
pub extern "C" fn bloom_unload_render_texture(handle: f64) {
|
|
2629
|
+
engine().textures.unload_render_texture(handle);
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
#[no_mangle]
|
|
2633
|
+
pub extern "C" fn bloom_begin_texture_mode(handle: f64) {
|
|
2634
|
+
let eng = engine();
|
|
2635
|
+
let (w, h, bg_idx) = match eng.textures.render_textures.get(handle) {
|
|
2636
|
+
Some(rt) => {
|
|
2637
|
+
let tex_handle = rt.texture_handle;
|
|
2638
|
+
match eng.textures.textures.get(tex_handle) {
|
|
2639
|
+
Some(td) => (rt.width, rt.height, td.bind_group_idx as usize),
|
|
2640
|
+
None => return,
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
None => return,
|
|
2644
|
+
};
|
|
2645
|
+
if let Some(texture) = eng.renderer.get_texture_ref(bg_idx) {
|
|
2646
|
+
// We need to call begin_texture_mode with a reference to the texture,
|
|
2647
|
+
// but get_texture_ref borrows renderer immutably. Clone the texture view
|
|
2648
|
+
// data we need first, then call the mutable method.
|
|
2649
|
+
let color_view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
|
2650
|
+
// Create depth texture for this RT.
|
|
2651
|
+
let depth_tex = eng.renderer.device.create_texture(&wgpu::TextureDescriptor {
|
|
2652
|
+
label: Some("rt_depth"), size: wgpu::Extent3d { width: w, height: h, depth_or_array_layers: 1 },
|
|
2653
|
+
mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2,
|
|
2654
|
+
format: wgpu::TextureFormat::Depth32Float, usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
|
|
2655
|
+
view_formats: &[],
|
|
2656
|
+
});
|
|
2657
|
+
let depth_view = depth_tex.create_view(&wgpu::TextureViewDescriptor::default());
|
|
2658
|
+
eng.renderer.rt_color_view = Some(color_view);
|
|
2659
|
+
eng.renderer.rt_depth_view = Some(depth_view);
|
|
2660
|
+
eng.renderer.rt_depth_texture = Some(depth_tex);
|
|
2661
|
+
eng.renderer.rt_width = w;
|
|
2662
|
+
eng.renderer.rt_height = h;
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
#[no_mangle]
|
|
2667
|
+
pub extern "C" fn bloom_end_texture_mode() {
|
|
2668
|
+
engine().renderer.end_texture_mode();
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
#[no_mangle]
|
|
2672
|
+
pub extern "C" fn bloom_get_render_texture_texture(handle: f64) -> f64 {
|
|
2673
|
+
engine().textures.get_render_texture_texture(handle)
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2676
|
+
#[no_mangle]
|
|
2677
|
+
pub extern "C" fn bloom_scene_get_transform(handle: f64, index: f64) -> f64 {
|
|
2678
|
+
let mat = engine().scene.get_transform(handle);
|
|
2679
|
+
let i = index as usize;
|
|
2680
|
+
let col = i / 4;
|
|
2681
|
+
let row = i % 4;
|
|
2682
|
+
if col < 4 && row < 4 { mat[col][row] as f64 } else { 0.0 }
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
#[no_mangle]
|
|
2686
|
+
pub extern "C" fn bloom_scene_get_bounds_min_x(handle: f64) -> f64 { engine().scene.get_bounds(handle).0[0] as f64 }
|
|
2687
|
+
|
|
2688
|
+
#[no_mangle]
|
|
2689
|
+
pub extern "C" fn bloom_scene_get_bounds_min_y(handle: f64) -> f64 { engine().scene.get_bounds(handle).0[1] as f64 }
|
|
2690
|
+
|
|
2691
|
+
#[no_mangle]
|
|
2692
|
+
pub extern "C" fn bloom_scene_get_bounds_min_z(handle: f64) -> f64 { engine().scene.get_bounds(handle).0[2] as f64 }
|
|
2693
|
+
|
|
2694
|
+
#[no_mangle]
|
|
2695
|
+
pub extern "C" fn bloom_scene_get_bounds_max_x(handle: f64) -> f64 { engine().scene.get_bounds(handle).1[0] as f64 }
|
|
2696
|
+
|
|
2697
|
+
#[no_mangle]
|
|
2698
|
+
pub extern "C" fn bloom_scene_get_bounds_max_y(handle: f64) -> f64 { engine().scene.get_bounds(handle).1[1] as f64 }
|
|
2699
|
+
|
|
2700
|
+
#[no_mangle]
|
|
2701
|
+
pub extern "C" fn bloom_scene_get_bounds_max_z(handle: f64) -> f64 { engine().scene.get_bounds(handle).1[2] as f64 }
|
|
2702
|
+
|
|
2703
|
+
#[no_mangle]
|
|
2704
|
+
pub extern "C" fn bloom_scene_set_user_data(handle: f64, data: f64) {
|
|
2705
|
+
engine().scene.set_user_data(handle, data as i64);
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
#[no_mangle]
|
|
2709
|
+
pub extern "C" fn bloom_scene_get_user_data(handle: f64) -> f64 {
|
|
2710
|
+
engine().scene.get_user_data(handle) as f64
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
#[no_mangle]
|
|
2714
|
+
pub extern "C" fn bloom_scene_extrude_polygon(
|
|
2715
|
+
handle: f64,
|
|
2716
|
+
polygon_ptr: *const f64,
|
|
2717
|
+
polygon_count: f64,
|
|
2718
|
+
depth: f64,
|
|
2719
|
+
) {
|
|
2720
|
+
if polygon_ptr.is_null() { return; }
|
|
2721
|
+
let n = polygon_count as usize;
|
|
2722
|
+
let polygon = unsafe { std::slice::from_raw_parts(polygon_ptr, n * 2) };
|
|
2723
|
+
|
|
2724
|
+
let geo = bloom_shared::geometry::extrude_polygon(polygon, &[], depth);
|
|
2725
|
+
engine().scene.update_geometry(handle, geo.vertices, geo.indices);
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
#[no_mangle]
|
|
2729
|
+
pub extern "C" fn bloom_scene_subtract_box(
|
|
2730
|
+
handle: f64,
|
|
2731
|
+
min_x: f64, min_y: f64, min_z: f64,
|
|
2732
|
+
max_x: f64, max_y: f64, max_z: f64,
|
|
2733
|
+
) {
|
|
2734
|
+
let eng = engine();
|
|
2735
|
+
if let Some(node) = eng.scene.nodes.get(handle) {
|
|
2736
|
+
let current = bloom_shared::geometry::GeometryData {
|
|
2737
|
+
vertices: node.vertices.clone(),
|
|
2738
|
+
indices: node.indices.clone(),
|
|
2739
|
+
};
|
|
2740
|
+
let result = bloom_shared::geometry::subtract_box(
|
|
2741
|
+
¤t,
|
|
2742
|
+
[min_x as f32, min_y as f32, min_z as f32],
|
|
2743
|
+
[max_x as f32, max_y as f32, max_z as f32],
|
|
2744
|
+
);
|
|
2745
|
+
eng.scene.update_geometry(handle, result.vertices, result.indices);
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
#[no_mangle]
|
|
2750
|
+
pub extern "C" fn bloom_enable_shadows() {
|
|
2751
|
+
engine().renderer.shadow_map.enable();
|
|
2752
|
+
}
|
|
2753
|
+
|
|
2754
|
+
#[no_mangle]
|
|
2755
|
+
pub extern "C" fn bloom_disable_shadows() {
|
|
2756
|
+
engine().renderer.shadow_map.disable();
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
#[no_mangle]
|
|
2760
|
+
pub extern "C" fn bloom_dump_shadow_map(path_ptr: *const u8) {
|
|
2761
|
+
let path = str_from_header(path_ptr).to_string();
|
|
2762
|
+
engine().renderer.dump_shadow_map(&path);
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
#[no_mangle]
|
|
2766
|
+
pub extern "C" fn bloom_enable_postfx() {
|
|
2767
|
+
let eng = engine();
|
|
2768
|
+
let w = eng.renderer.width();
|
|
2769
|
+
let h = eng.renderer.height();
|
|
2770
|
+
let fmt = eng.renderer.surface_format();
|
|
2771
|
+
eng.postfx = Some(bloom_shared::postfx::PostFxPipeline::new(
|
|
2772
|
+
&eng.renderer.device, w, h, fmt,
|
|
2773
|
+
));
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
#[no_mangle]
|
|
2777
|
+
pub extern "C" fn bloom_disable_postfx() {
|
|
2778
|
+
engine().postfx = None;
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
#[no_mangle]
|
|
2782
|
+
pub extern "C" fn bloom_postfx_set_selected(handle: f64) {
|
|
2783
|
+
if let Some(pfx) = &mut engine().postfx {
|
|
2784
|
+
if handle == 0.0 {
|
|
2785
|
+
pfx.set_selected(Vec::new());
|
|
2786
|
+
} else {
|
|
2787
|
+
pfx.set_selected(vec![handle]);
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
#[no_mangle]
|
|
2793
|
+
pub extern "C" fn bloom_postfx_set_hovered(handle: f64) {
|
|
2794
|
+
if let Some(pfx) = &mut engine().postfx {
|
|
2795
|
+
pfx.set_hovered(handle);
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
#[no_mangle]
|
|
2800
|
+
pub extern "C" fn bloom_postfx_set_outline_color(r: f64, g: f64, b: f64, a: f64) {
|
|
2801
|
+
if let Some(pfx) = &mut engine().postfx {
|
|
2802
|
+
pfx.outline_params.color_selected = [r as f32, g as f32, b as f32, a as f32];
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
#[no_mangle]
|
|
2807
|
+
pub extern "C" fn bloom_postfx_set_outline_thickness(thickness: f64) {
|
|
2808
|
+
if let Some(pfx) = &mut engine().postfx {
|
|
2809
|
+
pfx.outline_params.thickness[0] = thickness as f32;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
#[no_mangle]
|
|
2814
|
+
pub extern "C" fn bloom_scene_attach_model(node_handle: f64, model_handle: f64, mesh_index: f64) {
|
|
2815
|
+
let eng = engine();
|
|
2816
|
+
let mi = mesh_index as usize;
|
|
2817
|
+
|
|
2818
|
+
// Get model mesh data
|
|
2819
|
+
let model_data = match eng.models.models.get(model_handle) {
|
|
2820
|
+
Some(md) => md,
|
|
2821
|
+
None => return,
|
|
2822
|
+
};
|
|
2823
|
+
if mi >= model_data.meshes.len() { return; }
|
|
2824
|
+
let mesh = &model_data.meshes[mi];
|
|
2825
|
+
|
|
2826
|
+
// Copy vertices and indices to scene node
|
|
2827
|
+
let vertices = mesh.vertices.clone();
|
|
2828
|
+
let indices = mesh.indices.clone();
|
|
2829
|
+
let base_color_tex = mesh.texture_idx;
|
|
2830
|
+
let normal_tex = mesh.normal_texture_idx;
|
|
2831
|
+
let mr_tex = mesh.metallic_roughness_texture_idx;
|
|
2832
|
+
let emissive_tex = mesh.emissive_texture_idx;
|
|
2833
|
+
let emissive_factor = mesh.emissive_factor;
|
|
2834
|
+
eng.scene.update_geometry(node_handle, vertices, indices);
|
|
2835
|
+
|
|
2836
|
+
// Pipe PBR textures through to the scene node material so the
|
|
2837
|
+
// renderer's scene pipeline can sample them.
|
|
2838
|
+
if let Some(tex_idx) = base_color_tex {
|
|
2839
|
+
eng.scene.set_material_texture(node_handle, tex_idx);
|
|
2840
|
+
}
|
|
2841
|
+
if let Some(tex_idx) = normal_tex {
|
|
2842
|
+
eng.scene.set_material_normal_texture(node_handle, tex_idx);
|
|
2843
|
+
}
|
|
2844
|
+
if let Some(tex_idx) = mr_tex {
|
|
2845
|
+
eng.scene.set_material_metallic_roughness_texture(node_handle, tex_idx);
|
|
2846
|
+
}
|
|
2847
|
+
if let Some(tex_idx) = emissive_tex {
|
|
2848
|
+
eng.scene.set_material_emissive_texture(node_handle, tex_idx);
|
|
2849
|
+
}
|
|
2850
|
+
eng.scene.set_material_emissive_factor(
|
|
2851
|
+
node_handle,
|
|
2852
|
+
emissive_factor[0],
|
|
2853
|
+
emissive_factor[1],
|
|
2854
|
+
emissive_factor[2],
|
|
2855
|
+
);
|
|
2856
|
+
}
|
|
2857
|
+
|