Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch shapes to ref counts #3

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading