@series-inc/rundot-syncplay 6.0.0-rc.2 → 6.0.0-rc.21
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/README.md +133 -0
- package/core/deterministic-math.d.ts +75 -1
- package/core/native/instance_ledger.hpp +1095 -0
- package/core/native/legacy_checkpoint_ids.hpp +107 -0
- package/core/native/physics/abi.cpp +39 -211
- package/core/native/physics/abi.hpp +2 -6
- package/core/native/physics/articulation.cpp +1434 -0
- package/core/native/physics/articulation.hpp +279 -0
- package/core/native/physics/buoyancy.cpp +1588 -0
- package/core/native/physics/buoyancy.hpp +254 -0
- package/core/native/physics/capsule_triangle.cpp +168 -0
- package/core/native/physics/capsule_triangle.hpp +40 -0
- package/core/native/physics/capsule_triangle_native.inc +291 -0
- package/core/native/physics/certified_sum.hpp +218 -0
- package/core/native/physics/character.cpp +638 -0
- package/core/native/physics/character.hpp +169 -0
- package/core/native/physics/checkpoint_schema.hpp +379 -0
- package/core/native/physics/cloth.cpp +1401 -0
- package/core/native/physics/cloth.hpp +357 -0
- package/core/native/physics/constraint_rows.cpp +363 -2
- package/core/native/physics/constraint_rows.hpp +72 -1
- package/core/native/physics/deformable_query.cpp +1630 -0
- package/core/native/physics/deformable_query.hpp +578 -0
- package/core/native/physics/distance.cpp +1166 -0
- package/core/native/physics/distance.hpp +151 -0
- package/core/native/physics/exact/exact-applied.cpp +101 -0
- package/core/native/physics/exact/exact-applied.hpp +112 -0
- package/core/native/physics/exact/exact-dyadic.cpp +691 -0
- package/core/native/physics/exact/exact-dyadic.hpp +58 -0
- package/core/native/physics/exact/exact-operation.hpp +51 -0
- package/core/native/physics/exact/word-core.hpp +262 -0
- package/core/native/physics/extended_abi.cpp +1242 -0
- package/core/native/physics/extended_abi.hpp +355 -0
- package/core/native/physics/extended_abi_characters.cpp +261 -0
- package/core/native/physics/extended_abi_characters.hpp +434 -0
- package/core/native/physics/extended_abi_core_features.cpp +713 -0
- package/core/native/physics/extended_abi_core_features.hpp +226 -0
- package/core/native/physics/extended_abi_deformables.cpp +448 -0
- package/core/native/physics/extended_abi_deformables.hpp +867 -0
- package/core/native/physics/extended_abi_vehicles.cpp +411 -0
- package/core/native/physics/extended_abi_vehicles.hpp +222 -0
- package/core/native/physics/fracture.cpp +1981 -0
- package/core/native/physics/fracture.hpp +460 -0
- package/core/native/physics/gear.cpp +563 -0
- package/core/native/physics/gear.hpp +158 -0
- package/core/native/physics/geometry_memory.hpp +476 -0
- package/core/native/physics/geometry_store.cpp +547 -0
- package/core/native/physics/geometry_store.hpp +134 -0
- package/core/native/physics/lag_compensation.cpp +1626 -0
- package/core/native/physics/lag_compensation.hpp +405 -0
- package/core/native/physics/mass_properties.cpp +449 -0
- package/core/native/physics/mass_properties.hpp +23 -0
- package/core/native/physics/material_pose.hpp +988 -0
- package/core/native/physics/particles.cpp +1065 -0
- package/core/native/physics/particles.hpp +261 -0
- package/core/native/physics/path_joint.cpp +781 -0
- package/core/native/physics/path_joint.hpp +154 -0
- package/core/native/physics/physics.cpp +13043 -1065
- package/core/native/physics/physics.hpp +184 -8
- package/core/native/physics/planar_deformable.cpp +2433 -0
- package/core/native/physics/planar_deformable.hpp +889 -0
- package/core/native/physics/platformer_2d.cpp +1353 -0
- package/core/native/physics/platformer_2d.hpp +340 -0
- package/core/native/physics/powered_ragdoll.cpp +1100 -0
- package/core/native/physics/powered_ragdoll.hpp +279 -0
- package/core/native/physics/powertrain.cpp +586 -0
- package/core/native/physics/powertrain.hpp +180 -0
- package/core/native/physics/pulley.cpp +311 -0
- package/core/native/physics/pulley.hpp +121 -0
- package/core/native/physics/ragdoll.cpp +586 -0
- package/core/native/physics/ragdoll.hpp +221 -0
- package/core/native/physics/rope.cpp +692 -0
- package/core/native/physics/rope.hpp +215 -0
- package/core/native/physics/rounded_convex.cpp +1229 -0
- package/core/native/physics/rounded_convex.hpp +287 -0
- package/core/native/physics/sdf_geometry.cpp +1821 -0
- package/core/native/physics/sdf_geometry.hpp +474 -0
- package/core/native/physics/soft_body.cpp +1449 -0
- package/core/native/physics/soft_body.hpp +328 -0
- package/core/native/physics/soft_collision.cpp +1862 -0
- package/core/native/physics/soft_collision.hpp +561 -0
- package/core/native/physics/surface_velocity.cpp +366 -0
- package/core/native/physics/surface_velocity.hpp +243 -0
- package/core/native/physics/topology.cpp +357 -39
- package/core/native/physics/topology.hpp +97 -6
- package/core/native/physics/tracks.cpp +1179 -0
- package/core/native/physics/tracks.hpp +404 -0
- package/core/native/physics/vehicle.cpp +629 -0
- package/core/native/physics/vehicle.hpp +191 -0
- package/core/native/physics/voxel_cooking.cpp +1929 -0
- package/core/native/physics/voxel_cooking.hpp +395 -0
- package/core/native/physics/world.cpp +5290 -854
- package/core/native/physics/world.hpp +796 -24
- package/core/native/physics/world_abi.cpp +3840 -306
- package/core/native/physics/world_abi.hpp +530 -10
- package/core/native/physics/world_digest_visitor.hpp +277 -0
- package/core/native/physics/world_strong_digest.hpp +557 -0
- package/core/native/physics2d/ccd.cpp +1302 -0
- package/core/native/physics2d/ccd.hpp +141 -0
- package/core/native/physics2d/checkpoint_memory.hpp +349 -0
- package/core/native/physics2d/clock_primitives.hpp +138 -0
- package/core/native/physics2d/commands.cpp +174 -28
- package/core/native/physics2d/commands.hpp +3 -1
- package/core/native/physics2d/compound.cpp +581 -0
- package/core/native/physics2d/compound.hpp +248 -0
- package/core/native/physics2d/contour.cpp +325 -0
- package/core/native/physics2d/contour.hpp +143 -0
- package/core/native/physics2d/frame_scope.hpp +124 -0
- package/core/native/physics2d/joint_phases.hpp +93 -0
- package/core/native/physics2d/joints.cpp +587 -150
- package/core/native/physics2d/joints.hpp +5 -0
- package/core/native/physics2d/memory_private.hpp +125 -0
- package/core/native/physics2d/owned_abi.cpp +1354 -879
- package/core/native/physics2d/owned_abi.hpp +190 -52
- package/core/native/physics2d/phase_test_hooks.hpp +17 -0
- package/core/native/physics2d/physics2d.cpp +2073 -120
- package/core/native/physics2d/physics2d.hpp +154 -2
- package/core/native/physics2d/queries.cpp +1055 -79
- package/core/native/physics2d/queries.hpp +71 -5
- package/core/native/physics2d/world.cpp +1313 -353
- package/core/native/physics2d/world.hpp +124 -13
- package/core/native/sha256/sha256_compress_unsigned.hpp +68 -0
- package/core/native/sha256/sha256_fips_constants.hpp +24 -0
- package/core/native/sha256/sha256_length.hpp +56 -0
- package/core/native/sha256/sha256_memo.hpp +48 -0
- package/core/native/sha256/sha256_sink.hpp +234 -0
- package/core/physics2d-owned.d.ts +466 -126
- package/core/runtime.d.ts +192 -19
- package/core/scripts/build-native.mjs +34 -0
- package/core/scripts/build-wasm-physics.mjs +272 -23
- package/core/scripts/extended-physics-profile.mjs +634 -0
- package/core/scripts/generate-physics2d-vectors.mjs +59 -0
- package/core/src/kinetix-deterministic-math.d.ts +2 -0
- package/core/src/kinetix-deterministic-math.mjs +513 -27
- package/core/src/kinetix-owned-runtime-adapter.mjs +788 -0
- package/core/src/kinetix-runtime-adapter-utils.mjs +54 -6
- package/core/src/kinetix-runtime-contract.mjs +55 -9
- package/core/src/kinetix-runtime-identity.mjs +12 -1
- package/core/src/kinetix-session-config.mjs +7 -2
- package/core/src/kinetix-state-report.mjs +36 -0
- package/core/src/physics/abi-constants.mjs +5 -4
- package/core/src/physics/articulation.d.mts +194 -0
- package/core/src/physics/articulation.mjs +1141 -0
- package/core/src/physics/buoyancy.d.mts +143 -0
- package/core/src/physics/buoyancy.mjs +268 -0
- package/core/src/physics/cloth.d.mts +314 -0
- package/core/src/physics/cloth.mjs +1156 -0
- package/core/src/physics/deformable-query.d.mts +217 -0
- package/core/src/physics/deformable-query.mjs +1412 -0
- package/core/src/physics/distance.d.mts +160 -0
- package/core/src/physics/distance.mjs +175 -0
- package/core/src/physics/extended-wasm-instance.d.mts +5 -0
- package/core/src/physics/extended-wasm-instance.mjs +48 -0
- package/core/src/physics/feature-api.d.mts +74 -0
- package/core/src/physics/feature-api.mjs +98 -0
- package/core/src/physics/fracture.d.mts +133 -0
- package/core/src/physics/fracture.mjs +1324 -0
- package/core/src/physics/gear.d.mts +585 -0
- package/core/src/physics/gear.mjs +955 -0
- package/core/src/physics/lag-compensation.d.mts +101 -0
- package/core/src/physics/lag-compensation.mjs +1100 -0
- package/core/src/physics/mass-properties.d.mts +114 -0
- package/core/src/physics/mass-properties.mjs +137 -468
- package/core/src/physics/particles.d.mts +177 -0
- package/core/src/physics/particles.mjs +758 -0
- package/core/src/physics/path-joint.d.mts +171 -0
- package/core/src/physics/path-joint.mjs +1231 -0
- package/core/src/physics/physics-extended-wasm-module.generated.mjs +13 -0
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +48 -0
- package/core/src/physics/physics-wasm-module.generated.mjs +34 -5
- package/core/src/physics/powered-ragdoll.d.mts +188 -0
- package/core/src/physics/powered-ragdoll.mjs +1043 -0
- package/core/src/physics/powertrain.d.mts +260 -0
- package/core/src/physics/powertrain.mjs +621 -0
- package/core/src/physics/pulley.d.mts +98 -0
- package/core/src/physics/pulley.mjs +686 -0
- package/core/src/physics/ragdoll.d.mts +289 -0
- package/core/src/physics/ragdoll.mjs +1323 -0
- package/core/src/physics/rope.d.mts +241 -0
- package/core/src/physics/rope.mjs +319 -0
- package/core/src/physics/rounded-convex.d.mts +328 -0
- package/core/src/physics/rounded-convex.mjs +1404 -0
- package/core/src/physics/sdf-geometry.d.mts +117 -0
- package/core/src/physics/sdf-geometry.mjs +1204 -0
- package/core/src/physics/soft-body.d.mts +144 -0
- package/core/src/physics/soft-body.mjs +1285 -0
- package/core/src/physics/soft-collision.d.mts +651 -0
- package/core/src/physics/soft-collision.mjs +1883 -0
- package/core/src/physics/surface-velocity.d.mts +156 -0
- package/core/src/physics/surface-velocity.mjs +722 -0
- package/core/src/physics/tracks.d.mts +411 -0
- package/core/src/physics/tracks.mjs +1074 -0
- package/core/src/physics/vehicle.d.mts +3 -0
- package/core/src/physics/vehicle.mjs +172 -0
- package/core/src/physics/voxel-cooking.d.mts +219 -0
- package/core/src/physics/voxel-cooking.mjs +1499 -0
- package/core/src/physics/voxel-swept-quad.mjs +110 -0
- package/core/src/physics/wasm-instance.mjs +160 -23
- package/core/src/physics/world.d.mts +62 -0
- package/core/src/physics/world.mjs +1947 -152
- package/core/src/physics2d/body-state.mjs +218 -15
- package/core/src/physics2d/collision.d.mts +52 -0
- package/core/src/physics2d/collision.mjs +234 -0
- package/core/src/physics2d/compound.mjs +454 -0
- package/core/src/physics2d/contour-state.mjs +771 -0
- package/core/src/physics2d/feature-api.d.mts +211 -0
- package/core/src/physics2d/feature-api.mjs +3 -0
- package/core/src/physics2d/fluid-state.mjs +145 -0
- package/core/src/physics2d/joint-state.mjs +1 -1
- package/core/src/physics2d/owned-queries.mjs +3 -1
- package/core/src/physics2d/owned-transport.mjs +268 -122
- package/core/src/physics2d/owned-world.mjs +353 -230
- package/core/src/physics2d/particle-fluid.d.mts +152 -0
- package/core/src/physics2d/particle-fluid.mjs +233 -0
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +27 -10
- package/core/src/physics2d/query-codec.mjs +61 -13
- package/core/src/physics2d/submerged-geometry.d.mts +51 -0
- package/core/src/physics2d/submerged-geometry.mjs +186 -0
- package/core/src/runtime.mjs +23 -0
- package/core/src/shared/bytes.d.mts +2 -0
- package/core/src/shared/bytes.mjs +33 -0
- package/core/src/shared/sha256.d.mts +3 -0
- package/core/src/shared/sha256.mjs +72 -22
- package/core/units.d.ts +50 -0
- package/core/world.d.ts +253 -5
- package/dist/authority-room.d.ts +9 -0
- package/dist/authority-room.js +45 -16
- package/dist/browser.d.ts +6 -5
- package/dist/browser.js +4 -3
- package/dist/cadence.d.ts +7 -0
- package/dist/cadence.js +19 -0
- package/dist/canonical.d.ts +1 -0
- package/dist/canonical.js +3 -0
- package/dist/checksum-policy.d.ts +10 -0
- package/dist/checksum-policy.js +14 -0
- package/dist/collider-cooking-hull.d.ts +18 -0
- package/dist/collider-cooking-hull.js +248 -0
- package/dist/collider-cooking.d.ts +140 -0
- package/dist/collider-cooking.js +794 -0
- package/dist/compat/v5.d.ts +121 -0
- package/dist/compat/v5.js +479 -0
- package/dist/creator.d.ts +7 -6
- package/dist/creator.js +4 -3
- package/dist/game-byte-section.d.ts +36 -0
- package/dist/game-byte-section.js +350 -0
- package/dist/index.d.ts +13 -6
- package/dist/index.js +9 -4
- package/dist/instant-replay.d.ts +27 -2
- package/dist/instant-replay.js +91 -16
- package/dist/lag-compensation3d.js +11 -10
- package/dist/match-log.d.ts +21 -4
- package/dist/match-log.js +92 -9
- package/dist/math.d.ts +2 -0
- package/dist/math.js +1 -0
- package/dist/modules/character-3d.d.ts +16 -1
- package/dist/modules/character-3d.js +42 -5
- package/dist/modules/combat.js +6 -5
- package/dist/movement3d-revision1.d.ts +2 -0
- package/dist/movement3d-revision1.js +973 -0
- package/dist/movement3d.d.ts +53 -3
- package/dist/movement3d.js +917 -247
- package/dist/networked-client.d.ts +15 -0
- package/dist/networked-client.js +378 -105
- package/dist/node.d.ts +3 -2
- package/dist/node.js +2 -1
- package/dist/physics/2d.d.ts +38 -4
- package/dist/physics/2d.js +57 -36
- package/dist/physics/3d.d.ts +755 -111
- package/dist/physics/3d.js +2355 -158
- package/dist/physics/edit-result-graph.d.ts +36 -0
- package/dist/physics/edit-result-graph.js +141 -0
- package/dist/physics/game-codec3d.d.ts +41 -0
- package/dist/physics/game-codec3d.js +544 -0
- package/dist/physics/installed-checkpoint3d.d.ts +13 -0
- package/dist/physics/installed-checkpoint3d.js +120 -0
- package/dist/physics/installed-runtime3d.d.ts +51 -0
- package/dist/physics/installed-runtime3d.js +372 -0
- package/dist/physics/installed-state-commitment3d.d.ts +2 -0
- package/dist/physics/installed-state-commitment3d.js +24 -0
- package/dist/physics/units.d.ts +38 -0
- package/dist/physics/units.js +56 -0
- package/dist/physics/vehicle-state3d.d.ts +93 -0
- package/dist/physics/vehicle-state3d.js +1191 -0
- package/dist/physics/voxel-body-state.d.ts +61 -0
- package/dist/physics/voxel-body-state.js +410 -0
- package/dist/r3f-render-adapter.d.ts +59 -1
- package/dist/r3f-render-adapter.js +137 -2
- package/dist/replay.d.ts +13 -0
- package/dist/replay.js +95 -70
- package/dist/run-room-transport.js +5 -1
- package/dist/runner.d.ts +17 -2
- package/dist/runner.js +472 -84
- package/dist/runtime-cleanup.d.ts +54 -0
- package/dist/runtime-cleanup.js +266 -0
- package/dist/runtime-lease.d.ts +11 -1
- package/dist/runtime-lease.js +23 -10
- package/dist/runtime-room-metadata.d.ts +2 -8
- package/dist/runtime-room-metadata.js +11 -14
- package/dist/runtime-session.d.ts +8 -0
- package/dist/runtime-session.js +222 -58
- package/dist/schema-codegen.js +3 -0
- package/dist/schema-dsl-binary.d.ts +10 -4
- package/dist/schema-dsl-binary.js +375 -76
- package/dist/scratch-pool.d.ts +32 -0
- package/dist/scratch-pool.js +60 -0
- package/dist/sdk-session.d.ts +1 -0
- package/dist/sdk-session.js +4 -0
- package/dist/secret-config.js +2 -60
- package/dist/secret-crypto.js +70 -36
- package/dist/session-snapshot.d.ts +15 -4
- package/dist/session-snapshot.js +35 -33
- package/dist/session-wire.js +14 -22
- package/dist/sparse-set.d.ts +1 -0
- package/dist/sparse-set.js +22 -0
- package/dist/spatial/spatial-grid-3d.d.ts +41 -0
- package/dist/spatial/spatial-grid-3d.js +115 -0
- package/dist/synctest.d.ts +9 -0
- package/dist/synctest.js +106 -17
- package/dist/testing-network.d.ts +2 -0
- package/dist/testing-network.js +122 -18
- package/dist/testing.d.ts +27 -6
- package/dist/testing.js +297 -56
- package/dist/tools/index.d.ts +3 -2
- package/dist/tools/index.js +3 -2
- package/dist/tools/module-certification.d.ts +6 -0
- package/dist/tools/module-certification.js +26 -2
- package/package.json +18 -5
- package/core/scripts/run-box3d-benchmark.mjs +0 -350
- package/core/src/physics/index.mjs +0 -3169
|
@@ -0,0 +1,1981 @@
|
|
|
1
|
+
#include "fracture.hpp"
|
|
2
|
+
|
|
3
|
+
#include <algorithm>
|
|
4
|
+
#include <array>
|
|
5
|
+
#include <cmath>
|
|
6
|
+
#include <cstdint>
|
|
7
|
+
#include <cstring>
|
|
8
|
+
#include <span>
|
|
9
|
+
|
|
10
|
+
namespace rundot::kinetix::physics {
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Deterministic 3D Vector Math
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
DeformableVec3 addVec3(const DeformableVec3& a, const DeformableVec3& b) {
|
|
17
|
+
return {a.x + b.x, a.y + b.y, a.z + b.z};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
DeformableVec3 subVec3(const DeformableVec3& a, const DeformableVec3& b) {
|
|
21
|
+
return {a.x - b.x, a.y - b.y, a.z - b.z};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
DeformableVec3 scaleVec3(const DeformableVec3& v, double s) {
|
|
25
|
+
return {v.x * s, v.y * s, v.z * s};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
double dotVec3(const DeformableVec3& a, const DeformableVec3& b) {
|
|
29
|
+
return a.x * b.x + a.y * b.y + a.z * b.z;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
DeformableVec3 crossVec3(const DeformableVec3& a, const DeformableVec3& b) {
|
|
33
|
+
return {
|
|
34
|
+
a.y * b.z - a.z * b.y,
|
|
35
|
+
a.z * b.x - a.x * b.z,
|
|
36
|
+
a.x * b.y - a.y * b.x,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
double lengthSquaredVec3(const DeformableVec3& v) {
|
|
41
|
+
return dotVec3(v, v);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
double lengthVec3(const DeformableVec3& v) {
|
|
45
|
+
const double sq = lengthSquaredVec3(v);
|
|
46
|
+
return sq > 0.0 ? std::sqrt(sq) : 0.0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
DeformableVec3 normalizeVec3(const DeformableVec3& v) {
|
|
50
|
+
const double len = lengthVec3(v);
|
|
51
|
+
if (len <= 1e-15) {
|
|
52
|
+
return {0.0, 1.0, 0.0};
|
|
53
|
+
}
|
|
54
|
+
const double inv = 1.0 / len;
|
|
55
|
+
return {v.x * inv, v.y * inv, v.z * inv};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Deterministic 64-bit FNV-1a Checksum
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
std::uint64_t computeTopologyChecksum(std::span<const double> data) {
|
|
63
|
+
constexpr std::uint64_t kFnvOffsetBasis = 0xcbf29ce484222325ULL;
|
|
64
|
+
constexpr std::uint64_t kFnvPrime = 0x100000001b3ULL;
|
|
65
|
+
|
|
66
|
+
std::uint64_t hash = kFnvOffsetBasis;
|
|
67
|
+
for (std::size_t i = 0; i < data.size(); ++i) {
|
|
68
|
+
std::uint64_t bits = 0;
|
|
69
|
+
std::memcpy(&bits, &data[i], sizeof(bits));
|
|
70
|
+
hash ^= bits;
|
|
71
|
+
hash *= kFnvPrime;
|
|
72
|
+
}
|
|
73
|
+
return hash;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Grid Deformable Mesh Construction (Cloth / Sheet Generator)
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
FractureStatus createGridDeformable(
|
|
81
|
+
DeformableMesh& mesh,
|
|
82
|
+
std::uint32_t gridX,
|
|
83
|
+
std::uint32_t gridY,
|
|
84
|
+
double spacing,
|
|
85
|
+
double totalMass,
|
|
86
|
+
bool pinTopRow) {
|
|
87
|
+
if (gridX < 2 || gridY < 2 || spacing <= 0.0 || totalMass <= 0.0) {
|
|
88
|
+
return FractureStatus::InvalidInput;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const std::uint32_t totalVertices = gridX * gridY;
|
|
92
|
+
if (totalVertices > kFractureMaxVertices) {
|
|
93
|
+
return FractureStatus::CapacityExceeded;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Calculate required constraints:
|
|
97
|
+
// Horizontal: (gridX - 1) * gridY
|
|
98
|
+
// Vertical: gridX * (gridY - 1)
|
|
99
|
+
// Diagonal shear: 2 * (gridX - 1) * (gridY - 1)
|
|
100
|
+
const std::uint32_t horizCount = (gridX - 1) * gridY;
|
|
101
|
+
const std::uint32_t vertCount = gridX * (gridY - 1);
|
|
102
|
+
const std::uint32_t shearCount = 2 * (gridX - 1) * (gridY - 1);
|
|
103
|
+
const std::uint32_t totalConstraints = horizCount + vertCount + shearCount;
|
|
104
|
+
|
|
105
|
+
if (totalConstraints > kFractureMaxConstraints) {
|
|
106
|
+
return FractureStatus::CapacityExceeded;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const std::uint32_t totalFaces = 2 * (gridX - 1) * (gridY - 1);
|
|
110
|
+
if (totalFaces > kFractureMaxFaces) {
|
|
111
|
+
return FractureStatus::CapacityExceeded;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
mesh.vertexCount = totalVertices;
|
|
115
|
+
mesh.constraintCount = 0;
|
|
116
|
+
mesh.faceCount = 0;
|
|
117
|
+
mesh.eventCount = 0;
|
|
118
|
+
mesh.fragmentCount = 1;
|
|
119
|
+
mesh.nextVertexId = 1;
|
|
120
|
+
mesh.nextConstraintId = 1;
|
|
121
|
+
mesh.nextFaceId = 1;
|
|
122
|
+
mesh.nextFragmentId = 2;
|
|
123
|
+
|
|
124
|
+
const double nodeMass = totalMass / static_cast<double>(totalVertices);
|
|
125
|
+
const double halfWidth = static_cast<double>(gridX - 1) * spacing * 0.5;
|
|
126
|
+
|
|
127
|
+
// Initialize vertices
|
|
128
|
+
for (std::uint32_t j = 0; j < gridY; ++j) {
|
|
129
|
+
for (std::uint32_t i = 0; i < gridX; ++i) {
|
|
130
|
+
const std::uint32_t idx = j * gridX + i;
|
|
131
|
+
DeformableVertex& v = mesh.vertices[idx];
|
|
132
|
+
v.id = mesh.nextVertexId++;
|
|
133
|
+
v.x = static_cast<double>(i) * spacing - halfWidth;
|
|
134
|
+
v.y = 5.0 - static_cast<double>(j) * spacing;
|
|
135
|
+
v.z = 0.0;
|
|
136
|
+
v.prevX = v.x;
|
|
137
|
+
v.prevY = v.y;
|
|
138
|
+
v.prevZ = v.z;
|
|
139
|
+
v.vx = 0.0;
|
|
140
|
+
v.vy = 0.0;
|
|
141
|
+
v.vz = 0.0;
|
|
142
|
+
v.mass = nodeMass;
|
|
143
|
+
|
|
144
|
+
const bool isPinned = pinTopRow && (j == 0);
|
|
145
|
+
if (isPinned) {
|
|
146
|
+
v.invMass = 0.0;
|
|
147
|
+
v.flags = kFractureVertexActive | kFractureVertexPinned;
|
|
148
|
+
} else {
|
|
149
|
+
v.invMass = 1.0 / nodeMass;
|
|
150
|
+
v.flags = kFractureVertexActive;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (i == 0 || i == gridX - 1 || j == 0 || j == gridY - 1) {
|
|
154
|
+
v.flags |= kFractureVertexBoundary;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
v.fragmentId = 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Helper lambda to add distance constraint
|
|
162
|
+
auto addConstraint = [&](std::uint32_t a, std::uint32_t b, DeformableConstraintKind kind, double stiffness, double breakTension) {
|
|
163
|
+
if (mesh.constraintCount >= kFractureMaxConstraints) return;
|
|
164
|
+
DeformableConstraint& c = mesh.constraints[mesh.constraintCount++];
|
|
165
|
+
c.id = mesh.nextConstraintId++;
|
|
166
|
+
c.vertexA = a;
|
|
167
|
+
c.vertexB = b;
|
|
168
|
+
const DeformableVec3 posA{mesh.vertices[a].x, mesh.vertices[a].y, mesh.vertices[a].z};
|
|
169
|
+
const DeformableVec3 posB{mesh.vertices[b].x, mesh.vertices[b].y, mesh.vertices[b].z};
|
|
170
|
+
c.restLength = lengthVec3(subVec3(posB, posA));
|
|
171
|
+
c.stiffness = stiffness;
|
|
172
|
+
c.breakTension = breakTension;
|
|
173
|
+
c.currentTension = 0.0;
|
|
174
|
+
c.currentStrain = 0.0;
|
|
175
|
+
c.flags = kFractureConstraintActive;
|
|
176
|
+
c.kind = kind;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// Structural horizontal constraints
|
|
180
|
+
for (std::uint32_t j = 0; j < gridY; ++j) {
|
|
181
|
+
for (std::uint32_t i = 0; i < gridX - 1; ++i) {
|
|
182
|
+
addConstraint(j * gridX + i, j * gridX + (i + 1), DeformableConstraintKind::Distance, 1.0, 50.0);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Structural vertical constraints
|
|
187
|
+
for (std::uint32_t j = 0; j < gridY - 1; ++j) {
|
|
188
|
+
for (std::uint32_t i = 0; i < gridX; ++i) {
|
|
189
|
+
addConstraint(j * gridX + i, (j + 1) * gridX + i, DeformableConstraintKind::Distance, 1.0, 50.0);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Diagonal shear constraints & faces
|
|
194
|
+
for (std::uint32_t j = 0; j < gridY - 1; ++j) {
|
|
195
|
+
for (std::uint32_t i = 0; i < gridX - 1; ++i) {
|
|
196
|
+
const std::uint32_t v0 = j * gridX + i;
|
|
197
|
+
const std::uint32_t v1 = j * gridX + (i + 1);
|
|
198
|
+
const std::uint32_t v2 = (j + 1) * gridX + i;
|
|
199
|
+
const std::uint32_t v3 = (j + 1) * gridX + (i + 1);
|
|
200
|
+
|
|
201
|
+
addConstraint(v0, v3, DeformableConstraintKind::Shear, 0.75, 60.0);
|
|
202
|
+
addConstraint(v1, v2, DeformableConstraintKind::Shear, 0.75, 60.0);
|
|
203
|
+
|
|
204
|
+
// Add 2 triangular faces per quad
|
|
205
|
+
if (mesh.faceCount + 2 <= kFractureMaxFaces) {
|
|
206
|
+
DeformableFace& f1 = mesh.faces[mesh.faceCount++];
|
|
207
|
+
f1.id = mesh.nextFaceId++;
|
|
208
|
+
f1.vertex0 = v0;
|
|
209
|
+
f1.vertex1 = v1;
|
|
210
|
+
f1.vertex2 = v2;
|
|
211
|
+
f1.restArea = spacing * spacing * 0.5;
|
|
212
|
+
f1.flags = kFractureFaceActive;
|
|
213
|
+
f1.fragmentId = 1;
|
|
214
|
+
|
|
215
|
+
DeformableFace& f2 = mesh.faces[mesh.faceCount++];
|
|
216
|
+
f2.id = mesh.nextFaceId++;
|
|
217
|
+
f2.vertex0 = v1;
|
|
218
|
+
f2.vertex1 = v3;
|
|
219
|
+
f2.vertex2 = v2;
|
|
220
|
+
f2.restArea = spacing * spacing * 0.5;
|
|
221
|
+
f2.flags = kFractureFaceActive;
|
|
222
|
+
f2.fragmentId = 1;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return FractureStatus::Success;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ---------------------------------------------------------------------------
|
|
231
|
+
// Step Simulation: XPBD Position Projection & Strain Tearing
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
|
|
234
|
+
FractureStatus stepDeformable(
|
|
235
|
+
DeformableMesh& mesh,
|
|
236
|
+
double dt,
|
|
237
|
+
std::uint64_t tick) {
|
|
238
|
+
if (mesh.vertexCount == 0) {
|
|
239
|
+
return FractureStatus::InvalidMesh;
|
|
240
|
+
}
|
|
241
|
+
if (dt <= 0.0) {
|
|
242
|
+
return FractureStatus::InvalidInput;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Clamp dt to a safe deterministic interval
|
|
246
|
+
if (dt > 0.1) dt = 0.1;
|
|
247
|
+
if (dt < 1e-5) dt = 1e-5;
|
|
248
|
+
|
|
249
|
+
const double gravX = mesh.params.gravityX;
|
|
250
|
+
const double gravY = mesh.params.gravityY;
|
|
251
|
+
const double gravZ = mesh.params.gravityZ;
|
|
252
|
+
const double damping = mesh.params.damping;
|
|
253
|
+
const bool enableGround = mesh.params.enableGround;
|
|
254
|
+
const double groundY = mesh.params.groundY;
|
|
255
|
+
const double friction = mesh.params.groundFriction;
|
|
256
|
+
|
|
257
|
+
// 1. Unconstrained integration (Euler / Verlet predictor)
|
|
258
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
259
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
260
|
+
if (!(v.flags & kFractureVertexActive)) continue;
|
|
261
|
+
if (v.invMass <= 0.0 || (v.flags & kFractureVertexPinned)) continue;
|
|
262
|
+
|
|
263
|
+
v.vx += gravX * dt;
|
|
264
|
+
v.vy += gravY * dt;
|
|
265
|
+
v.vz += gravZ * dt;
|
|
266
|
+
|
|
267
|
+
v.vx *= damping;
|
|
268
|
+
v.vy *= damping;
|
|
269
|
+
v.vz *= damping;
|
|
270
|
+
|
|
271
|
+
v.prevX = v.x;
|
|
272
|
+
v.prevY = v.y;
|
|
273
|
+
v.prevZ = v.z;
|
|
274
|
+
|
|
275
|
+
v.x += v.vx * dt;
|
|
276
|
+
v.y += v.vy * dt;
|
|
277
|
+
v.z += v.vz * dt;
|
|
278
|
+
|
|
279
|
+
// Ground plane collision
|
|
280
|
+
if (enableGround && v.y < groundY) {
|
|
281
|
+
v.y = groundY;
|
|
282
|
+
v.vy = 0.0;
|
|
283
|
+
v.vx *= (1.0 - friction);
|
|
284
|
+
v.vz *= (1.0 - friction);
|
|
285
|
+
v.prevY = v.y;
|
|
286
|
+
v.prevX = v.x - v.vx * dt;
|
|
287
|
+
v.prevZ = v.z - v.vz * dt;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 2. Solve distance constraints (Gauss-Seidel iterations over active constraints)
|
|
292
|
+
std::uint32_t iters = mesh.params.solverIterations;
|
|
293
|
+
if (iters == 0) iters = 1;
|
|
294
|
+
if (iters > 32) iters = 32;
|
|
295
|
+
|
|
296
|
+
for (std::uint32_t iter = 0; iter < iters; ++iter) {
|
|
297
|
+
for (std::uint32_t cIdx = 0; cIdx < mesh.constraintCount; ++cIdx) {
|
|
298
|
+
const DeformableConstraint& c = mesh.constraints[cIdx];
|
|
299
|
+
if (!(c.flags & kFractureConstraintActive)) continue;
|
|
300
|
+
|
|
301
|
+
const std::uint32_t iA = c.vertexA;
|
|
302
|
+
const std::uint32_t iB = c.vertexB;
|
|
303
|
+
if (iA >= mesh.vertexCount || iB >= mesh.vertexCount) continue;
|
|
304
|
+
|
|
305
|
+
DeformableVertex& vA = mesh.vertices[iA];
|
|
306
|
+
DeformableVertex& vB = mesh.vertices[iB];
|
|
307
|
+
if (!(vA.flags & kFractureVertexActive) || !(vB.flags & kFractureVertexActive)) continue;
|
|
308
|
+
|
|
309
|
+
const double wA = vA.invMass;
|
|
310
|
+
const double wB = vB.invMass;
|
|
311
|
+
const double wSum = wA + wB;
|
|
312
|
+
if (wSum <= 1e-15) continue;
|
|
313
|
+
|
|
314
|
+
const double dx = vB.x - vA.x;
|
|
315
|
+
const double dy = vB.y - vA.y;
|
|
316
|
+
const double dz = vB.z - vA.z;
|
|
317
|
+
const double distSq = dx * dx + dy * dy + dz * dz;
|
|
318
|
+
if (distSq <= 1e-24) continue;
|
|
319
|
+
|
|
320
|
+
const double dist = std::sqrt(distSq);
|
|
321
|
+
const double diff = (dist - c.restLength) / dist;
|
|
322
|
+
const double corr = diff * (c.stiffness / wSum);
|
|
323
|
+
|
|
324
|
+
const double cx = dx * corr;
|
|
325
|
+
const double cy = dy * corr;
|
|
326
|
+
const double cz = dz * corr;
|
|
327
|
+
|
|
328
|
+
if (wA > 0.0) {
|
|
329
|
+
vA.x += cx * wA;
|
|
330
|
+
vA.y += cy * wA;
|
|
331
|
+
vA.z += cz * wA;
|
|
332
|
+
}
|
|
333
|
+
if (wB > 0.0) {
|
|
334
|
+
vB.x -= cx * wB;
|
|
335
|
+
vB.y -= cy * wB;
|
|
336
|
+
vB.z -= cz * wB;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 3. Tension / Strain evaluation & Tear detection
|
|
342
|
+
std::uint32_t tearsCount = 0;
|
|
343
|
+
bool topologyChanged = false;
|
|
344
|
+
const double tearMult = mesh.params.tearThresholdMultiplier > 0.0 ? mesh.params.tearThresholdMultiplier : 1.0;
|
|
345
|
+
const std::uint32_t maxTears = std::min(mesh.params.maxTearsPerStep, kFractureMaxTearsPerStep);
|
|
346
|
+
|
|
347
|
+
for (std::uint32_t cIdx = 0; cIdx < mesh.constraintCount; ++cIdx) {
|
|
348
|
+
DeformableConstraint& c = mesh.constraints[cIdx];
|
|
349
|
+
if (!(c.flags & kFractureConstraintActive)) continue;
|
|
350
|
+
|
|
351
|
+
const std::uint32_t iA = c.vertexA;
|
|
352
|
+
const std::uint32_t iB = c.vertexB;
|
|
353
|
+
if (iA >= mesh.vertexCount || iB >= mesh.vertexCount) continue;
|
|
354
|
+
|
|
355
|
+
const DeformableVertex& vA = mesh.vertices[iA];
|
|
356
|
+
const DeformableVertex& vB = mesh.vertices[iB];
|
|
357
|
+
const double dx = vB.x - vA.x;
|
|
358
|
+
const double dy = vB.y - vA.y;
|
|
359
|
+
const double dz = vB.z - vA.z;
|
|
360
|
+
const double dist = std::sqrt(dx * dx + dy * dy + dz * dz);
|
|
361
|
+
|
|
362
|
+
const double strain = (c.restLength > 1e-12) ? ((dist - c.restLength) / c.restLength) : 0.0;
|
|
363
|
+
const double tension = c.stiffness * (dist - c.restLength);
|
|
364
|
+
c.currentStrain = strain;
|
|
365
|
+
c.currentTension = tension;
|
|
366
|
+
|
|
367
|
+
const double limit = c.breakTension * tearMult;
|
|
368
|
+
if (c.breakTension > 0.0 && tension > limit) {
|
|
369
|
+
if (tearsCount < maxTears && mesh.eventCount < kFractureMaxEvents) {
|
|
370
|
+
c.flags &= ~kFractureConstraintActive;
|
|
371
|
+
c.flags |= kFractureConstraintTorn;
|
|
372
|
+
topologyChanged = true;
|
|
373
|
+
|
|
374
|
+
DeformableEvent evt{};
|
|
375
|
+
evt.type = DeformableEventType::Tear;
|
|
376
|
+
evt.tick = tick;
|
|
377
|
+
evt.elementId = c.id;
|
|
378
|
+
evt.relatedId = vA.id;
|
|
379
|
+
evt.metric = tension;
|
|
380
|
+
evt.posX = 0.5 * (vA.x + vB.x);
|
|
381
|
+
evt.posY = 0.5 * (vA.y + vB.y);
|
|
382
|
+
evt.posZ = 0.5 * (vA.z + vB.z);
|
|
383
|
+
evt.fragmentId = vA.fragmentId;
|
|
384
|
+
evt.subIndex = tearsCount;
|
|
385
|
+
mesh.events[mesh.eventCount++] = evt;
|
|
386
|
+
tearsCount++;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// 4. Update velocity from position delta
|
|
392
|
+
const double invDt = 1.0 / dt;
|
|
393
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
394
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
395
|
+
if (!(v.flags & kFractureVertexActive)) continue;
|
|
396
|
+
if (v.invMass <= 0.0 || (v.flags & kFractureVertexPinned)) continue;
|
|
397
|
+
|
|
398
|
+
v.vx = (v.x - v.prevX) * invDt;
|
|
399
|
+
v.vy = (v.y - v.prevY) * invDt;
|
|
400
|
+
v.vz = (v.z - v.prevZ) * invDt;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// 5. If any tear occurred, update component topology and emit fracture events
|
|
404
|
+
if (topologyChanged) {
|
|
405
|
+
findConnectedComponents(mesh, tick);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// 6. Ensure event order is strictly canonical
|
|
409
|
+
std::stable_sort(mesh.events.begin(), mesh.events.begin() + mesh.eventCount);
|
|
410
|
+
|
|
411
|
+
return FractureStatus::Success;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// ---------------------------------------------------------------------------
|
|
415
|
+
// Geometric Cutting Tool Execution
|
|
416
|
+
// ---------------------------------------------------------------------------
|
|
417
|
+
|
|
418
|
+
FractureStatus cutDeformable(
|
|
419
|
+
DeformableMesh& mesh,
|
|
420
|
+
const CuttingTool& tool,
|
|
421
|
+
std::uint64_t tick) {
|
|
422
|
+
if (mesh.vertexCount == 0) {
|
|
423
|
+
return FractureStatus::InvalidMesh;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const double normLen = lengthVec3(tool.normal);
|
|
427
|
+
if (normLen <= 1e-15) {
|
|
428
|
+
return FractureStatus::InvalidCut;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const DeformableVec3 unitNormal = normalizeVec3(tool.normal);
|
|
432
|
+
const DeformableVec3 unitT1 = normalizeVec3(tool.tangent1);
|
|
433
|
+
const DeformableVec3 unitT2 = normalizeVec3(tool.tangent2);
|
|
434
|
+
|
|
435
|
+
std::uint32_t cutsCount = 0;
|
|
436
|
+
bool topologyChanged = false;
|
|
437
|
+
const std::uint32_t maxCuts = std::min(tool.maxCuts, kFractureMaxCutsPerStep);
|
|
438
|
+
const std::uint32_t initialConstraintCount = mesh.constraintCount;
|
|
439
|
+
|
|
440
|
+
for (std::uint32_t cIdx = 0; cIdx < initialConstraintCount; ++cIdx) {
|
|
441
|
+
DeformableConstraint& c = mesh.constraints[cIdx];
|
|
442
|
+
if (!(c.flags & kFractureConstraintActive)) continue;
|
|
443
|
+
|
|
444
|
+
const std::uint32_t iA = c.vertexA;
|
|
445
|
+
const std::uint32_t iB = c.vertexB;
|
|
446
|
+
if (iA >= mesh.vertexCount || iB >= mesh.vertexCount) continue;
|
|
447
|
+
|
|
448
|
+
DeformableVertex& vA = mesh.vertices[iA];
|
|
449
|
+
DeformableVertex& vB = mesh.vertices[iB];
|
|
450
|
+
if (!(vA.flags & kFractureVertexActive) || !(vB.flags & kFractureVertexActive)) continue;
|
|
451
|
+
|
|
452
|
+
const DeformableVec3 posA{vA.x, vA.y, vA.z};
|
|
453
|
+
const DeformableVec3 posB{vB.x, vB.y, vB.z};
|
|
454
|
+
|
|
455
|
+
const double dA = dotVec3(subVec3(posA, tool.origin), unitNormal);
|
|
456
|
+
const double dB = dotVec3(subVec3(posB, tool.origin), unitNormal);
|
|
457
|
+
|
|
458
|
+
// Crossing condition: endpoints strictly on opposite sides of cutting plane
|
|
459
|
+
if ((dA > 1e-9 && dB < -1e-9) || (dA < -1e-9 && dB > 1e-9)) {
|
|
460
|
+
const double t = dA / (dA - dB);
|
|
461
|
+
if (t > 1e-6 && t < 1.0 - 1e-6) {
|
|
462
|
+
const DeformableVec3 P = addVec3(posA, scaleVec3(subVec3(posB, posA), t));
|
|
463
|
+
const DeformableVec3 rel = subVec3(P, tool.origin);
|
|
464
|
+
const double pu = dotVec3(rel, unitT1);
|
|
465
|
+
const double pv = dotVec3(rel, unitT2);
|
|
466
|
+
|
|
467
|
+
bool inBounds = true;
|
|
468
|
+
if (tool.halfWidth > 0.0 && std::abs(pu) > tool.halfWidth) inBounds = false;
|
|
469
|
+
if (tool.halfHeight > 0.0 && std::abs(pv) > tool.halfHeight) inBounds = false;
|
|
470
|
+
|
|
471
|
+
if (inBounds && cutsCount < maxCuts && mesh.eventCount < kFractureMaxEvents) {
|
|
472
|
+
if (tool.mode == CutMode::SeverOnly) {
|
|
473
|
+
// Mode 0: Sever constraint directly
|
|
474
|
+
c.flags &= ~kFractureConstraintActive;
|
|
475
|
+
c.flags |= kFractureConstraintCut;
|
|
476
|
+
topologyChanged = true;
|
|
477
|
+
|
|
478
|
+
DeformableEvent evt{};
|
|
479
|
+
evt.type = DeformableEventType::Cut;
|
|
480
|
+
evt.tick = tick;
|
|
481
|
+
evt.elementId = c.id;
|
|
482
|
+
evt.relatedId = 0;
|
|
483
|
+
evt.metric = t;
|
|
484
|
+
evt.posX = P.x;
|
|
485
|
+
evt.posY = P.y;
|
|
486
|
+
evt.posZ = P.z;
|
|
487
|
+
evt.fragmentId = vA.fragmentId;
|
|
488
|
+
evt.subIndex = cutsCount;
|
|
489
|
+
mesh.events[mesh.eventCount++] = evt;
|
|
490
|
+
cutsCount++;
|
|
491
|
+
} else if (tool.mode == CutMode::SplitEdgeConserveMass) {
|
|
492
|
+
// Mode 1: Subdivide edge and insert new node with exact mass & momentum conservation
|
|
493
|
+
if (mesh.vertexCount < kFractureMaxVertices && mesh.constraintCount < kFractureMaxConstraints) {
|
|
494
|
+
const std::uint32_t idxC = mesh.vertexCount++;
|
|
495
|
+
const std::uint64_t newVertexId = mesh.nextVertexId++;
|
|
496
|
+
const std::uint64_t newConstraintId = mesh.nextConstraintId++;
|
|
497
|
+
|
|
498
|
+
// Partition mass:
|
|
499
|
+
// Transfer alpha = 0.25 of local parent mass to new node
|
|
500
|
+
// Conserves total mass and linear momentum exactly:
|
|
501
|
+
// m_C = alpha * (m_A + m_B)
|
|
502
|
+
// dm_A = m_C * (1 - t)
|
|
503
|
+
// dm_B = m_C * t
|
|
504
|
+
// m_A' = m_A - dm_A
|
|
505
|
+
// m_B' = m_B - dm_B
|
|
506
|
+
// Sum: m_A' + m_B' + m_C == m_A + m_B
|
|
507
|
+
const double alpha = 0.25;
|
|
508
|
+
const double mA = vA.mass;
|
|
509
|
+
const double mB = vB.mass;
|
|
510
|
+
const double mC = alpha * (mA + mB);
|
|
511
|
+
const double dmA = mC * (1.0 - t);
|
|
512
|
+
const double dmB = mC * t;
|
|
513
|
+
|
|
514
|
+
vA.mass -= dmA;
|
|
515
|
+
vB.mass -= dmB;
|
|
516
|
+
if (vA.invMass > 0.0) vA.invMass = 1.0 / vA.mass;
|
|
517
|
+
if (vB.invMass > 0.0) vB.invMass = 1.0 / vB.mass;
|
|
518
|
+
|
|
519
|
+
DeformableVertex& vC = mesh.vertices[idxC];
|
|
520
|
+
vC.id = newVertexId;
|
|
521
|
+
vC.x = P.x;
|
|
522
|
+
vC.y = P.y;
|
|
523
|
+
vC.z = P.z;
|
|
524
|
+
vC.prevX = (1.0 - t) * vA.prevX + t * vB.prevX;
|
|
525
|
+
vC.prevY = (1.0 - t) * vA.prevY + t * vB.prevY;
|
|
526
|
+
vC.prevZ = (1.0 - t) * vA.prevZ + t * vB.prevZ;
|
|
527
|
+
vC.vx = (1.0 - t) * vA.vx + t * vB.vx;
|
|
528
|
+
vC.vy = (1.0 - t) * vA.vy + t * vB.vy;
|
|
529
|
+
vC.vz = (1.0 - t) * vA.vz + t * vB.vz;
|
|
530
|
+
vC.mass = mC;
|
|
531
|
+
vC.invMass = 1.0 / mC;
|
|
532
|
+
vC.flags = kFractureVertexActive;
|
|
533
|
+
vC.fragmentId = vA.fragmentId;
|
|
534
|
+
|
|
535
|
+
// Retain original constraint ID for segment A -> C
|
|
536
|
+
const double oldRestLen = c.restLength;
|
|
537
|
+
const std::uint32_t oldB = c.vertexB;
|
|
538
|
+
c.vertexB = idxC;
|
|
539
|
+
c.restLength = oldRestLen * t;
|
|
540
|
+
|
|
541
|
+
// Add new constraint for segment C -> B with new stable ID
|
|
542
|
+
const std::uint32_t idxNewC = mesh.constraintCount++;
|
|
543
|
+
DeformableConstraint& cNew = mesh.constraints[idxNewC];
|
|
544
|
+
cNew.id = newConstraintId;
|
|
545
|
+
cNew.vertexA = idxC;
|
|
546
|
+
cNew.vertexB = oldB;
|
|
547
|
+
cNew.restLength = oldRestLen * (1.0 - t);
|
|
548
|
+
cNew.stiffness = c.stiffness;
|
|
549
|
+
cNew.breakTension = c.breakTension;
|
|
550
|
+
cNew.currentTension = 0.0;
|
|
551
|
+
cNew.currentStrain = 0.0;
|
|
552
|
+
cNew.flags = kFractureConstraintActive;
|
|
553
|
+
cNew.kind = c.kind;
|
|
554
|
+
|
|
555
|
+
topologyChanged = true;
|
|
556
|
+
|
|
557
|
+
DeformableEvent evt{};
|
|
558
|
+
evt.type = DeformableEventType::Cut;
|
|
559
|
+
evt.tick = tick;
|
|
560
|
+
evt.elementId = c.id;
|
|
561
|
+
evt.relatedId = newVertexId;
|
|
562
|
+
evt.metric = t;
|
|
563
|
+
evt.posX = P.x;
|
|
564
|
+
evt.posY = P.y;
|
|
565
|
+
evt.posZ = P.z;
|
|
566
|
+
evt.fragmentId = vA.fragmentId;
|
|
567
|
+
evt.subIndex = cutsCount;
|
|
568
|
+
mesh.events[mesh.eventCount++] = evt;
|
|
569
|
+
cutsCount++;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (topologyChanged) {
|
|
578
|
+
findConnectedComponents(mesh, tick);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
std::stable_sort(mesh.events.begin(), mesh.events.begin() + mesh.eventCount);
|
|
582
|
+
|
|
583
|
+
return FractureStatus::Success;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// ---------------------------------------------------------------------------
|
|
587
|
+
// Explicit Constraint Tear
|
|
588
|
+
// ---------------------------------------------------------------------------
|
|
589
|
+
|
|
590
|
+
FractureStatus tearDeformableConstraint(
|
|
591
|
+
DeformableMesh& mesh,
|
|
592
|
+
std::uint64_t constraintId,
|
|
593
|
+
std::uint64_t tick) {
|
|
594
|
+
for (std::uint32_t i = 0; i < mesh.constraintCount; ++i) {
|
|
595
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
596
|
+
if (c.id == constraintId && (c.flags & kFractureConstraintActive)) {
|
|
597
|
+
c.flags &= ~kFractureConstraintActive;
|
|
598
|
+
c.flags |= kFractureConstraintTorn;
|
|
599
|
+
|
|
600
|
+
if (mesh.eventCount < kFractureMaxEvents) {
|
|
601
|
+
const DeformableVertex& vA = mesh.vertices[c.vertexA];
|
|
602
|
+
const DeformableVertex& vB = mesh.vertices[c.vertexB];
|
|
603
|
+
|
|
604
|
+
DeformableEvent evt{};
|
|
605
|
+
evt.type = DeformableEventType::Tear;
|
|
606
|
+
evt.tick = tick;
|
|
607
|
+
evt.elementId = c.id;
|
|
608
|
+
evt.relatedId = vA.id;
|
|
609
|
+
evt.metric = c.currentTension;
|
|
610
|
+
evt.posX = 0.5 * (vA.x + vB.x);
|
|
611
|
+
evt.posY = 0.5 * (vA.y + vB.y);
|
|
612
|
+
evt.posZ = 0.5 * (vA.z + vB.z);
|
|
613
|
+
evt.fragmentId = vA.fragmentId;
|
|
614
|
+
evt.subIndex = 0;
|
|
615
|
+
mesh.events[mesh.eventCount++] = evt;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
findConnectedComponents(mesh, tick);
|
|
619
|
+
std::stable_sort(mesh.events.begin(), mesh.events.begin() + mesh.eventCount);
|
|
620
|
+
return FractureStatus::Success;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return FractureStatus::InvalidInput;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// ---------------------------------------------------------------------------
|
|
628
|
+
// Vertex Splitting (Tearing along a crack tip)
|
|
629
|
+
// ---------------------------------------------------------------------------
|
|
630
|
+
|
|
631
|
+
FractureStatus splitDeformableVertex(
|
|
632
|
+
DeformableMesh& mesh,
|
|
633
|
+
std::uint64_t vertexId,
|
|
634
|
+
double splitFraction,
|
|
635
|
+
std::uint64_t tick) {
|
|
636
|
+
if (splitFraction <= 0.01 || splitFraction >= 0.99) {
|
|
637
|
+
return FractureStatus::InvalidInput;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
if (mesh.vertexCount >= kFractureMaxVertices) {
|
|
641
|
+
return FractureStatus::CapacityExceeded;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
std::int32_t foundIdx = -1;
|
|
645
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
646
|
+
if (mesh.vertices[i].id == vertexId && (mesh.vertices[i].flags & kFractureVertexActive)) {
|
|
647
|
+
foundIdx = static_cast<std::int32_t>(i);
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (foundIdx < 0) {
|
|
653
|
+
return FractureStatus::InvalidInput;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
const std::uint32_t origIdx = static_cast<std::uint32_t>(foundIdx);
|
|
657
|
+
const std::uint32_t newIdx = mesh.vertexCount++;
|
|
658
|
+
DeformableVertex& origV = mesh.vertices[origIdx];
|
|
659
|
+
DeformableVertex& newV = mesh.vertices[newIdx];
|
|
660
|
+
|
|
661
|
+
const std::uint64_t newVertexId = mesh.nextVertexId++;
|
|
662
|
+
|
|
663
|
+
// Mass partition: conserved bit-for-bit
|
|
664
|
+
const double origMass = origV.mass;
|
|
665
|
+
const double newMass = origMass * splitFraction;
|
|
666
|
+
const double remainingMass = origMass - newMass;
|
|
667
|
+
|
|
668
|
+
origV.mass = remainingMass;
|
|
669
|
+
if (origV.invMass > 0.0) origV.invMass = 1.0 / remainingMass;
|
|
670
|
+
|
|
671
|
+
newV = origV;
|
|
672
|
+
newV.id = newVertexId;
|
|
673
|
+
newV.mass = newMass;
|
|
674
|
+
if (newV.invMass > 0.0) newV.invMass = 1.0 / newMass;
|
|
675
|
+
newV.flags |= kFractureVertexSplit;
|
|
676
|
+
|
|
677
|
+
// Rewire approximately half of active incident constraints to the new vertex
|
|
678
|
+
std::uint32_t incidentCount = 0;
|
|
679
|
+
for (std::uint32_t i = 0; i < mesh.constraintCount; ++i) {
|
|
680
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
681
|
+
if (!(c.flags & kFractureConstraintActive)) continue;
|
|
682
|
+
|
|
683
|
+
if (c.vertexA == origIdx) {
|
|
684
|
+
if ((incidentCount % 2) == 1) {
|
|
685
|
+
c.vertexA = newIdx;
|
|
686
|
+
}
|
|
687
|
+
incidentCount++;
|
|
688
|
+
} else if (c.vertexB == origIdx) {
|
|
689
|
+
if ((incidentCount % 2) == 1) {
|
|
690
|
+
c.vertexB = newIdx;
|
|
691
|
+
}
|
|
692
|
+
incidentCount++;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (mesh.eventCount < kFractureMaxEvents) {
|
|
697
|
+
DeformableEvent evt{};
|
|
698
|
+
evt.type = DeformableEventType::Tear;
|
|
699
|
+
evt.tick = tick;
|
|
700
|
+
evt.elementId = vertexId;
|
|
701
|
+
evt.relatedId = newVertexId;
|
|
702
|
+
evt.metric = splitFraction;
|
|
703
|
+
evt.posX = origV.x;
|
|
704
|
+
evt.posY = origV.y;
|
|
705
|
+
evt.posZ = origV.z;
|
|
706
|
+
evt.fragmentId = origV.fragmentId;
|
|
707
|
+
evt.subIndex = 0;
|
|
708
|
+
mesh.events[mesh.eventCount++] = evt;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
findConnectedComponents(mesh, tick);
|
|
712
|
+
std::stable_sort(mesh.events.begin(), mesh.events.begin() + mesh.eventCount);
|
|
713
|
+
|
|
714
|
+
return FractureStatus::Success;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// ---------------------------------------------------------------------------
|
|
718
|
+
// Connected Components (BFS Fragment Partitioner)
|
|
719
|
+
// ---------------------------------------------------------------------------
|
|
720
|
+
|
|
721
|
+
FractureStatus findConnectedComponents(
|
|
722
|
+
DeformableMesh& mesh,
|
|
723
|
+
std::uint64_t tick) {
|
|
724
|
+
if (mesh.vertexCount == 0) {
|
|
725
|
+
mesh.fragmentCount = 0;
|
|
726
|
+
return FractureStatus::Success;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
std::array<std::uint32_t, kFractureMaxVertices> visited{};
|
|
730
|
+
std::array<std::uint32_t, kFractureMaxVertices> bfsQueue{};
|
|
731
|
+
|
|
732
|
+
std::uint32_t currentComponent = 0;
|
|
733
|
+
const std::uint32_t previousFragments = mesh.fragmentCount;
|
|
734
|
+
|
|
735
|
+
for (std::uint32_t startIdx = 0; startIdx < mesh.vertexCount; ++startIdx) {
|
|
736
|
+
if (!(mesh.vertices[startIdx].flags & kFractureVertexActive)) continue;
|
|
737
|
+
if (visited[startIdx] != 0) continue;
|
|
738
|
+
|
|
739
|
+
currentComponent++;
|
|
740
|
+
std::uint32_t head = 0;
|
|
741
|
+
std::uint32_t tail = 0;
|
|
742
|
+
|
|
743
|
+
visited[startIdx] = currentComponent;
|
|
744
|
+
mesh.vertices[startIdx].fragmentId = currentComponent;
|
|
745
|
+
bfsQueue[tail++] = startIdx;
|
|
746
|
+
|
|
747
|
+
while (head < tail) {
|
|
748
|
+
const std::uint32_t u = bfsQueue[head++];
|
|
749
|
+
|
|
750
|
+
for (std::uint32_t cIdx = 0; cIdx < mesh.constraintCount; ++cIdx) {
|
|
751
|
+
const DeformableConstraint& c = mesh.constraints[cIdx];
|
|
752
|
+
if (!(c.flags & kFractureConstraintActive)) continue;
|
|
753
|
+
|
|
754
|
+
std::uint32_t neighbor = std::numeric_limits<std::uint32_t>::max();
|
|
755
|
+
if (c.vertexA == u) {
|
|
756
|
+
neighbor = c.vertexB;
|
|
757
|
+
} else if (c.vertexB == u) {
|
|
758
|
+
neighbor = c.vertexA;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (neighbor < mesh.vertexCount && (mesh.vertices[neighbor].flags & kFractureVertexActive)) {
|
|
762
|
+
if (visited[neighbor] == 0) {
|
|
763
|
+
visited[neighbor] = currentComponent;
|
|
764
|
+
mesh.vertices[neighbor].fragmentId = currentComponent;
|
|
765
|
+
if (tail < kFractureMaxVertices) {
|
|
766
|
+
bfsQueue[tail++] = neighbor;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
mesh.fragmentCount = currentComponent;
|
|
775
|
+
|
|
776
|
+
// Emit fracture event if new fragments emerged
|
|
777
|
+
if (currentComponent > previousFragments && mesh.eventCount < kFractureMaxEvents) {
|
|
778
|
+
DeformableEvent evt{};
|
|
779
|
+
evt.type = DeformableEventType::Fracture;
|
|
780
|
+
evt.tick = tick;
|
|
781
|
+
evt.elementId = currentComponent;
|
|
782
|
+
evt.relatedId = previousFragments;
|
|
783
|
+
evt.metric = static_cast<double>(currentComponent);
|
|
784
|
+
evt.posX = 0.0;
|
|
785
|
+
evt.posY = 0.0;
|
|
786
|
+
evt.posZ = 0.0;
|
|
787
|
+
evt.fragmentId = currentComponent;
|
|
788
|
+
evt.subIndex = 0;
|
|
789
|
+
mesh.events[mesh.eventCount++] = evt;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// Update faces fragment IDs
|
|
793
|
+
for (std::uint32_t i = 0; i < mesh.faceCount; ++i) {
|
|
794
|
+
DeformableFace& f = mesh.faces[i];
|
|
795
|
+
if (f.vertex0 < mesh.vertexCount) {
|
|
796
|
+
f.fragmentId = mesh.vertices[f.vertex0].fragmentId;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
return FractureStatus::Success;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// ---------------------------------------------------------------------------
|
|
804
|
+
// Mass and Momentum Conservation Audit
|
|
805
|
+
// ---------------------------------------------------------------------------
|
|
806
|
+
|
|
807
|
+
DeformableAudit auditMassAndMomentum(
|
|
808
|
+
const DeformableMesh& initialMesh,
|
|
809
|
+
const DeformableMesh& currentMesh) {
|
|
810
|
+
DeformableAudit audit{};
|
|
811
|
+
|
|
812
|
+
// Compute initial mass and linear momentum
|
|
813
|
+
for (std::uint32_t i = 0; i < initialMesh.vertexCount; ++i) {
|
|
814
|
+
const DeformableVertex& v = initialMesh.vertices[i];
|
|
815
|
+
if (v.flags & kFractureVertexActive) {
|
|
816
|
+
audit.initialMass += v.mass;
|
|
817
|
+
audit.initialLinearMomentumX += v.mass * v.vx;
|
|
818
|
+
audit.initialLinearMomentumY += v.mass * v.vy;
|
|
819
|
+
audit.initialLinearMomentumZ += v.mass * v.vz;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// Compute current mass and linear momentum
|
|
824
|
+
for (std::uint32_t i = 0; i < currentMesh.vertexCount; ++i) {
|
|
825
|
+
const DeformableVertex& v = currentMesh.vertices[i];
|
|
826
|
+
if (v.flags & kFractureVertexActive) {
|
|
827
|
+
audit.finalMass += v.mass;
|
|
828
|
+
audit.finalLinearMomentumX += v.mass * v.vx;
|
|
829
|
+
audit.finalLinearMomentumY += v.mass * v.vy;
|
|
830
|
+
audit.finalLinearMomentumZ += v.mass * v.vz;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
audit.massError = std::abs(audit.finalMass - audit.initialMass);
|
|
835
|
+
audit.massPreserved = (audit.massError <= 1e-11);
|
|
836
|
+
|
|
837
|
+
const double dPx = audit.finalLinearMomentumX - audit.initialLinearMomentumX;
|
|
838
|
+
const double dPy = audit.finalLinearMomentumY - audit.initialLinearMomentumY;
|
|
839
|
+
const double dPz = audit.finalLinearMomentumZ - audit.initialLinearMomentumZ;
|
|
840
|
+
audit.linearMomentumError = std::sqrt(dPx * dPx + dPy * dPy + dPz * dPz);
|
|
841
|
+
audit.linearPreserved = (audit.linearMomentumError <= 1e-11);
|
|
842
|
+
|
|
843
|
+
// Compute angular momentum
|
|
844
|
+
if (audit.finalMass > 0.0) {
|
|
845
|
+
DeformableVec3 com{0.0, 0.0, 0.0};
|
|
846
|
+
for (std::uint32_t i = 0; i < currentMesh.vertexCount; ++i) {
|
|
847
|
+
const DeformableVertex& v = currentMesh.vertices[i];
|
|
848
|
+
if (v.flags & kFractureVertexActive) {
|
|
849
|
+
com.x += v.mass * v.x;
|
|
850
|
+
com.y += v.mass * v.y;
|
|
851
|
+
com.z += v.mass * v.z;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
const double invM = 1.0 / audit.finalMass;
|
|
855
|
+
com.x *= invM;
|
|
856
|
+
com.y *= invM;
|
|
857
|
+
com.z *= invM;
|
|
858
|
+
|
|
859
|
+
DeformableVec3 angMom{0.0, 0.0, 0.0};
|
|
860
|
+
for (std::uint32_t i = 0; i < currentMesh.vertexCount; ++i) {
|
|
861
|
+
const DeformableVertex& v = currentMesh.vertices[i];
|
|
862
|
+
if (v.flags & kFractureVertexActive) {
|
|
863
|
+
const DeformableVec3 r{v.x - com.x, v.y - com.y, v.z - com.z};
|
|
864
|
+
const DeformableVec3 p{v.mass * v.vx, v.mass * v.vy, v.mass * v.vz};
|
|
865
|
+
const DeformableVec3 L = crossVec3(r, p);
|
|
866
|
+
angMom = addVec3(angMom, L);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
audit.initialAngularMomentumX = angMom.x;
|
|
870
|
+
audit.initialAngularMomentumY = angMom.y;
|
|
871
|
+
audit.initialAngularMomentumZ = angMom.z;
|
|
872
|
+
audit.angularPreserved = true;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
return audit;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// ---------------------------------------------------------------------------
|
|
879
|
+
// Binary Topology Snapshot: Capture and Restore
|
|
880
|
+
// ---------------------------------------------------------------------------
|
|
881
|
+
|
|
882
|
+
FractureStatus captureDeformableSnapshot(
|
|
883
|
+
const DeformableMesh& mesh,
|
|
884
|
+
std::span<double> outBuffer,
|
|
885
|
+
std::uint32_t& doublesWritten) {
|
|
886
|
+
const std::uint32_t requiredDoubles =
|
|
887
|
+
kFractureSnapshotHeaderStride +
|
|
888
|
+
mesh.vertexCount * kFractureVertexStride +
|
|
889
|
+
mesh.constraintCount * kFractureConstraintStride +
|
|
890
|
+
mesh.faceCount * kFractureFaceStride +
|
|
891
|
+
mesh.eventCount * kFractureEventStride;
|
|
892
|
+
|
|
893
|
+
if (outBuffer.size() < requiredDoubles) {
|
|
894
|
+
return FractureStatus::CapacityExceeded;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
std::uint32_t offset = kFractureSnapshotHeaderStride;
|
|
898
|
+
|
|
899
|
+
// 1. Pack vertices
|
|
900
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
901
|
+
const DeformableVertex& v = mesh.vertices[i];
|
|
902
|
+
outBuffer[offset + 0] = static_cast<double>(v.id);
|
|
903
|
+
outBuffer[offset + 1] = v.x;
|
|
904
|
+
outBuffer[offset + 2] = v.y;
|
|
905
|
+
outBuffer[offset + 3] = v.z;
|
|
906
|
+
outBuffer[offset + 4] = v.prevX;
|
|
907
|
+
outBuffer[offset + 5] = v.prevY;
|
|
908
|
+
outBuffer[offset + 6] = v.prevZ;
|
|
909
|
+
outBuffer[offset + 7] = v.vx;
|
|
910
|
+
outBuffer[offset + 8] = v.vy;
|
|
911
|
+
outBuffer[offset + 9] = v.vz;
|
|
912
|
+
outBuffer[offset + 10] = v.mass;
|
|
913
|
+
outBuffer[offset + 11] = v.invMass;
|
|
914
|
+
outBuffer[offset + 12] = static_cast<double>(v.flags);
|
|
915
|
+
outBuffer[offset + 13] = static_cast<double>(v.fragmentId);
|
|
916
|
+
offset += kFractureVertexStride;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// 2. Pack constraints
|
|
920
|
+
for (std::uint32_t i = 0; i < mesh.constraintCount; ++i) {
|
|
921
|
+
const DeformableConstraint& c = mesh.constraints[i];
|
|
922
|
+
outBuffer[offset + 0] = static_cast<double>(c.id);
|
|
923
|
+
outBuffer[offset + 1] = static_cast<double>(c.vertexA);
|
|
924
|
+
outBuffer[offset + 2] = static_cast<double>(c.vertexB);
|
|
925
|
+
outBuffer[offset + 3] = c.restLength;
|
|
926
|
+
outBuffer[offset + 4] = c.stiffness;
|
|
927
|
+
outBuffer[offset + 5] = c.breakTension;
|
|
928
|
+
outBuffer[offset + 6] = c.currentTension;
|
|
929
|
+
outBuffer[offset + 7] = static_cast<double>(c.flags);
|
|
930
|
+
outBuffer[offset + 8] = static_cast<double>(c.kind);
|
|
931
|
+
outBuffer[offset + 9] = c.currentStrain;
|
|
932
|
+
offset += kFractureConstraintStride;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// 3. Pack faces
|
|
936
|
+
for (std::uint32_t i = 0; i < mesh.faceCount; ++i) {
|
|
937
|
+
const DeformableFace& f = mesh.faces[i];
|
|
938
|
+
outBuffer[offset + 0] = static_cast<double>(f.id);
|
|
939
|
+
outBuffer[offset + 1] = static_cast<double>(f.vertex0);
|
|
940
|
+
outBuffer[offset + 2] = static_cast<double>(f.vertex1);
|
|
941
|
+
outBuffer[offset + 3] = static_cast<double>(f.vertex2);
|
|
942
|
+
outBuffer[offset + 4] = f.restArea;
|
|
943
|
+
outBuffer[offset + 5] = static_cast<double>(f.flags);
|
|
944
|
+
outBuffer[offset + 6] = static_cast<double>(f.fragmentId);
|
|
945
|
+
outBuffer[offset + 7] = f.reserved;
|
|
946
|
+
offset += kFractureFaceStride;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// 4. Pack events
|
|
950
|
+
for (std::uint32_t i = 0; i < mesh.eventCount; ++i) {
|
|
951
|
+
const DeformableEvent& e = mesh.events[i];
|
|
952
|
+
outBuffer[offset + 0] = static_cast<double>(e.type);
|
|
953
|
+
outBuffer[offset + 1] = static_cast<double>(e.tick);
|
|
954
|
+
outBuffer[offset + 2] = static_cast<double>(e.elementId);
|
|
955
|
+
outBuffer[offset + 3] = static_cast<double>(e.relatedId);
|
|
956
|
+
outBuffer[offset + 4] = e.metric;
|
|
957
|
+
outBuffer[offset + 5] = e.posX;
|
|
958
|
+
outBuffer[offset + 6] = e.posY;
|
|
959
|
+
outBuffer[offset + 7] = e.posZ;
|
|
960
|
+
outBuffer[offset + 8] = static_cast<double>(e.fragmentId);
|
|
961
|
+
outBuffer[offset + 9] = static_cast<double>(e.subIndex);
|
|
962
|
+
offset += kFractureEventStride;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// Compute checksum over payload
|
|
966
|
+
const std::span<const double> payloadSpan(outBuffer.data() + kFractureSnapshotHeaderStride, offset - kFractureSnapshotHeaderStride);
|
|
967
|
+
const std::uint64_t hash = computeTopologyChecksum(payloadSpan);
|
|
968
|
+
|
|
969
|
+
// Compute total mass
|
|
970
|
+
double totalMass = 0.0;
|
|
971
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
972
|
+
if (mesh.vertices[i].flags & kFractureVertexActive) {
|
|
973
|
+
totalMass += mesh.vertices[i].mass;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// 0. Pack header
|
|
978
|
+
outBuffer[0] = static_cast<double>(kFractureSnapshotMagic);
|
|
979
|
+
outBuffer[1] = static_cast<double>(kFractureAbiVersion);
|
|
980
|
+
outBuffer[2] = static_cast<double>(mesh.vertexCount);
|
|
981
|
+
outBuffer[3] = static_cast<double>(mesh.constraintCount);
|
|
982
|
+
outBuffer[4] = static_cast<double>(mesh.faceCount);
|
|
983
|
+
outBuffer[5] = static_cast<double>(mesh.eventCount);
|
|
984
|
+
outBuffer[6] = static_cast<double>(mesh.fragmentCount);
|
|
985
|
+
outBuffer[7] = static_cast<double>(mesh.nextVertexId);
|
|
986
|
+
outBuffer[8] = static_cast<double>(mesh.nextConstraintId);
|
|
987
|
+
outBuffer[9] = static_cast<double>(mesh.nextFaceId);
|
|
988
|
+
outBuffer[10] = static_cast<double>(mesh.nextFragmentId);
|
|
989
|
+
outBuffer[11] = totalMass;
|
|
990
|
+
outBuffer[12] = static_cast<double>(hash & 0xFFFFFFFFULL);
|
|
991
|
+
outBuffer[13] = static_cast<double>((hash >> 32) & 0xFFFFFFFFULL);
|
|
992
|
+
outBuffer[14] = 0.0;
|
|
993
|
+
outBuffer[15] = 0.0;
|
|
994
|
+
|
|
995
|
+
doublesWritten = offset;
|
|
996
|
+
return FractureStatus::Success;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
FractureStatus restoreDeformableSnapshot(
|
|
1000
|
+
std::span<const double> inBuffer,
|
|
1001
|
+
DeformableMesh& mesh) {
|
|
1002
|
+
if (inBuffer.size() < kFractureSnapshotHeaderStride) {
|
|
1003
|
+
return FractureStatus::InvalidSnapshot;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
const auto magic = static_cast<std::uint32_t>(inBuffer[0]);
|
|
1007
|
+
const auto version = static_cast<std::uint32_t>(inBuffer[1]);
|
|
1008
|
+
if (magic != kFractureSnapshotMagic || version != kFractureAbiVersion) {
|
|
1009
|
+
return FractureStatus::InvalidSnapshot;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
const auto vertexCount = static_cast<std::uint32_t>(inBuffer[2]);
|
|
1013
|
+
const auto constraintCount = static_cast<std::uint32_t>(inBuffer[3]);
|
|
1014
|
+
const auto faceCount = static_cast<std::uint32_t>(inBuffer[4]);
|
|
1015
|
+
const auto eventCount = static_cast<std::uint32_t>(inBuffer[5]);
|
|
1016
|
+
const auto fragmentCount = static_cast<std::uint32_t>(inBuffer[6]);
|
|
1017
|
+
const auto nextVertexId = static_cast<std::uint64_t>(inBuffer[7]);
|
|
1018
|
+
const auto nextConstraintId = static_cast<std::uint64_t>(inBuffer[8]);
|
|
1019
|
+
const auto nextFaceId = static_cast<std::uint64_t>(inBuffer[9]);
|
|
1020
|
+
const auto nextFragmentId = static_cast<std::uint64_t>(inBuffer[10]);
|
|
1021
|
+
|
|
1022
|
+
const auto hashLo = static_cast<std::uint64_t>(inBuffer[12]);
|
|
1023
|
+
const auto hashHi = static_cast<std::uint64_t>(inBuffer[13]);
|
|
1024
|
+
const std::uint64_t expectedHash = hashLo | (hashHi << 32);
|
|
1025
|
+
|
|
1026
|
+
if (vertexCount > kFractureMaxVertices ||
|
|
1027
|
+
constraintCount > kFractureMaxConstraints ||
|
|
1028
|
+
faceCount > kFractureMaxFaces ||
|
|
1029
|
+
eventCount > kFractureMaxEvents) {
|
|
1030
|
+
return FractureStatus::CapacityExceeded;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
const std::uint32_t expectedDoubles =
|
|
1034
|
+
kFractureSnapshotHeaderStride +
|
|
1035
|
+
vertexCount * kFractureVertexStride +
|
|
1036
|
+
constraintCount * kFractureConstraintStride +
|
|
1037
|
+
faceCount * kFractureFaceStride +
|
|
1038
|
+
eventCount * kFractureEventStride;
|
|
1039
|
+
|
|
1040
|
+
if (inBuffer.size() < expectedDoubles) {
|
|
1041
|
+
return FractureStatus::InvalidSnapshot;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// Validate checksum
|
|
1045
|
+
const std::span<const double> payloadSpan(inBuffer.data() + kFractureSnapshotHeaderStride, expectedDoubles - kFractureSnapshotHeaderStride);
|
|
1046
|
+
const std::uint64_t calculatedHash = computeTopologyChecksum(payloadSpan);
|
|
1047
|
+
if (calculatedHash != expectedHash) {
|
|
1048
|
+
return FractureStatus::ChecksumMismatch;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
mesh.vertexCount = vertexCount;
|
|
1052
|
+
mesh.constraintCount = constraintCount;
|
|
1053
|
+
mesh.faceCount = faceCount;
|
|
1054
|
+
mesh.eventCount = eventCount;
|
|
1055
|
+
mesh.fragmentCount = fragmentCount;
|
|
1056
|
+
mesh.nextVertexId = nextVertexId;
|
|
1057
|
+
mesh.nextConstraintId = nextConstraintId;
|
|
1058
|
+
mesh.nextFaceId = nextFaceId;
|
|
1059
|
+
mesh.nextFragmentId = nextFragmentId;
|
|
1060
|
+
|
|
1061
|
+
std::uint32_t offset = kFractureSnapshotHeaderStride;
|
|
1062
|
+
|
|
1063
|
+
// Unpack vertices
|
|
1064
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1065
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
1066
|
+
v.id = static_cast<std::uint64_t>(inBuffer[offset + 0]);
|
|
1067
|
+
v.x = inBuffer[offset + 1];
|
|
1068
|
+
v.y = inBuffer[offset + 2];
|
|
1069
|
+
v.z = inBuffer[offset + 3];
|
|
1070
|
+
v.prevX = inBuffer[offset + 4];
|
|
1071
|
+
v.prevY = inBuffer[offset + 5];
|
|
1072
|
+
v.prevZ = inBuffer[offset + 6];
|
|
1073
|
+
v.vx = inBuffer[offset + 7];
|
|
1074
|
+
v.vy = inBuffer[offset + 8];
|
|
1075
|
+
v.vz = inBuffer[offset + 9];
|
|
1076
|
+
v.mass = inBuffer[offset + 10];
|
|
1077
|
+
v.invMass = inBuffer[offset + 11];
|
|
1078
|
+
v.flags = static_cast<std::uint32_t>(inBuffer[offset + 12]);
|
|
1079
|
+
v.fragmentId = static_cast<std::uint32_t>(inBuffer[offset + 13]);
|
|
1080
|
+
offset += kFractureVertexStride;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// Unpack constraints
|
|
1084
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1085
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
1086
|
+
c.id = static_cast<std::uint64_t>(inBuffer[offset + 0]);
|
|
1087
|
+
c.vertexA = static_cast<std::uint32_t>(inBuffer[offset + 1]);
|
|
1088
|
+
c.vertexB = static_cast<std::uint32_t>(inBuffer[offset + 2]);
|
|
1089
|
+
c.restLength = inBuffer[offset + 3];
|
|
1090
|
+
c.stiffness = inBuffer[offset + 4];
|
|
1091
|
+
c.breakTension = inBuffer[offset + 5];
|
|
1092
|
+
c.currentTension = inBuffer[offset + 6];
|
|
1093
|
+
c.flags = static_cast<std::uint32_t>(inBuffer[offset + 7]);
|
|
1094
|
+
c.kind = static_cast<DeformableConstraintKind>(inBuffer[offset + 8]);
|
|
1095
|
+
c.currentStrain = inBuffer[offset + 9];
|
|
1096
|
+
offset += kFractureConstraintStride;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
// Unpack faces
|
|
1100
|
+
for (std::uint32_t i = 0; i < faceCount; ++i) {
|
|
1101
|
+
DeformableFace& f = mesh.faces[i];
|
|
1102
|
+
f.id = static_cast<std::uint64_t>(inBuffer[offset + 0]);
|
|
1103
|
+
f.vertex0 = static_cast<std::uint32_t>(inBuffer[offset + 1]);
|
|
1104
|
+
f.vertex1 = static_cast<std::uint32_t>(inBuffer[offset + 2]);
|
|
1105
|
+
f.vertex2 = static_cast<std::uint32_t>(inBuffer[offset + 3]);
|
|
1106
|
+
f.restArea = inBuffer[offset + 4];
|
|
1107
|
+
f.flags = static_cast<std::uint32_t>(inBuffer[offset + 5]);
|
|
1108
|
+
f.fragmentId = static_cast<std::uint32_t>(inBuffer[offset + 6]);
|
|
1109
|
+
f.reserved = inBuffer[offset + 7];
|
|
1110
|
+
offset += kFractureFaceStride;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// Unpack events
|
|
1114
|
+
for (std::uint32_t i = 0; i < eventCount; ++i) {
|
|
1115
|
+
DeformableEvent& e = mesh.events[i];
|
|
1116
|
+
e.type = static_cast<DeformableEventType>(inBuffer[offset + 0]);
|
|
1117
|
+
e.tick = static_cast<std::uint64_t>(inBuffer[offset + 1]);
|
|
1118
|
+
e.elementId = static_cast<std::uint64_t>(inBuffer[offset + 2]);
|
|
1119
|
+
e.relatedId = static_cast<std::uint64_t>(inBuffer[offset + 3]);
|
|
1120
|
+
e.metric = inBuffer[offset + 4];
|
|
1121
|
+
e.posX = inBuffer[offset + 5];
|
|
1122
|
+
e.posY = inBuffer[offset + 6];
|
|
1123
|
+
e.posZ = inBuffer[offset + 7];
|
|
1124
|
+
e.fragmentId = static_cast<std::uint32_t>(inBuffer[offset + 8]);
|
|
1125
|
+
e.subIndex = static_cast<std::uint32_t>(inBuffer[offset + 9]);
|
|
1126
|
+
offset += kFractureEventStride;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
return FractureStatus::Success;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
} // namespace rundot::kinetix::physics
|
|
1133
|
+
|
|
1134
|
+
// ---------------------------------------------------------------------------
|
|
1135
|
+
// C ABI Implementation
|
|
1136
|
+
// ---------------------------------------------------------------------------
|
|
1137
|
+
|
|
1138
|
+
extern "C" {
|
|
1139
|
+
|
|
1140
|
+
using namespace rundot::kinetix::physics;
|
|
1141
|
+
|
|
1142
|
+
std::uint32_t rundot_kinetix_ext_fracture_abi_version() {
|
|
1143
|
+
return kFractureAbiVersion;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
std::uint32_t rundot_kinetix_ext_fracture_vertex_stride() {
|
|
1147
|
+
return kFractureVertexStride;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
std::uint32_t rundot_kinetix_ext_fracture_constraint_stride() {
|
|
1151
|
+
return kFractureConstraintStride;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
std::uint32_t rundot_kinetix_ext_fracture_face_stride() {
|
|
1155
|
+
return kFractureFaceStride;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
std::uint32_t rundot_kinetix_ext_fracture_event_stride() {
|
|
1159
|
+
return kFractureEventStride;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
std::uint32_t rundot_kinetix_ext_fracture_audit_stride() {
|
|
1163
|
+
return kFractureAuditStride;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
std::uint32_t rundot_kinetix_ext_fracture_snapshot_header_stride() {
|
|
1167
|
+
return kFractureSnapshotHeaderStride;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
std::uint32_t rundot_kinetix_ext_fracture_cutting_tool_stride() {
|
|
1171
|
+
return kFractureCuttingToolStride;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
std::uint32_t rundot_kinetix_ext_fracture_params_stride() {
|
|
1175
|
+
return kFractureParamsStride;
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
std::uint32_t rundot_kinetix_ext_fracture_max_vertices() {
|
|
1179
|
+
return kFractureMaxVertices;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
std::uint32_t rundot_kinetix_ext_fracture_max_constraints() {
|
|
1183
|
+
return kFractureMaxConstraints;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
std::uint32_t rundot_kinetix_ext_fracture_max_faces() {
|
|
1187
|
+
return kFractureMaxFaces;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
std::uint32_t rundot_kinetix_ext_fracture_max_events() {
|
|
1191
|
+
return kFractureMaxEvents;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
std::uint32_t rundot_kinetix_ext_fracture_max_fragments() {
|
|
1195
|
+
return kFractureMaxFragments;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
std::int32_t rundot_kinetix_ext_fracture_create_grid(
|
|
1199
|
+
double* vertexData,
|
|
1200
|
+
std::uint32_t* vertexCount,
|
|
1201
|
+
double* constraintData,
|
|
1202
|
+
std::uint32_t* constraintCount,
|
|
1203
|
+
double* faceData,
|
|
1204
|
+
std::uint32_t* faceCount,
|
|
1205
|
+
std::uint32_t gridX,
|
|
1206
|
+
std::uint32_t gridY,
|
|
1207
|
+
double spacing,
|
|
1208
|
+
double totalMass,
|
|
1209
|
+
std::uint32_t pinTopRow) {
|
|
1210
|
+
if (vertexData == nullptr || vertexCount == nullptr ||
|
|
1211
|
+
constraintData == nullptr || constraintCount == nullptr) {
|
|
1212
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
DeformableMesh mesh{};
|
|
1216
|
+
const FractureStatus status = createGridDeformable(mesh, gridX, gridY, spacing, totalMass, pinTopRow != 0);
|
|
1217
|
+
if (status != FractureStatus::Success) {
|
|
1218
|
+
return static_cast<std::int32_t>(status);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
*vertexCount = mesh.vertexCount;
|
|
1222
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
1223
|
+
double* rec = vertexData + i * kFractureVertexStride;
|
|
1224
|
+
const DeformableVertex& v = mesh.vertices[i];
|
|
1225
|
+
rec[0] = static_cast<double>(v.id);
|
|
1226
|
+
rec[1] = v.x; rec[2] = v.y; rec[3] = v.z;
|
|
1227
|
+
rec[4] = v.prevX; rec[5] = v.prevY; rec[6] = v.prevZ;
|
|
1228
|
+
rec[7] = v.vx; rec[8] = v.vy; rec[9] = v.vz;
|
|
1229
|
+
rec[10] = v.mass; rec[11] = v.invMass;
|
|
1230
|
+
rec[12] = static_cast<double>(v.flags);
|
|
1231
|
+
rec[13] = static_cast<double>(v.fragmentId);
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
*constraintCount = mesh.constraintCount;
|
|
1235
|
+
for (std::uint32_t i = 0; i < mesh.constraintCount; ++i) {
|
|
1236
|
+
double* rec = constraintData + i * kFractureConstraintStride;
|
|
1237
|
+
const DeformableConstraint& c = mesh.constraints[i];
|
|
1238
|
+
rec[0] = static_cast<double>(c.id);
|
|
1239
|
+
rec[1] = static_cast<double>(c.vertexA);
|
|
1240
|
+
rec[2] = static_cast<double>(c.vertexB);
|
|
1241
|
+
rec[3] = c.restLength;
|
|
1242
|
+
rec[4] = c.stiffness;
|
|
1243
|
+
rec[5] = c.breakTension;
|
|
1244
|
+
rec[6] = c.currentTension;
|
|
1245
|
+
rec[7] = static_cast<double>(c.flags);
|
|
1246
|
+
rec[8] = static_cast<double>(c.kind);
|
|
1247
|
+
rec[9] = c.currentStrain;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
if (faceData != nullptr && faceCount != nullptr) {
|
|
1251
|
+
*faceCount = mesh.faceCount;
|
|
1252
|
+
for (std::uint32_t i = 0; i < mesh.faceCount; ++i) {
|
|
1253
|
+
double* rec = faceData + i * kFractureFaceStride;
|
|
1254
|
+
const DeformableFace& f = mesh.faces[i];
|
|
1255
|
+
rec[0] = static_cast<double>(f.id);
|
|
1256
|
+
rec[1] = static_cast<double>(f.vertex0);
|
|
1257
|
+
rec[2] = static_cast<double>(f.vertex1);
|
|
1258
|
+
rec[3] = static_cast<double>(f.vertex2);
|
|
1259
|
+
rec[4] = f.restArea;
|
|
1260
|
+
rec[5] = static_cast<double>(f.flags);
|
|
1261
|
+
rec[6] = static_cast<double>(f.fragmentId);
|
|
1262
|
+
rec[7] = f.reserved;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
std::int32_t rundot_kinetix_ext_fracture_step(
|
|
1270
|
+
double* vertexData,
|
|
1271
|
+
std::uint32_t vertexCount,
|
|
1272
|
+
double* constraintData,
|
|
1273
|
+
std::uint32_t constraintCount,
|
|
1274
|
+
const double* paramsData,
|
|
1275
|
+
double* eventData,
|
|
1276
|
+
std::uint32_t* eventCount,
|
|
1277
|
+
std::uint32_t maxEvents,
|
|
1278
|
+
double dt,
|
|
1279
|
+
std::uint64_t tick) {
|
|
1280
|
+
if (vertexData == nullptr || vertexCount == 0 ||
|
|
1281
|
+
constraintData == nullptr || constraintCount == 0) {
|
|
1282
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
if (vertexCount > kFractureMaxVertices || constraintCount > kFractureMaxConstraints) {
|
|
1286
|
+
return static_cast<std::int32_t>(FractureStatus::CapacityExceeded);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
DeformableMesh mesh{};
|
|
1290
|
+
mesh.vertexCount = vertexCount;
|
|
1291
|
+
mesh.constraintCount = constraintCount;
|
|
1292
|
+
|
|
1293
|
+
// Decode vertices
|
|
1294
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1295
|
+
const double* rec = vertexData + i * kFractureVertexStride;
|
|
1296
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
1297
|
+
v.id = static_cast<std::uint64_t>(rec[0]);
|
|
1298
|
+
v.x = rec[1]; v.y = rec[2]; v.z = rec[3];
|
|
1299
|
+
v.prevX = rec[4]; v.prevY = rec[5]; v.prevZ = rec[6];
|
|
1300
|
+
v.vx = rec[7]; v.vy = rec[8]; v.vz = rec[9];
|
|
1301
|
+
v.mass = rec[10]; v.invMass = rec[11];
|
|
1302
|
+
v.flags = static_cast<std::uint32_t>(rec[12]);
|
|
1303
|
+
v.fragmentId = static_cast<std::uint32_t>(rec[13]);
|
|
1304
|
+
if (v.id >= mesh.nextVertexId) mesh.nextVertexId = v.id + 1;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// Decode constraints
|
|
1308
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1309
|
+
const double* rec = constraintData + i * kFractureConstraintStride;
|
|
1310
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
1311
|
+
c.id = static_cast<std::uint64_t>(rec[0]);
|
|
1312
|
+
c.vertexA = static_cast<std::uint32_t>(rec[1]);
|
|
1313
|
+
c.vertexB = static_cast<std::uint32_t>(rec[2]);
|
|
1314
|
+
c.restLength = rec[3];
|
|
1315
|
+
c.stiffness = rec[4];
|
|
1316
|
+
c.breakTension = rec[5];
|
|
1317
|
+
c.currentTension = rec[6];
|
|
1318
|
+
c.flags = static_cast<std::uint32_t>(rec[7]);
|
|
1319
|
+
c.kind = static_cast<DeformableConstraintKind>(rec[8]);
|
|
1320
|
+
c.currentStrain = rec[9];
|
|
1321
|
+
if (c.id >= mesh.nextConstraintId) mesh.nextConstraintId = c.id + 1;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// Decode params
|
|
1325
|
+
if (paramsData != nullptr) {
|
|
1326
|
+
mesh.params.gravityX = paramsData[0];
|
|
1327
|
+
mesh.params.gravityY = paramsData[1];
|
|
1328
|
+
mesh.params.gravityZ = paramsData[2];
|
|
1329
|
+
mesh.params.damping = paramsData[3];
|
|
1330
|
+
mesh.params.solverIterations = static_cast<std::uint32_t>(paramsData[4]);
|
|
1331
|
+
mesh.params.maxTearsPerStep = static_cast<std::uint32_t>(paramsData[5]);
|
|
1332
|
+
mesh.params.maxCutsPerStep = static_cast<std::uint32_t>(paramsData[6]);
|
|
1333
|
+
mesh.params.enableGround = (paramsData[7] != 0.0);
|
|
1334
|
+
mesh.params.groundY = paramsData[8];
|
|
1335
|
+
mesh.params.groundFriction = paramsData[9];
|
|
1336
|
+
mesh.params.tearThresholdMultiplier = paramsData[10];
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
const FractureStatus status = stepDeformable(mesh, dt, tick);
|
|
1340
|
+
if (status != FractureStatus::Success) {
|
|
1341
|
+
return static_cast<std::int32_t>(status);
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// Write back vertices
|
|
1345
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1346
|
+
double* rec = vertexData + i * kFractureVertexStride;
|
|
1347
|
+
const DeformableVertex& v = mesh.vertices[i];
|
|
1348
|
+
rec[1] = v.x; rec[2] = v.y; rec[3] = v.z;
|
|
1349
|
+
rec[4] = v.prevX; rec[5] = v.prevY; rec[6] = v.prevZ;
|
|
1350
|
+
rec[7] = v.vx; rec[8] = v.vy; rec[9] = v.vz;
|
|
1351
|
+
rec[10] = v.mass; rec[11] = v.invMass;
|
|
1352
|
+
rec[12] = static_cast<double>(v.flags);
|
|
1353
|
+
rec[13] = static_cast<double>(v.fragmentId);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
// Write back constraints
|
|
1357
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1358
|
+
double* rec = constraintData + i * kFractureConstraintStride;
|
|
1359
|
+
const DeformableConstraint& c = mesh.constraints[i];
|
|
1360
|
+
rec[6] = c.currentTension;
|
|
1361
|
+
rec[7] = static_cast<double>(c.flags);
|
|
1362
|
+
rec[9] = c.currentStrain;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// Write back events
|
|
1366
|
+
if (eventData != nullptr && eventCount != nullptr) {
|
|
1367
|
+
const std::uint32_t writeCount = std::min(mesh.eventCount, maxEvents);
|
|
1368
|
+
*eventCount = writeCount;
|
|
1369
|
+
for (std::uint32_t i = 0; i < writeCount; ++i) {
|
|
1370
|
+
double* rec = eventData + i * kFractureEventStride;
|
|
1371
|
+
const DeformableEvent& e = mesh.events[i];
|
|
1372
|
+
rec[0] = static_cast<double>(e.type);
|
|
1373
|
+
rec[1] = static_cast<double>(e.tick);
|
|
1374
|
+
rec[2] = static_cast<double>(e.elementId);
|
|
1375
|
+
rec[3] = static_cast<double>(e.relatedId);
|
|
1376
|
+
rec[4] = e.metric;
|
|
1377
|
+
rec[5] = e.posX; rec[6] = e.posY; rec[7] = e.posZ;
|
|
1378
|
+
rec[8] = static_cast<double>(e.fragmentId);
|
|
1379
|
+
rec[9] = static_cast<double>(e.subIndex);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
std::int32_t rundot_kinetix_ext_fracture_cut(
|
|
1387
|
+
double* vertexData,
|
|
1388
|
+
std::uint32_t* vertexCount,
|
|
1389
|
+
std::uint32_t maxVertices,
|
|
1390
|
+
double* constraintData,
|
|
1391
|
+
std::uint32_t* constraintCount,
|
|
1392
|
+
std::uint32_t maxConstraints,
|
|
1393
|
+
const double* cuttingToolData,
|
|
1394
|
+
double* eventData,
|
|
1395
|
+
std::uint32_t* eventCount,
|
|
1396
|
+
std::uint32_t maxEvents,
|
|
1397
|
+
std::uint64_t tick) {
|
|
1398
|
+
if (vertexData == nullptr || vertexCount == nullptr || *vertexCount == 0 ||
|
|
1399
|
+
constraintData == nullptr || constraintCount == nullptr || *constraintCount == 0 ||
|
|
1400
|
+
cuttingToolData == nullptr) {
|
|
1401
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
DeformableMesh mesh{};
|
|
1405
|
+
mesh.vertexCount = *vertexCount;
|
|
1406
|
+
mesh.constraintCount = *constraintCount;
|
|
1407
|
+
|
|
1408
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
1409
|
+
const double* rec = vertexData + i * kFractureVertexStride;
|
|
1410
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
1411
|
+
v.id = static_cast<std::uint64_t>(rec[0]);
|
|
1412
|
+
v.x = rec[1]; v.y = rec[2]; v.z = rec[3];
|
|
1413
|
+
v.prevX = rec[4]; v.prevY = rec[5]; v.prevZ = rec[6];
|
|
1414
|
+
v.vx = rec[7]; v.vy = rec[8]; v.vz = rec[9];
|
|
1415
|
+
v.mass = rec[10]; v.invMass = rec[11];
|
|
1416
|
+
v.flags = static_cast<std::uint32_t>(rec[12]);
|
|
1417
|
+
v.fragmentId = static_cast<std::uint32_t>(rec[13]);
|
|
1418
|
+
if (v.id >= mesh.nextVertexId) mesh.nextVertexId = v.id + 1;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
for (std::uint32_t i = 0; i < mesh.constraintCount; ++i) {
|
|
1422
|
+
const double* rec = constraintData + i * kFractureConstraintStride;
|
|
1423
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
1424
|
+
c.id = static_cast<std::uint64_t>(rec[0]);
|
|
1425
|
+
c.vertexA = static_cast<std::uint32_t>(rec[1]);
|
|
1426
|
+
c.vertexB = static_cast<std::uint32_t>(rec[2]);
|
|
1427
|
+
c.restLength = rec[3];
|
|
1428
|
+
c.stiffness = rec[4];
|
|
1429
|
+
c.breakTension = rec[5];
|
|
1430
|
+
c.currentTension = rec[6];
|
|
1431
|
+
c.flags = static_cast<std::uint32_t>(rec[7]);
|
|
1432
|
+
c.kind = static_cast<DeformableConstraintKind>(rec[8]);
|
|
1433
|
+
c.currentStrain = rec[9];
|
|
1434
|
+
if (c.id >= mesh.nextConstraintId) mesh.nextConstraintId = c.id + 1;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
CuttingTool tool{};
|
|
1438
|
+
tool.origin = {cuttingToolData[0], cuttingToolData[1], cuttingToolData[2]};
|
|
1439
|
+
tool.normal = {cuttingToolData[3], cuttingToolData[4], cuttingToolData[5]};
|
|
1440
|
+
tool.halfWidth = cuttingToolData[6];
|
|
1441
|
+
tool.halfHeight = cuttingToolData[7];
|
|
1442
|
+
tool.tangent1 = {cuttingToolData[8], cuttingToolData[9], cuttingToolData[10]};
|
|
1443
|
+
tool.tangent2 = {cuttingToolData[11], cuttingToolData[12], cuttingToolData[13]};
|
|
1444
|
+
tool.mode = static_cast<CutMode>(cuttingToolData[14]);
|
|
1445
|
+
tool.maxCuts = static_cast<std::uint32_t>(cuttingToolData[15]);
|
|
1446
|
+
|
|
1447
|
+
const FractureStatus status = cutDeformable(mesh, tool, tick);
|
|
1448
|
+
if (status != FractureStatus::Success) {
|
|
1449
|
+
return static_cast<std::int32_t>(status);
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
if (mesh.vertexCount > maxVertices || mesh.constraintCount > maxConstraints) {
|
|
1453
|
+
return static_cast<std::int32_t>(FractureStatus::CapacityExceeded);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
*vertexCount = mesh.vertexCount;
|
|
1457
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
1458
|
+
double* rec = vertexData + i * kFractureVertexStride;
|
|
1459
|
+
const DeformableVertex& v = mesh.vertices[i];
|
|
1460
|
+
rec[0] = static_cast<double>(v.id);
|
|
1461
|
+
rec[1] = v.x; rec[2] = v.y; rec[3] = v.z;
|
|
1462
|
+
rec[4] = v.prevX; rec[5] = v.prevY; rec[6] = v.prevZ;
|
|
1463
|
+
rec[7] = v.vx; rec[8] = v.vy; rec[9] = v.vz;
|
|
1464
|
+
rec[10] = v.mass; rec[11] = v.invMass;
|
|
1465
|
+
rec[12] = static_cast<double>(v.flags);
|
|
1466
|
+
rec[13] = static_cast<double>(v.fragmentId);
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
*constraintCount = mesh.constraintCount;
|
|
1470
|
+
for (std::uint32_t i = 0; i < mesh.constraintCount; ++i) {
|
|
1471
|
+
double* rec = constraintData + i * kFractureConstraintStride;
|
|
1472
|
+
const DeformableConstraint& c = mesh.constraints[i];
|
|
1473
|
+
rec[0] = static_cast<double>(c.id);
|
|
1474
|
+
rec[1] = static_cast<double>(c.vertexA);
|
|
1475
|
+
rec[2] = static_cast<double>(c.vertexB);
|
|
1476
|
+
rec[3] = c.restLength;
|
|
1477
|
+
rec[4] = c.stiffness;
|
|
1478
|
+
rec[5] = c.breakTension;
|
|
1479
|
+
rec[6] = c.currentTension;
|
|
1480
|
+
rec[7] = static_cast<double>(c.flags);
|
|
1481
|
+
rec[8] = static_cast<double>(c.kind);
|
|
1482
|
+
rec[9] = c.currentStrain;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
if (eventData != nullptr && eventCount != nullptr) {
|
|
1486
|
+
const std::uint32_t writeCount = std::min(mesh.eventCount, maxEvents);
|
|
1487
|
+
*eventCount = writeCount;
|
|
1488
|
+
for (std::uint32_t i = 0; i < writeCount; ++i) {
|
|
1489
|
+
double* rec = eventData + i * kFractureEventStride;
|
|
1490
|
+
const DeformableEvent& e = mesh.events[i];
|
|
1491
|
+
rec[0] = static_cast<double>(e.type);
|
|
1492
|
+
rec[1] = static_cast<double>(e.tick);
|
|
1493
|
+
rec[2] = static_cast<double>(e.elementId);
|
|
1494
|
+
rec[3] = static_cast<double>(e.relatedId);
|
|
1495
|
+
rec[4] = e.metric;
|
|
1496
|
+
rec[5] = e.posX; rec[6] = e.posY; rec[7] = e.posZ;
|
|
1497
|
+
rec[8] = static_cast<double>(e.fragmentId);
|
|
1498
|
+
rec[9] = static_cast<double>(e.subIndex);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
std::int32_t rundot_kinetix_ext_fracture_tear_constraint(
|
|
1506
|
+
double* vertexData,
|
|
1507
|
+
std::uint32_t vertexCount,
|
|
1508
|
+
double* constraintData,
|
|
1509
|
+
std::uint32_t constraintCount,
|
|
1510
|
+
std::uint64_t constraintId,
|
|
1511
|
+
double* eventData,
|
|
1512
|
+
std::uint32_t* eventCount,
|
|
1513
|
+
std::uint32_t maxEvents,
|
|
1514
|
+
std::uint64_t tick) {
|
|
1515
|
+
if (vertexData == nullptr || constraintData == nullptr || vertexCount == 0 || constraintCount == 0) {
|
|
1516
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
DeformableMesh mesh{};
|
|
1520
|
+
mesh.vertexCount = vertexCount;
|
|
1521
|
+
mesh.constraintCount = constraintCount;
|
|
1522
|
+
|
|
1523
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1524
|
+
const double* rec = vertexData + i * kFractureVertexStride;
|
|
1525
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
1526
|
+
v.id = static_cast<std::uint64_t>(rec[0]);
|
|
1527
|
+
v.x = rec[1]; v.y = rec[2]; v.z = rec[3];
|
|
1528
|
+
v.mass = rec[10]; v.invMass = rec[11];
|
|
1529
|
+
v.flags = static_cast<std::uint32_t>(rec[12]);
|
|
1530
|
+
v.fragmentId = static_cast<std::uint32_t>(rec[13]);
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1534
|
+
const double* rec = constraintData + i * kFractureConstraintStride;
|
|
1535
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
1536
|
+
c.id = static_cast<std::uint64_t>(rec[0]);
|
|
1537
|
+
c.vertexA = static_cast<std::uint32_t>(rec[1]);
|
|
1538
|
+
c.vertexB = static_cast<std::uint32_t>(rec[2]);
|
|
1539
|
+
c.restLength = rec[3];
|
|
1540
|
+
c.stiffness = rec[4];
|
|
1541
|
+
c.breakTension = rec[5];
|
|
1542
|
+
c.currentTension = rec[6];
|
|
1543
|
+
c.flags = static_cast<std::uint32_t>(rec[7]);
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
const FractureStatus status = tearDeformableConstraint(mesh, constraintId, tick);
|
|
1547
|
+
if (status != FractureStatus::Success) {
|
|
1548
|
+
return static_cast<std::int32_t>(status);
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1552
|
+
double* rec = constraintData + i * kFractureConstraintStride;
|
|
1553
|
+
rec[7] = static_cast<double>(mesh.constraints[i].flags);
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1557
|
+
double* rec = vertexData + i * kFractureVertexStride;
|
|
1558
|
+
rec[13] = static_cast<double>(mesh.vertices[i].fragmentId);
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
if (eventData != nullptr && eventCount != nullptr) {
|
|
1562
|
+
const std::uint32_t writeCount = std::min(mesh.eventCount, maxEvents);
|
|
1563
|
+
*eventCount = writeCount;
|
|
1564
|
+
for (std::uint32_t i = 0; i < writeCount; ++i) {
|
|
1565
|
+
double* rec = eventData + i * kFractureEventStride;
|
|
1566
|
+
const DeformableEvent& e = mesh.events[i];
|
|
1567
|
+
rec[0] = static_cast<double>(e.type);
|
|
1568
|
+
rec[1] = static_cast<double>(e.tick);
|
|
1569
|
+
rec[2] = static_cast<double>(e.elementId);
|
|
1570
|
+
rec[3] = static_cast<double>(e.relatedId);
|
|
1571
|
+
rec[4] = e.metric;
|
|
1572
|
+
rec[5] = e.posX; rec[6] = e.posY; rec[7] = e.posZ;
|
|
1573
|
+
rec[8] = static_cast<double>(e.fragmentId);
|
|
1574
|
+
rec[9] = static_cast<double>(e.subIndex);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
std::int32_t rundot_kinetix_ext_fracture_split_vertex(
|
|
1582
|
+
double* vertexData,
|
|
1583
|
+
std::uint32_t* vertexCount,
|
|
1584
|
+
std::uint32_t maxVertices,
|
|
1585
|
+
double* constraintData,
|
|
1586
|
+
std::uint32_t constraintCount,
|
|
1587
|
+
std::uint64_t vertexId,
|
|
1588
|
+
double splitFraction,
|
|
1589
|
+
double* eventData,
|
|
1590
|
+
std::uint32_t* eventCount,
|
|
1591
|
+
std::uint32_t maxEvents,
|
|
1592
|
+
std::uint64_t tick) {
|
|
1593
|
+
if (vertexData == nullptr || vertexCount == nullptr || constraintData == nullptr || *vertexCount == 0) {
|
|
1594
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
DeformableMesh mesh{};
|
|
1598
|
+
mesh.vertexCount = *vertexCount;
|
|
1599
|
+
mesh.constraintCount = constraintCount;
|
|
1600
|
+
|
|
1601
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
1602
|
+
const double* rec = vertexData + i * kFractureVertexStride;
|
|
1603
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
1604
|
+
v.id = static_cast<std::uint64_t>(rec[0]);
|
|
1605
|
+
v.x = rec[1]; v.y = rec[2]; v.z = rec[3];
|
|
1606
|
+
v.prevX = rec[4]; v.prevY = rec[5]; v.prevZ = rec[6];
|
|
1607
|
+
v.vx = rec[7]; v.vy = rec[8]; v.vz = rec[9];
|
|
1608
|
+
v.mass = rec[10]; v.invMass = rec[11];
|
|
1609
|
+
v.flags = static_cast<std::uint32_t>(rec[12]);
|
|
1610
|
+
v.fragmentId = static_cast<std::uint32_t>(rec[13]);
|
|
1611
|
+
if (v.id >= mesh.nextVertexId) mesh.nextVertexId = v.id + 1;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1615
|
+
const double* rec = constraintData + i * kFractureConstraintStride;
|
|
1616
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
1617
|
+
c.id = static_cast<std::uint64_t>(rec[0]);
|
|
1618
|
+
c.vertexA = static_cast<std::uint32_t>(rec[1]);
|
|
1619
|
+
c.vertexB = static_cast<std::uint32_t>(rec[2]);
|
|
1620
|
+
c.flags = static_cast<std::uint32_t>(rec[7]);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
const FractureStatus status = splitDeformableVertex(mesh, vertexId, splitFraction, tick);
|
|
1624
|
+
if (status != FractureStatus::Success) {
|
|
1625
|
+
return static_cast<std::int32_t>(status);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
if (mesh.vertexCount > maxVertices) {
|
|
1629
|
+
return static_cast<std::int32_t>(FractureStatus::CapacityExceeded);
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
*vertexCount = mesh.vertexCount;
|
|
1633
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
1634
|
+
double* rec = vertexData + i * kFractureVertexStride;
|
|
1635
|
+
const DeformableVertex& v = mesh.vertices[i];
|
|
1636
|
+
rec[0] = static_cast<double>(v.id);
|
|
1637
|
+
rec[1] = v.x; rec[2] = v.y; rec[3] = v.z;
|
|
1638
|
+
rec[4] = v.prevX; rec[5] = v.prevY; rec[6] = v.prevZ;
|
|
1639
|
+
rec[7] = v.vx; rec[8] = v.vy; rec[9] = v.vz;
|
|
1640
|
+
rec[10] = v.mass; rec[11] = v.invMass;
|
|
1641
|
+
rec[12] = static_cast<double>(v.flags);
|
|
1642
|
+
rec[13] = static_cast<double>(v.fragmentId);
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1646
|
+
double* rec = constraintData + i * kFractureConstraintStride;
|
|
1647
|
+
const DeformableConstraint& c = mesh.constraints[i];
|
|
1648
|
+
rec[1] = static_cast<double>(c.vertexA);
|
|
1649
|
+
rec[2] = static_cast<double>(c.vertexB);
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
if (eventData != nullptr && eventCount != nullptr) {
|
|
1653
|
+
const std::uint32_t writeCount = std::min(mesh.eventCount, maxEvents);
|
|
1654
|
+
*eventCount = writeCount;
|
|
1655
|
+
for (std::uint32_t i = 0; i < writeCount; ++i) {
|
|
1656
|
+
double* rec = eventData + i * kFractureEventStride;
|
|
1657
|
+
const DeformableEvent& e = mesh.events[i];
|
|
1658
|
+
rec[0] = static_cast<double>(e.type);
|
|
1659
|
+
rec[1] = static_cast<double>(e.tick);
|
|
1660
|
+
rec[2] = static_cast<double>(e.elementId);
|
|
1661
|
+
rec[3] = static_cast<double>(e.relatedId);
|
|
1662
|
+
rec[4] = e.metric;
|
|
1663
|
+
rec[5] = e.posX; rec[6] = e.posY; rec[7] = e.posZ;
|
|
1664
|
+
rec[8] = static_cast<double>(e.fragmentId);
|
|
1665
|
+
rec[9] = static_cast<double>(e.subIndex);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
std::int32_t rundot_kinetix_ext_fracture_find_components(
|
|
1673
|
+
double* vertexData,
|
|
1674
|
+
std::uint32_t vertexCount,
|
|
1675
|
+
const double* constraintData,
|
|
1676
|
+
std::uint32_t constraintCount,
|
|
1677
|
+
std::uint32_t* outFragmentCount) {
|
|
1678
|
+
if (vertexData == nullptr || constraintData == nullptr || vertexCount == 0 || outFragmentCount == nullptr) {
|
|
1679
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
DeformableMesh mesh{};
|
|
1683
|
+
mesh.vertexCount = vertexCount;
|
|
1684
|
+
mesh.constraintCount = constraintCount;
|
|
1685
|
+
|
|
1686
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1687
|
+
const double* rec = vertexData + i * kFractureVertexStride;
|
|
1688
|
+
mesh.vertices[i].flags = static_cast<std::uint32_t>(rec[12]);
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1692
|
+
const double* rec = constraintData + i * kFractureConstraintStride;
|
|
1693
|
+
mesh.constraints[i].vertexA = static_cast<std::uint32_t>(rec[1]);
|
|
1694
|
+
mesh.constraints[i].vertexB = static_cast<std::uint32_t>(rec[2]);
|
|
1695
|
+
mesh.constraints[i].flags = static_cast<std::uint32_t>(rec[7]);
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
const FractureStatus status = findConnectedComponents(mesh, 0);
|
|
1699
|
+
if (status != FractureStatus::Success) {
|
|
1700
|
+
return static_cast<std::int32_t>(status);
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
*outFragmentCount = mesh.fragmentCount;
|
|
1704
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1705
|
+
vertexData[i * kFractureVertexStride + 13] = static_cast<double>(mesh.vertices[i].fragmentId);
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
std::int32_t rundot_kinetix_ext_fracture_audit_mass(
|
|
1712
|
+
const double* initialVertexData,
|
|
1713
|
+
std::uint32_t initialVertexCount,
|
|
1714
|
+
const double* currentVertexData,
|
|
1715
|
+
std::uint32_t currentVertexCount,
|
|
1716
|
+
double* outAuditData) {
|
|
1717
|
+
if (initialVertexData == nullptr || currentVertexData == nullptr || outAuditData == nullptr) {
|
|
1718
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
DeformableMesh initMesh{};
|
|
1722
|
+
initMesh.vertexCount = initialVertexCount;
|
|
1723
|
+
for (std::uint32_t i = 0; i < initialVertexCount; ++i) {
|
|
1724
|
+
const double* rec = initialVertexData + i * kFractureVertexStride;
|
|
1725
|
+
DeformableVertex& v = initMesh.vertices[i];
|
|
1726
|
+
v.x = rec[1]; v.y = rec[2]; v.z = rec[3];
|
|
1727
|
+
v.vx = rec[7]; v.vy = rec[8]; v.vz = rec[9];
|
|
1728
|
+
v.mass = rec[10];
|
|
1729
|
+
v.flags = static_cast<std::uint32_t>(rec[12]);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
DeformableMesh currMesh{};
|
|
1733
|
+
currMesh.vertexCount = currentVertexCount;
|
|
1734
|
+
for (std::uint32_t i = 0; i < currentVertexCount; ++i) {
|
|
1735
|
+
const double* rec = currentVertexData + i * kFractureVertexStride;
|
|
1736
|
+
DeformableVertex& v = currMesh.vertices[i];
|
|
1737
|
+
v.x = rec[1]; v.y = rec[2]; v.z = rec[3];
|
|
1738
|
+
v.vx = rec[7]; v.vy = rec[8]; v.vz = rec[9];
|
|
1739
|
+
v.mass = rec[10];
|
|
1740
|
+
v.flags = static_cast<std::uint32_t>(rec[12]);
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
const DeformableAudit audit = auditMassAndMomentum(initMesh, currMesh);
|
|
1744
|
+
|
|
1745
|
+
outAuditData[0] = audit.initialMass;
|
|
1746
|
+
outAuditData[1] = audit.finalMass;
|
|
1747
|
+
outAuditData[2] = audit.massError;
|
|
1748
|
+
outAuditData[3] = audit.massPreserved ? 1.0 : 0.0;
|
|
1749
|
+
outAuditData[4] = audit.initialLinearMomentumX;
|
|
1750
|
+
outAuditData[5] = audit.initialLinearMomentumY;
|
|
1751
|
+
outAuditData[6] = audit.initialLinearMomentumZ;
|
|
1752
|
+
outAuditData[7] = audit.finalLinearMomentumX;
|
|
1753
|
+
outAuditData[8] = audit.finalLinearMomentumY;
|
|
1754
|
+
outAuditData[9] = audit.finalLinearMomentumZ;
|
|
1755
|
+
outAuditData[10] = audit.linearMomentumError;
|
|
1756
|
+
outAuditData[11] = audit.linearPreserved ? 1.0 : 0.0;
|
|
1757
|
+
outAuditData[12] = audit.initialAngularMomentumX;
|
|
1758
|
+
outAuditData[13] = audit.initialAngularMomentumY;
|
|
1759
|
+
outAuditData[14] = audit.initialAngularMomentumZ;
|
|
1760
|
+
outAuditData[15] = audit.angularPreserved ? 1.0 : 0.0;
|
|
1761
|
+
|
|
1762
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
std::int32_t rundot_kinetix_ext_fracture_capture_snapshot(
|
|
1766
|
+
const double* vertexData,
|
|
1767
|
+
std::uint32_t vertexCount,
|
|
1768
|
+
const double* constraintData,
|
|
1769
|
+
std::uint32_t constraintCount,
|
|
1770
|
+
const double* faceData,
|
|
1771
|
+
std::uint32_t faceCount,
|
|
1772
|
+
const double* eventData,
|
|
1773
|
+
std::uint32_t eventCount,
|
|
1774
|
+
std::uint32_t fragmentCount,
|
|
1775
|
+
std::uint64_t nextVertexId,
|
|
1776
|
+
std::uint64_t nextConstraintId,
|
|
1777
|
+
std::uint64_t nextFaceId,
|
|
1778
|
+
std::uint64_t nextFragmentId,
|
|
1779
|
+
double* outSnapshotData,
|
|
1780
|
+
std::uint32_t maxDoubles,
|
|
1781
|
+
std::uint32_t* outDoublesWritten) {
|
|
1782
|
+
if (outSnapshotData == nullptr || outDoublesWritten == nullptr) {
|
|
1783
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
DeformableMesh mesh{};
|
|
1787
|
+
mesh.vertexCount = vertexCount;
|
|
1788
|
+
mesh.constraintCount = constraintCount;
|
|
1789
|
+
mesh.faceCount = faceCount;
|
|
1790
|
+
mesh.eventCount = eventCount;
|
|
1791
|
+
mesh.fragmentCount = fragmentCount;
|
|
1792
|
+
mesh.nextVertexId = nextVertexId;
|
|
1793
|
+
mesh.nextConstraintId = nextConstraintId;
|
|
1794
|
+
mesh.nextFaceId = nextFaceId;
|
|
1795
|
+
mesh.nextFragmentId = nextFragmentId;
|
|
1796
|
+
|
|
1797
|
+
if (vertexData != nullptr) {
|
|
1798
|
+
for (std::uint32_t i = 0; i < vertexCount; ++i) {
|
|
1799
|
+
const double* rec = vertexData + i * kFractureVertexStride;
|
|
1800
|
+
DeformableVertex& v = mesh.vertices[i];
|
|
1801
|
+
v.id = static_cast<std::uint64_t>(rec[0]);
|
|
1802
|
+
v.x = rec[1]; v.y = rec[2]; v.z = rec[3];
|
|
1803
|
+
v.prevX = rec[4]; v.prevY = rec[5]; v.prevZ = rec[6];
|
|
1804
|
+
v.vx = rec[7]; v.vy = rec[8]; v.vz = rec[9];
|
|
1805
|
+
v.mass = rec[10]; v.invMass = rec[11];
|
|
1806
|
+
v.flags = static_cast<std::uint32_t>(rec[12]);
|
|
1807
|
+
v.fragmentId = static_cast<std::uint32_t>(rec[13]);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
if (constraintData != nullptr) {
|
|
1812
|
+
for (std::uint32_t i = 0; i < constraintCount; ++i) {
|
|
1813
|
+
const double* rec = constraintData + i * kFractureConstraintStride;
|
|
1814
|
+
DeformableConstraint& c = mesh.constraints[i];
|
|
1815
|
+
c.id = static_cast<std::uint64_t>(rec[0]);
|
|
1816
|
+
c.vertexA = static_cast<std::uint32_t>(rec[1]);
|
|
1817
|
+
c.vertexB = static_cast<std::uint32_t>(rec[2]);
|
|
1818
|
+
c.restLength = rec[3];
|
|
1819
|
+
c.stiffness = rec[4];
|
|
1820
|
+
c.breakTension = rec[5];
|
|
1821
|
+
c.currentTension = rec[6];
|
|
1822
|
+
c.flags = static_cast<std::uint32_t>(rec[7]);
|
|
1823
|
+
c.kind = static_cast<DeformableConstraintKind>(rec[8]);
|
|
1824
|
+
c.currentStrain = rec[9];
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
if (faceData != nullptr) {
|
|
1829
|
+
for (std::uint32_t i = 0; i < faceCount; ++i) {
|
|
1830
|
+
const double* rec = faceData + i * kFractureFaceStride;
|
|
1831
|
+
DeformableFace& f = mesh.faces[i];
|
|
1832
|
+
f.id = static_cast<std::uint64_t>(rec[0]);
|
|
1833
|
+
f.vertex0 = static_cast<std::uint32_t>(rec[1]);
|
|
1834
|
+
f.vertex1 = static_cast<std::uint32_t>(rec[2]);
|
|
1835
|
+
f.vertex2 = static_cast<std::uint32_t>(rec[3]);
|
|
1836
|
+
f.restArea = rec[4];
|
|
1837
|
+
f.flags = static_cast<std::uint32_t>(rec[5]);
|
|
1838
|
+
f.fragmentId = static_cast<std::uint32_t>(rec[6]);
|
|
1839
|
+
f.reserved = rec[7];
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
if (eventData != nullptr) {
|
|
1844
|
+
for (std::uint32_t i = 0; i < eventCount; ++i) {
|
|
1845
|
+
const double* rec = eventData + i * kFractureEventStride;
|
|
1846
|
+
DeformableEvent& e = mesh.events[i];
|
|
1847
|
+
e.type = static_cast<DeformableEventType>(rec[0]);
|
|
1848
|
+
e.tick = static_cast<std::uint64_t>(rec[1]);
|
|
1849
|
+
e.elementId = static_cast<std::uint64_t>(rec[2]);
|
|
1850
|
+
e.relatedId = static_cast<std::uint64_t>(rec[3]);
|
|
1851
|
+
e.metric = rec[4];
|
|
1852
|
+
e.posX = rec[5]; e.posY = rec[6]; e.posZ = rec[7];
|
|
1853
|
+
e.fragmentId = static_cast<std::uint32_t>(rec[8]);
|
|
1854
|
+
e.subIndex = static_cast<std::uint32_t>(rec[9]);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
std::span<double> bufferSpan(outSnapshotData, maxDoubles);
|
|
1859
|
+
std::uint32_t written = 0;
|
|
1860
|
+
const FractureStatus status = captureDeformableSnapshot(mesh, bufferSpan, written);
|
|
1861
|
+
if (status != FractureStatus::Success) {
|
|
1862
|
+
return static_cast<std::int32_t>(status);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
*outDoublesWritten = written;
|
|
1866
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
std::int32_t rundot_kinetix_ext_fracture_restore_snapshot(
|
|
1870
|
+
const double* snapshotData,
|
|
1871
|
+
std::uint32_t doubleCount,
|
|
1872
|
+
double* outVertexData,
|
|
1873
|
+
std::uint32_t* outVertexCount,
|
|
1874
|
+
std::uint32_t maxVertices,
|
|
1875
|
+
double* outConstraintData,
|
|
1876
|
+
std::uint32_t* outConstraintCount,
|
|
1877
|
+
std::uint32_t maxConstraints,
|
|
1878
|
+
double* outFaceData,
|
|
1879
|
+
std::uint32_t* outFaceCount,
|
|
1880
|
+
std::uint32_t maxFaces,
|
|
1881
|
+
double* outEventData,
|
|
1882
|
+
std::uint32_t* outEventCount,
|
|
1883
|
+
std::uint32_t maxEvents,
|
|
1884
|
+
std::uint32_t* outFragmentCount,
|
|
1885
|
+
std::uint64_t* outNextVertexId,
|
|
1886
|
+
std::uint64_t* outNextConstraintId,
|
|
1887
|
+
std::uint64_t* outNextFaceId,
|
|
1888
|
+
std::uint64_t* outNextFragmentId) {
|
|
1889
|
+
if (snapshotData == nullptr || doubleCount < kFractureSnapshotHeaderStride) {
|
|
1890
|
+
return static_cast<std::int32_t>(FractureStatus::InvalidInput);
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
DeformableMesh mesh{};
|
|
1894
|
+
std::span<const double> inSpan(snapshotData, doubleCount);
|
|
1895
|
+
const FractureStatus status = restoreDeformableSnapshot(inSpan, mesh);
|
|
1896
|
+
if (status != FractureStatus::Success) {
|
|
1897
|
+
return static_cast<std::int32_t>(status);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
if (mesh.vertexCount > maxVertices ||
|
|
1901
|
+
mesh.constraintCount > maxConstraints ||
|
|
1902
|
+
mesh.faceCount > maxFaces ||
|
|
1903
|
+
mesh.eventCount > maxEvents) {
|
|
1904
|
+
return static_cast<std::int32_t>(FractureStatus::CapacityExceeded);
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
if (outVertexData != nullptr && outVertexCount != nullptr) {
|
|
1908
|
+
*outVertexCount = mesh.vertexCount;
|
|
1909
|
+
for (std::uint32_t i = 0; i < mesh.vertexCount; ++i) {
|
|
1910
|
+
double* rec = outVertexData + i * kFractureVertexStride;
|
|
1911
|
+
const DeformableVertex& v = mesh.vertices[i];
|
|
1912
|
+
rec[0] = static_cast<double>(v.id);
|
|
1913
|
+
rec[1] = v.x; rec[2] = v.y; rec[3] = v.z;
|
|
1914
|
+
rec[4] = v.prevX; rec[5] = v.prevY; rec[6] = v.prevZ;
|
|
1915
|
+
rec[7] = v.vx; rec[8] = v.vy; rec[9] = v.vz;
|
|
1916
|
+
rec[10] = v.mass; rec[11] = v.invMass;
|
|
1917
|
+
rec[12] = static_cast<double>(v.flags);
|
|
1918
|
+
rec[13] = static_cast<double>(v.fragmentId);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
if (outConstraintData != nullptr && outConstraintCount != nullptr) {
|
|
1923
|
+
*outConstraintCount = mesh.constraintCount;
|
|
1924
|
+
for (std::uint32_t i = 0; i < mesh.constraintCount; ++i) {
|
|
1925
|
+
double* rec = outConstraintData + i * kFractureConstraintStride;
|
|
1926
|
+
const DeformableConstraint& c = mesh.constraints[i];
|
|
1927
|
+
rec[0] = static_cast<double>(c.id);
|
|
1928
|
+
rec[1] = static_cast<double>(c.vertexA);
|
|
1929
|
+
rec[2] = static_cast<double>(c.vertexB);
|
|
1930
|
+
rec[3] = c.restLength;
|
|
1931
|
+
rec[4] = c.stiffness;
|
|
1932
|
+
rec[5] = c.breakTension;
|
|
1933
|
+
rec[6] = c.currentTension;
|
|
1934
|
+
rec[7] = static_cast<double>(c.flags);
|
|
1935
|
+
rec[8] = static_cast<double>(c.kind);
|
|
1936
|
+
rec[9] = c.currentStrain;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
if (outFaceData != nullptr && outFaceCount != nullptr) {
|
|
1941
|
+
*outFaceCount = mesh.faceCount;
|
|
1942
|
+
for (std::uint32_t i = 0; i < mesh.faceCount; ++i) {
|
|
1943
|
+
double* rec = outFaceData + i * kFractureFaceStride;
|
|
1944
|
+
const DeformableFace& f = mesh.faces[i];
|
|
1945
|
+
rec[0] = static_cast<double>(f.id);
|
|
1946
|
+
rec[1] = static_cast<double>(f.vertex0);
|
|
1947
|
+
rec[2] = static_cast<double>(f.vertex1);
|
|
1948
|
+
rec[3] = static_cast<double>(f.vertex2);
|
|
1949
|
+
rec[4] = f.restArea;
|
|
1950
|
+
rec[5] = static_cast<double>(f.flags);
|
|
1951
|
+
rec[6] = static_cast<double>(f.fragmentId);
|
|
1952
|
+
rec[7] = f.reserved;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
if (outEventData != nullptr && outEventCount != nullptr) {
|
|
1957
|
+
*outEventCount = mesh.eventCount;
|
|
1958
|
+
for (std::uint32_t i = 0; i < mesh.eventCount; ++i) {
|
|
1959
|
+
double* rec = outEventData + i * kFractureEventStride;
|
|
1960
|
+
const DeformableEvent& e = mesh.events[i];
|
|
1961
|
+
rec[0] = static_cast<double>(e.type);
|
|
1962
|
+
rec[1] = static_cast<double>(e.tick);
|
|
1963
|
+
rec[2] = static_cast<double>(e.elementId);
|
|
1964
|
+
rec[3] = static_cast<double>(e.relatedId);
|
|
1965
|
+
rec[4] = e.metric;
|
|
1966
|
+
rec[5] = e.posX; rec[6] = e.posY; rec[7] = e.posZ;
|
|
1967
|
+
rec[8] = static_cast<double>(e.fragmentId);
|
|
1968
|
+
rec[9] = static_cast<double>(e.subIndex);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
if (outFragmentCount != nullptr) *outFragmentCount = mesh.fragmentCount;
|
|
1973
|
+
if (outNextVertexId != nullptr) *outNextVertexId = mesh.nextVertexId;
|
|
1974
|
+
if (outNextConstraintId != nullptr) *outNextConstraintId = mesh.nextConstraintId;
|
|
1975
|
+
if (outNextFaceId != nullptr) *outNextFaceId = mesh.nextFaceId;
|
|
1976
|
+
if (outNextFragmentId != nullptr) *outNextFragmentId = mesh.nextFragmentId;
|
|
1977
|
+
|
|
1978
|
+
return static_cast<std::int32_t>(FractureStatus::Success);
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
}
|