Skip to content

Releases: schteppe/p2.js

v0.7.1

21 Nov 19:01
Compare
Choose a tag to compare

Upgrades the poly-decomp dependency, and adds ContactEquation.prototype.getVelocityAlongNormal. Not much more to see here :)

v0.7.0

12 Jul 19:18
Compare
Choose a tag to compare

Summary

  • This release makes it more easy and verbose to construct Shapes due to new constructors.
  • Shapes now have position and angle properties, which indicates the local position in the body they are attached to. This also means that a Shape instance can be attached to a single Body.
  • The raycasting API is refactored and should now be more verbose and flexible.
  • TopDownVehicle class was added. Use it to make racing games!

Changes

  • Renamed Rectangle to Box 380aaa5
  • Updated all Shape constructors so they take their parameters via an options object. This way, Shape constructor parameters can be passed in the same options object. 380aaa5
    • new Rectangle(w, h) => new Box({ width: w, height: h })
    • new Capsule(l, r) => new Capsule({ length: l, radius: r })
    • new Circle(r) => new Circle({ radius: r })
    • new Convex(array) => new Convex({ vertices: array })
    • new Heightfield(array, options) => new Heightfield({ heights: array, [...other options...] })
    • new Line(l) => new Line({ length: l })
  • Removed .shapeOffsets and .shapeAngles from Body in favor of the new .position and .angle properties in the Shape instances. This means that a shape can only be added to one body. 16e1a47
  • Raycasting API is scratched and rewritten. Replaced World.prototype.raycastAll, .raycastClosest and .raycastAny with .raycast(result, ray). Moved the intersection methods in Ray to their respective Shape. d1feff1
  • Enabled island splitting by default 1aed70b
  • Increased default solver tolerance 1aed70b
  • The "point" argument in Body.prototype.applyForce should now be a vector relative to the Body position, instead of a world point 28494c1

Fixes

  • Event objects now release references to objects in parameters after emit fe2461b
  • Fix for requirejs via phaser ced0558

Additions

  • The following options can now be passed via the Shape constructor: material, position, angle, collisionGroup, collisionMask, sensor, collisionResponse 6a20c75 380aaa5
  • Added AABB.prototype.containsPoint 9423e3a
  • Added vec2.getLineSegmentsIntersection and vec2.getLineSegmentsIntersectionFraction a01ee11
  • Added AABB.prototype.overlapsRay
  • Added vec2.reflect ea9b6d5
  • Added TopDownVehicle class 33846a5
  • Added Body.prototype.getVelocityAtPoint 33846a5
  • Added object pools and prefilling 3537a2e 0b2a648
  • Added Body.prototype.applyLocalForce 28494c1
  • The following options can now be passed to Body constructor: allowSleep, collisionResponse, gravityScale, sleepSpeedLimit, sleepTimeLimit, id
  • Added Body.prototype.applyImpulse, .applyImpulseLocal, .vectorToLocalFrame, . vectorToWorldFrame 872ea6c
  • Added vec2.vectorToLocalFrame and vec2.vectorToGlobalFrame 238d120

Removals

  • Removed GridBroadphase since it is buggy and mostly unused e90c672
  • Removed World.prototype.setGlobalEquationParameters. Use .setGlobalStiffness and .setGlobalRelaxation instead 69d494b
  • Removed doProfiling and lastStepTime properties from World since it is much easier to use the browser profiling tools nowadays. 4223c88
  • Removed broken method World.prototype.clone c330903

v0.6.1

29 Mar 11:29
Compare
Choose a tag to compare

Small release, fixes some bugs and adds basic raycasting + experimental CCD.

Changes

  • Changed default broadphase algorithm to SAPBroadphase.

Fixes

  • Fixed bug in endContact event, bodyB had the value of bodyA.
  • Require.js fix for the build files, making it possible to use p2.js on the same page as require.js
  • .idleTime in Body is now initialized correctly
  • All classes now have .constructor set correctly

Additions

  • Added .collisonResponse flag for Body and Shape.
  • Added methods .raycastClosest, .raycastAll and .raycastAny to World
  • Added method Body.prototype.integrate
  • Added properties .ccdSpeedThreshold and .ccdIterations to Body

v0.6.0

09 Jul 19:06
Compare
Choose a tag to compare

Breaking changes

  • Renamed property .motionState to .type in class Body.
  • Changed constructor of RevoluteConstraint. Now the local pivots are passed as options instead of direct arguments. See the constraints demo.
  • Removed World.prototype.toJSON and .fromJSON.
  • Removed properties .enableBodySleeping and .enableIslandSleeping from World instances. The enum .sleepMode can be used instead. See the sleep demo.
  • Converted Spring to a base class for the new LinearSpring and RotationalSpring classes. LinearSpring can be used as the old Spring.
  • Utils.ARRAY_TYPE can now be overridden by injecting a global called P2_ARRAY_TYPE. Support for GLMAT_ARRAY_TYPE has been removed.

