UNPKG

@box2d/debug-draw

Version:

Debug drawing helper for @box2d

107 lines (106 loc) 3.2 kB
"use strict"; // MIT License Object.defineProperty(exports, "__esModule", { value: true }); exports.b2SolverData = exports.b2Velocity = exports.b2Position = exports.b2TimeStep = exports.b2Profile = void 0; // Copyright (c) 2019 Erin Catto // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. const b2_math_1 = require("../common/b2_math"); /** * Profiling data. Times are in milliseconds. */ class b2Profile { constructor() { this.step = 0; this.collide = 0; this.solve = 0; this.solveInit = 0; this.solveVelocity = 0; this.solvePosition = 0; this.broadphase = 0; this.solveTOI = 0; } Reset() { this.step = 0; this.collide = 0; this.solve = 0; this.solveInit = 0; this.solveVelocity = 0; this.solvePosition = 0; this.broadphase = 0; this.solveTOI = 0; return this; } } exports.b2Profile = b2Profile; /** * This is an internal structure. */ class b2TimeStep { constructor() { this.dt = 0; // time step this.inv_dt = 0; // inverse time step (0 if dt == 0). this.dtRatio = 0; // dt * inv_dt0 this.config = { velocityIterations: 0, positionIterations: 0, }; this.warmStarting = false; } static Create() { return new b2TimeStep(); } Copy(step) { this.dt = step.dt; this.inv_dt = step.inv_dt; this.dtRatio = step.dtRatio; this.config = { ...step.config, }; this.warmStarting = step.warmStarting; return this; } } exports.b2TimeStep = b2TimeStep; /** * This is an internal structure. */ class b2Position { constructor() { this.c = new b2_math_1.b2Vec2(); this.a = 0; } } exports.b2Position = b2Position; /** * This is an internal structure. */ class b2Velocity { constructor() { this.v = new b2_math_1.b2Vec2(); this.w = 0; } } exports.b2Velocity = b2Velocity; /** * Solver Data */ class b2SolverData { constructor() { this.step = b2TimeStep.Create(); } } exports.b2SolverData = b2SolverData;