@perplexdotgg/bounce 1.5.1 → 1.6.0
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 +1 -0
- package/build/bounce.d.ts +243 -1357
- package/build/bounce.js +24 -26
- package/package.json +2 -2
package/build/bounce.js
CHANGED
|
@@ -2457,8 +2457,8 @@ class ContactPair extends createClass()(contactPairProps) {
|
|
|
2457
2457
|
}
|
|
2458
2458
|
}
|
|
2459
2459
|
function createContactPairKey(bodyA, bodyB) {
|
|
2460
|
-
const keyA = `${bodyA.type}:${bodyA.
|
|
2461
|
-
const keyB = `${bodyB.type}:${bodyB.
|
|
2460
|
+
const keyA = `${bodyA.type}:${bodyA.poolIndex}`;
|
|
2461
|
+
const keyB = `${bodyB.type}:${bodyB.poolIndex}`;
|
|
2462
2462
|
return keyA < keyB ? `${keyA}|${keyB}` : `${keyB}|${keyA}`;
|
|
2463
2463
|
}
|
|
2464
2464
|
const linearVelocityA = /* @__PURE__ */ Vec3.create();
|
|
@@ -2833,12 +2833,12 @@ class ArrayPool {
|
|
|
2833
2833
|
return null;
|
|
2834
2834
|
}
|
|
2835
2835
|
const instance = this.array[this._count];
|
|
2836
|
-
instance.
|
|
2836
|
+
instance.poolIndex = this._count;
|
|
2837
2837
|
this._count++;
|
|
2838
2838
|
return instance;
|
|
2839
2839
|
}
|
|
2840
2840
|
remove(instance) {
|
|
2841
|
-
const index = instance.
|
|
2841
|
+
const index = instance.poolIndex;
|
|
2842
2842
|
const lastIndex = this._count - 1;
|
|
2843
2843
|
if (index === lastIndex) {
|
|
2844
2844
|
this._count--;
|
|
@@ -2846,8 +2846,8 @@ class ArrayPool {
|
|
|
2846
2846
|
}
|
|
2847
2847
|
this.array[index] = this.array[lastIndex];
|
|
2848
2848
|
this.array[lastIndex] = instance;
|
|
2849
|
-
this.array[index].
|
|
2850
|
-
this.array[lastIndex].
|
|
2849
|
+
this.array[index].poolIndex = index;
|
|
2850
|
+
this.array[lastIndex].poolIndex = lastIndex;
|
|
2851
2851
|
this._count--;
|
|
2852
2852
|
}
|
|
2853
2853
|
clear() {
|
|
@@ -3735,7 +3735,7 @@ class BodyPairsModule {
|
|
|
3735
3735
|
* @returns
|
|
3736
3736
|
*/
|
|
3737
3737
|
createPair(bodyA, bodyB) {
|
|
3738
|
-
if (bodyA.type === bodyB.type && bodyA.
|
|
3738
|
+
if (bodyA.type === bodyB.type && bodyA.poolIndex > bodyB.poolIndex) {
|
|
3739
3739
|
const temp2 = bodyA;
|
|
3740
3740
|
bodyA = bodyB;
|
|
3741
3741
|
bodyB = temp2;
|
|
@@ -8019,9 +8019,7 @@ const bodyProps = props({
|
|
|
8019
8019
|
isSleepingEnabled: BooleanType(true),
|
|
8020
8020
|
linearDamping: -1,
|
|
8021
8021
|
angularDamping: -1,
|
|
8022
|
-
firstPotentialConstraintPairEdge: LazyReferenceType(
|
|
8023
|
-
(() => ConstraintPairEdge)
|
|
8024
|
-
),
|
|
8022
|
+
firstPotentialConstraintPairEdge: LazyReferenceType((() => ConstraintPairEdge)),
|
|
8025
8023
|
visitGeneration: NumberType(0, true)
|
|
8026
8024
|
});
|
|
8027
8025
|
const afterConstructorCode = `
|
|
@@ -12474,10 +12472,10 @@ class BvhModule {
|
|
|
12474
12472
|
startOffset = this.world.pools.bvhNodes.toArray(array, startOffset);
|
|
12475
12473
|
startOffset = this.world.pools.bodyPairNode.toArray(array, startOffset);
|
|
12476
12474
|
startOffset = this.world.pools.bodyPairEdge.toArray(array, startOffset);
|
|
12477
|
-
array[startOffset++] = this.dynamicTree.root?.
|
|
12478
|
-
array[startOffset++] = this.dynamicTree.root?.
|
|
12479
|
-
array[startOffset++] = this.staticTree.root?.
|
|
12480
|
-
array[startOffset++] = this.staticTree.root?.
|
|
12475
|
+
array[startOffset++] = this.dynamicTree.root?.poolIndex ?? -1;
|
|
12476
|
+
array[startOffset++] = this.dynamicTree.root?.poolVersion ?? -1;
|
|
12477
|
+
array[startOffset++] = this.staticTree.root?.poolIndex ?? -1;
|
|
12478
|
+
array[startOffset++] = this.staticTree.root?.poolVersion ?? -1;
|
|
12481
12479
|
return startOffset;
|
|
12482
12480
|
}
|
|
12483
12481
|
fromArray(array, startOffset) {
|
|
@@ -12505,21 +12503,21 @@ class BvhModule {
|
|
|
12505
12503
|
edgeA: this.world.pools.bodyPairEdge,
|
|
12506
12504
|
edgeB: this.world.pools.bodyPairEdge
|
|
12507
12505
|
}, startOffsetBodyPairNode);
|
|
12508
|
-
const
|
|
12509
|
-
const
|
|
12510
|
-
const
|
|
12511
|
-
const
|
|
12512
|
-
if (
|
|
12513
|
-
this.dynamicTree.root = this.world.pools.bvhNodes.array[
|
|
12514
|
-
if (
|
|
12506
|
+
const dynamicTreeRootPoolIndex = array[startOffset++];
|
|
12507
|
+
const dynamicTreeRootPoolVersion = array[startOffset++];
|
|
12508
|
+
const staticTreeRootPoolIndex = array[startOffset++];
|
|
12509
|
+
const staticTreeRootPoolVersion = array[startOffset++];
|
|
12510
|
+
if (dynamicTreeRootPoolIndex >= 0) {
|
|
12511
|
+
this.dynamicTree.root = this.world.pools.bvhNodes.array[dynamicTreeRootPoolIndex];
|
|
12512
|
+
if (dynamicTreeRootPoolVersion !== this.dynamicTree.root.poolVersion) {
|
|
12515
12513
|
this.dynamicTree.root = null;
|
|
12516
12514
|
}
|
|
12517
12515
|
} else {
|
|
12518
12516
|
this.dynamicTree.root = null;
|
|
12519
12517
|
}
|
|
12520
|
-
if (
|
|
12521
|
-
this.staticTree.root = this.world.pools.bvhNodes.array[
|
|
12522
|
-
if (
|
|
12518
|
+
if (staticTreeRootPoolIndex >= 0) {
|
|
12519
|
+
this.staticTree.root = this.world.pools.bvhNodes.array[staticTreeRootPoolIndex];
|
|
12520
|
+
if (staticTreeRootPoolVersion !== this.staticTree.root.poolVersion) {
|
|
12523
12521
|
this.staticTree.root = null;
|
|
12524
12522
|
}
|
|
12525
12523
|
} else {
|
|
@@ -15247,7 +15245,7 @@ class World {
|
|
|
15247
15245
|
if (bodyA === bodyB) {
|
|
15248
15246
|
continue;
|
|
15249
15247
|
}
|
|
15250
|
-
if (bodyA.
|
|
15248
|
+
if (bodyA.poolIndex > bodyB.poolIndex) {
|
|
15251
15249
|
continue;
|
|
15252
15250
|
}
|
|
15253
15251
|
yield [bodyA, bodyB];
|
|
@@ -15268,7 +15266,7 @@ class World {
|
|
|
15268
15266
|
if (bodyA === bodyB) {
|
|
15269
15267
|
continue;
|
|
15270
15268
|
}
|
|
15271
|
-
if (bodyA.
|
|
15269
|
+
if (bodyA.poolIndex > bodyB.poolIndex) {
|
|
15272
15270
|
continue;
|
|
15273
15271
|
}
|
|
15274
15272
|
if (bodyA.computedBounds.intersectsAabb(bodyB.computedBounds) === false) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perplexdotgg/bounce",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Bounce",
|
|
6
6
|
"main": "./build/bounce.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test": "vitest"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"monomorph": "^2.0
|
|
15
|
+
"monomorph": "^2.1.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^25.0.10",
|