Other changes

  • Added flag .enableFrictionReduction to Narrowphase.
  • Added RevoluteConstraint.prototype.setLimits.
  • Added PrismaticConstraint.prototype.setLimits.
  • LockConstraint, DistanceConstraint, and GearConstraint can now be constructed from current body transforms.
  • RevoluteConstraint can now be constructed from the current body transforms and a world point.
  • Material id can now be passed via constructor.
  • ContactMaterial instances now have a property .contactSkinSize.
  • Added method Body.prototype.getAABB.
  • Limits for DistanceConstraint. See the DistanceConstraint demo.
  • Added Body.prototype.overlaps.
  • Added class OverlapKeeper.
  • If substepping is used in World.prototype.step, the substeps are aborted if slower than real time.
  • Added Heightfield/Convex and Heightfield/Circle collision support.
  • Added property .overlapKeeper to World.
  • EventEmitter.prototype.has can now check if any listeners were added to a given topic.
  • Added Utils.defaults.

v0.5.0

05 Apr 21:40
Compare
Choose a tag to compare
  • Added property .enableIslandSleeping to World.
  • Added property .useFrictionGravityOnZeroGravity to World.
  • Renamed .useWorldGravityForFrictionApproximation in World to .useWorldGravityAsFrictionGravity to keep things more uniform.
  • Sleep improvements.
  • Added property .frictionIterations to GSSolver, and removed .skipFrictionIterations.
  • Upgraded to gl-matrix 2.1.0.
  • Removed QuadTree.
  • Removed mat2.
  • Added Utils.extend.
  • Added methods .setStiffness and .setRelaxation methods to Constraint.
  • Removed properties .stiffness, .relaxation and .useGlobalEquationParameters from GSSolver.
  • Added methods .setGlobalStiffness, .setGlobalRelaxation, .setGlobalEquationParameters to World.
  • Renamed property .eps to .epsilon for Equation.
  • Removed property .useBoundingBoxes from NaiveBroadphase in favor of the new property .boundingVolumeType in Broadphase.
  • Added methods .getMaxForce and .setMaxForce to LockConstraint.
  • Changed property names .bi, .bj, .ni, .ri, .rj to .bodyA, .bodyB, .normalA, .contactPointA, .contactPointB in Equation, ContactEquation and FrictionEquation classes.
  • Removed IslandSolver in favor of the new property World.islandSplit.
  • Changed constructors of the Constraints so they all take an options object as last parameter.
  • Added property .collideConnected to Constraint.
  • Added property .islandSplit to World.
  • Added methods .disableBodyCollision and .enableBodyCollision to World.
  • Added properties .useWorldGravityForFrictionApproximation and .frictionGravity to World.
  • Added Heightfield class.
  • Removed properties .defaultFriction and .defaultRestitution from World, in favor of .defaultContactMaterial.
  • Added property .enabled to Equation.
  • Added property .surfaceVelocity to ContactMaterial.
  • Added property .sensor to Shape.
  • World now emits events 'beginContact', 'endContact' and 'preSolve'.
  • Added property .gravityScale to Body.
  • Renamed class SAP1DBroadphase to SAPBroadphase.
  • Added property .interpolatedPosition to `Body``.
  • Added method .internalStep to World.
  • Added property .applyGravity to World.
  • Renamed method .computeC to .computeInvC in Equation, and made it compute the inverse.
  • Added static method Utils.splice.
  • Added property .world to Body.
  • Added property .fixedRotation to Body.
  • Added class AABB.
  • Added properties .aabb and .aabbNeedsUpdate to Body, as well as a method .updateAABB.
  • Added property .useBoundingBoxes to NaiveBroadphase.
  • Added static method Broadphase.aabbCheck.
  • Added method .computeAABB to Shape.
  • Added static method Broadphase.canCollide.
  • Body now inherits from EventEmitter, and dispatches events 'sleep','sleepy' and 'wakeup'.
  • Added properties .allowSleep, .sleepState, .sleepSpeedLimit, .sleepTimeLimit, .lastTimeSleepy as well as methods .sleep, .wakeUp and .sleepTick to Body.
  • Added enums Body.AWAKE, Body.SLEEPY, Body.SLEEPING.
  • Added property .enableBodySleeping to World.
  • Added options .disableRotationalLock, .lowerLimit, .upperLimit to PrismaticConstraint constructor.
  • Added methods .enableMotor, .disableMotor to PrismaticConstraint as well as properties .motorEnabled, .motorSpeed, .motorEquation.

v0.4.0

22 Jan 21:04
Compare
Choose a tag to compare
  • Added properties .damping and .angularDamping to Body.
  • Added property .applyDamping to World.
  • Added properties .shapeA and .shapeB to ContactEquation and FrictionEquation.
  • Added property .contactEquation to FrictionEquation.
  • Added property .multiplier to Equation.
  • Added properties .lowerLimitEnabled, .lowerLimit, .upperLimitEnabled, .upperLimit to RevoluteConstraint.
  • Added property .frictionCoefficient to FrictionEquation and Narrowphase. The solver now updates the friction force bounds dynamically in the solver from this value. FrictionEquation.setSlipForce() is thus deprecated.
  • Changed name of Narrowphase.convexPlane to Narrowphase.planeConvex.
  • Changed name of Narrowphase.capsulePlane to Narrowphase.planeCapsule.
  • Added property .emitImpactEvent to World.
  • Added method .getBodyById to World.
  • Added property .skipFrictionIterations to GSSolver.
  • Changed parameter names for PrismaticConstraint. This breaks backwards compatibility.
  • Added properties .localAxisA, .localAnchorA, .localAnchorB, to PrismaticConstraint.