From 1bbdadc89001a104fc36e025ac6378c74909846c Mon Sep 17 00:00:00 2001 From: Ali Shakiba Date: Wed, 20 Dec 2023 23:22:14 -0800 Subject: [PATCH] add style for debugging --- src/collision/Shape.ts | 4 ++++ src/dynamics/Body.ts | 4 ++++ src/dynamics/Fixture.ts | 4 ++++ src/dynamics/Joint.ts | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/collision/Shape.ts b/src/collision/Shape.ts index e42f32ed..a3d82b0b 100644 --- a/src/collision/Shape.ts +++ b/src/collision/Shape.ts @@ -27,6 +27,7 @@ import { RayCastOutput, RayCastInput, AABBValue } from './AABB'; import { DistanceProxy } from './Distance'; import type { Transform, TransformValue } from '../common/Transform'; import type { Vec2Value } from '../common/Vec2'; +import { Style } from '../util/Testbed'; // todo make shape an interface @@ -44,6 +45,9 @@ export abstract class Shape { */ m_radius: number; + /** Styling for dev-tools. */ + style: Style = {}; + /** @internal */ abstract _reset(): void; diff --git a/src/dynamics/Body.ts b/src/dynamics/Body.ts index 640e155b..2fa3deed 100644 --- a/src/dynamics/Body.ts +++ b/src/dynamics/Body.ts @@ -35,6 +35,7 @@ import { Shape } from '../collision/Shape'; import { JointEdge } from "./Joint"; import { World } from "./World"; import { ContactEdge } from "./Contact"; +import { Style } from '../util/Testbed'; /** @internal */ const _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT; @@ -217,6 +218,9 @@ export class Body { /** @internal */ m_next: Body | null; /** @internal */ m_destroyed: boolean; + /** Styling for dev-tools. */ + style: Style = {}; + /** @internal */ constructor(world: World, def: BodyDef) { def = options(def, BodyDefDefault); diff --git a/src/dynamics/Fixture.ts b/src/dynamics/Fixture.ts index 3739302c..2a6616eb 100644 --- a/src/dynamics/Fixture.ts +++ b/src/dynamics/Fixture.ts @@ -30,6 +30,7 @@ import { Shape, ShapeType } from '../collision/Shape'; import { Body, MassData } from "./Body"; import { BroadPhase } from "../collision/BroadPhase"; import { TransformValue } from "../common/Transform"; +import { Style } from '../util/Testbed'; /** @internal */ const _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT; @@ -131,6 +132,9 @@ export class Fixture { /** @internal */ m_proxyCount: number; /** @internal */ m_userData: unknown; + /** Styling for dev-tools. */ + style: Style = {}; + constructor(body: Body, def: FixtureDef); constructor(body: Body, shape: Shape, def?: FixtureOpt); constructor(body: Body, shape: Shape, density?: number); diff --git a/src/dynamics/Joint.ts b/src/dynamics/Joint.ts index cd962afb..0ab39ac8 100644 --- a/src/dynamics/Joint.ts +++ b/src/dynamics/Joint.ts @@ -25,6 +25,7 @@ import type { Vec2, Vec2Value } from '../common/Vec2'; import type { Body } from './Body'; import { TimeStep } from "./Solver"; +import { Style } from '../util/Testbed'; /** @internal */ const _ASSERT = typeof ASSERT === 'undefined' ? false : ASSERT; @@ -108,6 +109,9 @@ export abstract class Joint { /** @internal */ m_islandFlag: boolean = false; /** @internal */ m_userData: unknown; + /** Styling for dev-tools. */ + style: Style = {}; + constructor(def: JointDef); constructor(def: JointOpt, bodyA: Body, bodyB: Body); constructor(def: JointDef | JointOpt, bodyA?: Body, bodyB?: Body) {