Skip to content

Commit

Permalink
switch shapes to ref counts
Browse files Browse the repository at this point in the history
  • Loading branch information
LeXXik committed May 2, 2024
1 parent 85ce23f commit 0630160
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/physics/jolt/back/operators/cleaner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Cleaner {
return false;
}

Jolt.destroy(shape);
shape.Release();

tracker.shapeMap.delete(shapeNumber);

Expand Down
1 change: 1 addition & 0 deletions src/physics/jolt/back/operators/creator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class Creator {
return false;
}
const shape = shapeResult.Get();
shape.AddRef();

this._backend.tracker.shapeMap.set(num, shape);

Expand Down
5 changes: 5 additions & 0 deletions src/physics/jolt/back/operators/querier.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Debug } from '../../debug.mjs';
import {
BUFFER_READ_BOOL, BUFFER_READ_UINT32, BUFFER_READ_UINT8, BUFFER_WRITE_BOOL,
BUFFER_WRITE_JOLTVEC32, BUFFER_WRITE_UINT16, BUFFER_WRITE_UINT32, CMD_CAST_RAY, CMD_CAST_SHAPE,
COMPONENT_SYSTEM_MANAGER
} from '../../constants.mjs';

const params = [];

Expand Down
10 changes: 6 additions & 4 deletions src/physics/jolt/manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
OPERATOR_MODIFIER, OPERATOR_QUERIER
} from './constants.mjs';

const halfExtent = new Vec3(0.5, 0.5, 0.5);

class JoltManager extends PhysicsManager {
constructor(app, opts, resolve) {
const config = {
Expand Down Expand Up @@ -167,10 +169,10 @@ class JoltManager extends PhysicsManager {
const opts = {
// defaults
density: 1000,
shapePosition: new Vec3(),
shapeRotation: new Quat(),
scale: new Vec3(1, 1, 1),
halfExtent: new Vec3(0.5, 0.5, 0.5),
shapePosition: Vec3.ZERO,
shapeRotation: Quat.IDENTITY,
scale: Vec3.ONE,
halfExtent,
convexRadius: 0.05,
halfHeight: 0.5,
radius: 0.5,
Expand Down

0 comments on commit 0630160

Please sign in to comment.