Skip to content

Commit

Permalink
Merge pull request #99 from LeXXik/shapes
Browse files Browse the repository at this point in the history
Shapes
  • Loading branch information
LeXXik authored Oct 2, 2024
2 parents 11a9113 + 0f33af6 commit 2d759b8
Show file tree
Hide file tree
Showing 32 changed files with 4,376 additions and 6,433 deletions.
53 changes: 53 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import playcanvasConfig from '@playcanvas/eslint-config';
import babelParser from '@babel/eslint-parser';
import globals from 'globals';

export default [
...playcanvasConfig,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
parser: babelParser,
parserOptions: {
requireConfigFile: false
},
globals: {
...globals.browser,
...globals.mocha,
...globals.node,
'Jolt': 'readonly',
'$_DEBUG': 'readonly',
'$_VERSION': 'readonly',
'$_JOLT_VERSION': 'readonly'
}
},
rules: {
'import/order': 'off',
'no-eval': 'off',
'no-new-wrappers': 'off',
'jsdoc/check-tag-names': [
'error',
{
'definedTags': [
'defaultValue',
'category',
'group',
'hidden',
'import'
]
}
]
}
},
{
files: ['test/**/*.mjs'],
rules: {
'no-unused-expressions': 'off',
'prefer-arrow-callback': 'off', // Mocha uses function callbacks
'no-var': 'error',
'quotes': ['error', 'single']
}
}
];
9,998 changes: 3,883 additions & 6,115 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 7 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gamebop/physics",
"description": "Physics components for PlayCanvas engine",
"version": "0.3.3",
"version": "0.3.4",
"main": "dist/physics.min.mjs",
"author": "Gamebop",
"license": "MIT",
Expand All @@ -11,7 +11,7 @@
"build:dev": "rimraf dist && rollup -c --config_dev",
"build:prod": "rimraf dist && rollup -c",
"build:publish": "rimraf dist && rollup -c && rollup -c --config_dev && npm run publint",
"lint": "eslint --ext .mjs, src test rollup.config.mjs",
"lint": "eslint src test eslint.config.mjs rollup.config.mjs",
"publint": "publint",
"docs": "typedoc",
"test": "mocha --recursive"
Expand All @@ -23,46 +23,23 @@
"type": "git",
"url": "https://github.com/gamebop/physics.git"
},
"eslintConfig": {
"extends": "@playcanvas/eslint-config",
"rules": {
"no-eval": "off",
"no-new-wrappers": "off",
"jsdoc/check-tag-names": [
"error",
{
"definedTags": [
"defaultValue",
"category",
"group",
"hidden",
"import"
]
}
]
},
"globals": {
"Jolt": "readonly",
"$_DEBUG": "readonly",
"$_VERSION": "readonly",
"$_JOLT_VERSION": "readonly"
}
},
"files": [
"dist/*"
],
"peerDependencies": {
"jolt-physics": "^0.25.0",
"jolt-physics": "^0.26.0",
"playcanvas": "^1.71.3"
},
"devDependencies": {
"@playcanvas/eslint-config": "^1.7.1",
"@babel/eslint-parser": "^7.25.1",
"@playcanvas/eslint-config": "^2.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-strip": "^3.0.4",
"@rollup/plugin-terser": "^0.4.4",
"chai": "^5.1.1",
"eslint": "^8.57.0",
"eslint": "^9.11.1",
"globals": "^15.10.0",
"mocha": "^10.4.0",
"publint": "^0.2.7",
"rimraf": "^5.0.5",
Expand Down
6 changes: 3 additions & 3 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import strip from '@rollup/plugin-strip';
import jscc from 'rollup-plugin-jscc';
import terser from '@rollup/plugin-terser';
import jscc from 'rollup-plugin-jscc';
import json from '@rollup/plugin-json';
import { readFileSync } from 'fs';
import strip from '@rollup/plugin-strip';
import { nodeResolve } from '@rollup/plugin-node-resolve';

const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
const joltPkg = JSON.parse(readFileSync(new URL('./node_modules/jolt-physics/package.json', import.meta.url), 'utf8'));
Expand Down
5 changes: 3 additions & 2 deletions src/physics/init.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,9 @@ function init(app, opts = {}) {

if (app[propertyName]) {
if ($_DEBUG) {
Debug.warn(`Unable to initialize Physics Manager. Application has an existing property name that conflicts. ` +
`Tried to use "app.${propertyName}". Use { propertyName: string } in init options to use a custom property name. Aborting.`);
Debug.warn('Unable to initialize Physics Manager. Application has an existing ' +
`property name that conflicts. Tried to use "app.${propertyName}". Use ` +
'{ propertyName: string } in init options to use a custom property name. Aborting.');
}
reject(new Error('Selected property name is not available.'));
return;
Expand Down
3 changes: 2 additions & 1 deletion src/physics/jolt/back/backend.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,9 @@ class JoltBackend {
const characters = tracker.character;
const count = characters.size;

if (count === 0)
if (count === 0) {
return true;
}

const useMotionStates = this._config.useMotionStates;

Expand Down
32 changes: 19 additions & 13 deletions src/physics/jolt/back/commands-buffer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ class CommandsBuffer {
}
const value = this._view.getFloat32(this._bytesOffset);
if ($_DEBUG) {
Debug.checkFloat(value, `Got invalid value from buffer: ${value}`);
Debug.checkFloat(value);
}
this._bytesOffset += FLOAT32_SIZE;
return value;
}

writeFloat32(value, offset) {
if ($_DEBUG) {
const ok = Debug.checkFloat(value, `Trying to write invalid value to buffer: ${value}`);
const ok = Debug.checkFloat(value);
if (!ok) {
return false;
}
Expand Down Expand Up @@ -243,8 +243,8 @@ class CommandsBuffer {

writeUint8(value, offset) {
if ($_DEBUG) {
let ok = Debug.checkUint(value, `Trying to write invalid value to buffer: ${value}`);
ok = ok && Debug.assert(value <= 255, `Value is larger than int8: ${value}`);
let ok = Debug.checkUint(value);
ok = ok && Debug.assert(value <= 255);
if (!ok) {
return false;
}
Expand Down Expand Up @@ -276,16 +276,16 @@ class CommandsBuffer {
}
const value = this._view.getUint16(this._bytesOffset);
if ($_DEBUG) {
Debug.checkUint(value, `Got invalid value from buffer: ${value}`);
Debug.checkUint(value);
}
this._bytesOffset += UINT16_SIZE;
return value;
}

writeUint16(value, offset) {
if ($_DEBUG) {
let ok = Debug.checkUint(value, `Trying to write invalid value to buffer: ${value}`);
ok = ok && Debug.assert(value <= 65535, `Value is larger than int16: ${value}`);
let ok = Debug.checkUint(value);
ok = ok && Debug.assert(value <= 65535);
if (!ok) {
return false;
}
Expand Down Expand Up @@ -317,16 +317,16 @@ class CommandsBuffer {
}
const value = this._view.getUint32(this._bytesOffset);
if ($_DEBUG) {
Debug.checkUint(value, `Got invalid value from buffer: ${value}`);
Debug.checkUint(value);
}
this._bytesOffset += UINT32_SIZE;
return value;
}

writeUint32(value, offset) {
if ($_DEBUG) {
let ok = Debug.checkUint(value, `Trying to write invalid value to buffer: ${value}`);
ok = ok && Debug.assert(value <= 4294967295, `Value is larger than int32: ${value}`);
let ok = Debug.checkUint(value);
ok = ok && Debug.assert(value <= 4294967295);
if (!ok) {
return false;
}
Expand Down Expand Up @@ -358,15 +358,15 @@ class CommandsBuffer {
}
const value = this._view.getInt32(this._bytesOffset);
if ($_DEBUG) {
Debug.checkInt(value, `Got invalid value from buffer: ${value}`);
Debug.checkInt(value);
}
this._bytesOffset += INT32_SIZE;
return value;
}

writeInt32(value, offset) {
if ($_DEBUG) {
const ok = Debug.checkInt(value, `Trying to write invalid value to buffer: ${value}`);
const ok = Debug.checkInt(value);
if (!ok) {
return false;
}
Expand Down Expand Up @@ -404,7 +404,8 @@ class CommandsBuffer {

writePlane(plane) {
if ($_DEBUG) {
const ok = Debug.assert(!!plane && plane instanceof Plane, `Trying to write invalid Plane instance to buffer`, plane);
const ok = Debug.assert(!!plane && plane instanceof Plane,
'Trying to write invalid Plane instance to buffer', plane);
if (!ok) {
return false;
}
Expand Down Expand Up @@ -437,6 +438,11 @@ class CommandsBuffer {
this._buffer = null;
}

decrement(size) {
this._view.setUint16(0, --this._commandsCount);
this._bytesOffset -= size;
}

_increment() {
this._view.setUint16(0, ++this._commandsCount);
}
Expand Down
Loading

0 comments on commit 2d759b8

Please sign in to comment.