Skip to content
Open
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
8 changes: 4 additions & 4 deletions src.ts/coarena.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Coarena<T> {
}

public set(handle: number, data: T) {
let i = this.index(handle);
let i = this.#index(handle);
while (this.data.length <= i) {
this.data.push(null);
}
Expand All @@ -26,7 +26,7 @@ export class Coarena<T> {
}

public delete(handle: number) {
let i = this.index(handle);
let i = this.#index(handle);
if (i < this.data.length) {
if (this.data[i] != null) this.size -= 1;
this.data[i] = null;
Expand All @@ -38,7 +38,7 @@ export class Coarena<T> {
}

public get(handle: number): T | null {
let i = this.index(handle);
let i = this.#index(handle);
if (i < this.data.length) {
return this.data[i];
} else {
Expand All @@ -56,7 +56,7 @@ export class Coarena<T> {
return this.data.filter((elt) => elt != null);
}

private index(handle: number): number {
#index(handle: number): number {
/// Extracts the index part of a handle (the lower 32 bits).
/// This is done by first injecting the handle into an Float64Array
/// which is itself injected into an Uint32Array (at construction time).
Expand Down
12 changes: 6 additions & 6 deletions src.ts/dynamics/impulse_joint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export enum JointAxesMask {

export class ImpulseJoint {
protected rawSet: RawImpulseJointSet; // The ImpulseJoint won't need to free this.
protected bodySet: RigidBodySet; // The ImpulseJoint won’t need to free this.
#bodySet: RigidBodySet; // The ImpulseJoint won’t need to free this.
handle: ImpulseJointHandle;

constructor(
Expand All @@ -81,7 +81,7 @@ export class ImpulseJoint {
handle: ImpulseJointHandle,
) {
this.rawSet = rawSet;
this.bodySet = bodySet;
this.#bodySet = bodySet;
this.handle = handle;
}

Expand Down Expand Up @@ -114,7 +114,7 @@ export class ImpulseJoint {

/** @internal */
public finalizeDeserialization(bodySet: RigidBodySet) {
this.bodySet = bodySet;
this.#bodySet = bodySet;
}

/**
Expand All @@ -129,14 +129,14 @@ export class ImpulseJoint {
* The first rigid-body this joint it attached to.
*/
public body1(): RigidBody {
return this.bodySet.get(this.rawSet.jointBodyHandle1(this.handle));
return this.#bodySet.get(this.rawSet.jointBodyHandle1(this.handle));
}

/**
* The second rigid-body this joint is attached to.
*/
public body2(): RigidBody {
return this.bodySet.get(this.rawSet.jointBodyHandle2(this.handle));
return this.#bodySet.get(this.rawSet.jointBodyHandle2(this.handle));
}

/**
Expand Down Expand Up @@ -371,7 +371,7 @@ export class JointData {
damping: number;
length: number;

private constructor() {}
constructor() {}

/**
* Creates a new joint descriptor that builds a Fixed joint.
Expand Down
26 changes: 13 additions & 13 deletions src.ts/dynamics/impulse_joint_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {Collider, ColliderHandle} from "../geometry";
*/
export class ImpulseJointSet {
raw: RawImpulseJointSet;
private map: Coarena<ImpulseJoint>;
#map: Coarena<ImpulseJoint>;

/**
* Release the WASM memory occupied by this joint set.
Expand All @@ -36,26 +36,26 @@ export class ImpulseJointSet {
}
this.raw = undefined;

if (!!this.map) {
this.map.clear();
if (!!this.#map) {
this.#map.clear();
}
this.map = undefined;
this.#map = undefined;
}

constructor(raw?: RawImpulseJointSet) {
this.raw = raw || new RawImpulseJointSet();
this.map = new Coarena<ImpulseJoint>();
this.#map = new Coarena<ImpulseJoint>();
// Initialize the map with the existing elements, if any.
if (raw) {
raw.forEachJointHandle((handle: ImpulseJointHandle) => {
this.map.set(handle, ImpulseJoint.newTyped(raw, null, handle));
this.#map.set(handle, ImpulseJoint.newTyped(raw, null, handle));
});
}
}

/** @internal */
public finalizeDeserialization(bodies: RigidBodySet) {
this.map.forEach((joint) => joint.finalizeDeserialization(bodies));
this.#map.forEach((joint) => joint.finalizeDeserialization(bodies));
}

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ export class ImpulseJointSet {
);
rawParams.free();
let joint = ImpulseJoint.newTyped(this.raw, bodies, handle);
this.map.set(handle, joint);
this.#map.set(handle, joint);
return joint;
}

Expand Down Expand Up @@ -115,14 +115,14 @@ export class ImpulseJointSet {
* @param handle
*/
public unmap(handle: ImpulseJointHandle) {
this.map.delete(handle);
this.#map.delete(handle);
}

/**
* The number of joints on this set.
*/
public len(): number {
return this.map.len();
return this.#map.len();
}

/**
Expand All @@ -142,7 +142,7 @@ export class ImpulseJointSet {
* @param handle - The integer handle of the joint to retrieve.
*/
public get(handle: ImpulseJointHandle): ImpulseJoint | null {
return this.map.get(handle);
return this.#map.get(handle);
}

/**
Expand All @@ -151,7 +151,7 @@ export class ImpulseJointSet {
* @param f - The closure to apply.
*/
public forEach(f: (joint: ImpulseJoint) => void) {
this.map.forEach(f);
this.#map.forEach(f);
}

/**
Expand All @@ -160,6 +160,6 @@ export class ImpulseJointSet {
* @returns joint list.
*/
public getAll(): ImpulseJoint[] {
return this.map.getAll();
return this.#map.getAll();
}
}
26 changes: 13 additions & 13 deletions src.ts/dynamics/multibody_joint_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {RigidBodyHandle} from "./rigid_body";
*/
export class MultibodyJointSet {
raw: RawMultibodyJointSet;
private map: Coarena<MultibodyJoint>;
#map: Coarena<MultibodyJoint>;

/**
* Release the WASM memory occupied by this joint set.
Expand All @@ -35,19 +35,19 @@ export class MultibodyJointSet {
}
this.raw = undefined;

if (!!this.map) {
this.map.clear();
if (!!this.#map) {
this.#map.clear();
}
this.map = undefined;
this.#map = undefined;
}

constructor(raw?: RawMultibodyJointSet) {
this.raw = raw || new RawMultibodyJointSet();
this.map = new Coarena<MultibodyJoint>();
this.#map = new Coarena<MultibodyJoint>();
// Initialize the map with the existing elements, if any.
if (raw) {
raw.forEachJointHandle((handle: MultibodyJointHandle) => {
this.map.set(handle, MultibodyJoint.newTyped(this.raw, handle));
this.#map.set(handle, MultibodyJoint.newTyped(this.raw, handle));
});
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ export class MultibodyJointSet {
);
rawParams.free();
let joint = MultibodyJoint.newTyped(this.raw, handle);
this.map.set(handle, joint);
this.#map.set(handle, joint);
return joint;
}

Expand All @@ -87,22 +87,22 @@ export class MultibodyJointSet {
*/
public remove(handle: MultibodyJointHandle, wake_up: boolean) {
this.raw.remove(handle, wake_up);
this.map.delete(handle);
this.#map.delete(handle);
}

/**
* Internal function, do not call directly.
* @param handle
*/
public unmap(handle: MultibodyJointHandle) {
this.map.delete(handle);
this.#map.delete(handle);
}

/**
* The number of joints on this set.
*/
public len(): number {
return this.map.len();
return this.#map.len();
}

/**
Expand All @@ -122,7 +122,7 @@ export class MultibodyJointSet {
* @param handle - The integer handle of the joint to retrieve.
*/
public get(handle: MultibodyJointHandle): MultibodyJoint | null {
return this.map.get(handle);
return this.#map.get(handle);
}

/**
Expand All @@ -131,7 +131,7 @@ export class MultibodyJointSet {
* @param f - The closure to apply.
*/
public forEach(f: (joint: MultibodyJoint) => void) {
this.map.forEach(f);
this.#map.forEach(f);
}

/**
Expand All @@ -152,6 +152,6 @@ export class MultibodyJointSet {
* @returns joint list.
*/
public getAll(): MultibodyJoint[] {
return this.map.getAll();
return this.#map.getAll();
}
}
Loading