Skip to content
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
3 changes: 1 addition & 2 deletions src/physics/jolt/back/commands-buffer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
BUFFER_WRITE_UINT32, BUFFER_WRITE_UINT8, BUFFER_WRITE_VEC32, FLOAT32_SIZE, INT32_SIZE,
UINT16_SIZE, UINT32_SIZE, UINT8_SIZE
} from '../constants.mjs';
import { Plane } from 'playcanvas';

// TODO
// hide from docs, after PhysicsManager stops using it directly
Expand Down Expand Up @@ -404,7 +403,7 @@ class CommandsBuffer {

writePlane(plane) {
if ($_DEBUG) {
const ok = Debug.assert(!!plane && plane instanceof Plane,
const ok = Debug.assert(plane && plane.normal && plane.distance,
'Trying to write invalid Plane instance to buffer', plane);
if (!ok) {
return false;
Expand Down
3 changes: 1 addition & 2 deletions src/physics/jolt/front/constraint/types/constraint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import {
BUFFER_WRITE_BOOL, BUFFER_WRITE_FLOAT32, BUFFER_WRITE_UINT16, BUFFER_WRITE_UINT32, BUFFER_WRITE_UINT8,
CMD_JNT_SET_ENABLED, CONSTRAINT_TYPE_UNDEFINED, OPERATOR_MODIFIER, SPRING_MODE_FREQUENCY
} from '../../../constants.mjs';
import { Curve, Vec3 } from 'playcanvas';

function applyOptions(instance, opts) {
for (const [key, val] of Object.entries(opts)) {
const prop = `_${key}`;
if (instance[prop] === undefined) continue;
if (val instanceof Vec3 || val instanceof Curve) {
if (val?.clone instanceof Function) {
instance[prop] = val.clone();
} else {
instance[prop] = val;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Entity, Vec3 } from 'playcanvas';
import { Vec3 } from 'playcanvas';
import { BUFFER_WRITE_UINT32, BUFFER_WRITE_UINT8, BUFFER_WRITE_VEC32, CONSTRAINT_SPACE_WORLD } from '../../../../constants.mjs';
import { Debug } from '../../../../debug.mjs';
import { Constraint, applyOptions } from '../constraint.mjs';
Expand Down Expand Up @@ -81,9 +81,9 @@ class JointConstraint extends Constraint {

write(cb) {
if ($_DEBUG) {
let ok = Debug.assert(this._entity1 instanceof Entity, 'Invalid entity1', this._entity1);
let ok = Debug.assert(this._entity1.getGuid instanceof Function, 'Invalid entity1', this._entity1);
ok = ok && Debug.assert(!!this._entity1.body, 'Invalid entity1', this._entity1);
ok = ok && Debug.assert(this._entity2 instanceof Entity, 'Invalid entity2', this._entity2);
ok = ok && Debug.assert(this._entity2.getGuid instanceof Function, 'Invalid entity2', this._entity2);
ok = ok && Debug.assert(!!this._entity2.body, 'Invalid entity2', this._entity2);
ok = ok && Debug.checkVec(this._point1);
ok = ok && Debug.checkVec(this._point2);
Expand Down
8 changes: 4 additions & 4 deletions src/physics/jolt/front/shape/component.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Asset, Mesh, Quat, SEMANTIC_POSITION, Vec3, Mat4 } from 'playcanvas';
import { Quat, SEMANTIC_POSITION, Vec3, Mat4 } from 'playcanvas';
import { Debug } from '../../debug.mjs';
import { Component } from '../component.mjs';
import {
Expand Down Expand Up @@ -295,7 +295,7 @@ class ShapeComponent extends Component {
}

if ($_DEBUG) {
const ok = Debug.assert(mesh instanceof Mesh, 'Invalid mesh', mesh);
const ok = Debug.assert(mesh && mesh.vertexBuffer && mesh.indexBuffer, 'Invalid mesh', mesh);
if (!ok) {
return;
}
Expand Down Expand Up @@ -351,7 +351,7 @@ class ShapeComponent extends Component {
let ok = false;
if (typeof asset === 'number') {
ok = Debug.checkUint(asset);
} else if (asset instanceof Asset) {
} else {
ok = true;
}
if (!ok) {
Expand Down Expand Up @@ -637,7 +637,7 @@ class ShapeComponent extends Component {
}

getMeshes(callback) {
const id = this._renderAsset instanceof Asset ? this._renderAsset.id : this._renderAsset;
const id = typeof this._renderAsset === 'number' ? this._renderAsset : this._renderAsset.id;
const assets = this.system.app.assets;

const onAssetFullyReady = (asset) => {
Expand Down
4 changes: 2 additions & 2 deletions src/physics/jolt/front/system.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Debug } from '../debug.mjs';
import { buildAccessors } from '../../util.mjs';
import { BUFFER_WRITE_UINT32 } from '../constants.mjs';
import { ComponentSystem, Quat, Vec3 } from 'playcanvas';
import { ComponentSystem } from 'playcanvas';

class JoltComponentSystem extends ComponentSystem {
_store = {};
Expand Down Expand Up @@ -103,7 +103,7 @@ class JoltComponentSystem extends ComponentSystem {
Debug.assert(value != null, `Trying to initialize a component with invalid value for property "${key}": ${value}`, data);
}

if (value instanceof Vec3 || value instanceof Quat) {
if (value?.clone instanceof Function) {
component[`_${key}`] = value.clone();
} else {
component[`_${key}`] = value;
Expand Down
Loading