Skip to content

Releases: Prozi/detect-collisions

v6.3.5

07 Aug 22:53
Compare
Choose a tag to compare
  • feat: improve readme and api documentation (typedoc plugins)
  • feat: add utils getBounceDirection function for simple bouncing as used in stress test
  • feat: add test for getBounceDirection
  • tried to move @types/rbush and @types/sat to devDependencies but that won't work so no changes here

v6.3.1

02 Aug 18:33
Compare
Choose a tag to compare

My test shamefuly didnt include the corner case of position being nonzero

  • fixed this by adding to Tank the case
  • fixed the case
  • improved performance of concave sub-polygons recreation (something I mentioned in previous)

please use this instead of v6.3.0 :-)

v6.3.0

02 Aug 17:22
Compare
Choose a tag to compare

So, I've found this part in readme about concave and convex polygons.

Detect-Collisions uses the Separating Axis Theorem (SAT) for its narrow-phase collision tests. One caveat to SAT is that it only works properly on convex bodies. However, concave polygons can be "faked" by using a series of lines. Keep in mind that a polygon drawn using lines is "hollow".
Handling true concave polygons requires breaking them down into their component convex polygons (Convex Decomposition) and testing them for collisions individually. There are plans to integrate this functionality into the library in the future, but for now, check out poly-decomp.js.

Did some research, wrote a Test that failed (Test Driven Development for the win) because one of polygons was concave

I used wikipedia image as reference to write the test

Then I used the poly-decomp library to fix the test by implementing concave polygons detection, which requires breaking a polygon points into smaller polygons and then doing a check there. It can be optimised further I'm sure. For now this happens only on 2 concave polygons, and doesn't reuse the small Polygons.

The https://prozi.github.io/detect-collisions/demo/?stress took about I think 5% performance hit so for you out there that don't need this feature maybe stick to <= v6.3.0

v6.2.2

30 Jul 00:20
Compare
Choose a tag to compare

fixed #30 by undoing a bug introduced in v6.2.0

resigned from using clockwise(points) on points array of polygon - I thought that was necessary for proper rbush working with polygons but I don't think so anymore, if you encounter any problems with polygons not colliding properly please report asap thank you

also added 2 tests for polygon with clockwise and counter-clockwise points

v6.2.0

23 Jul 22:20
Compare
Choose a tag to compare
  • added options parameter to createCircle (fixed #29)
  • added options parameter to createPoint
  • resigned from using clockwise(points) on points array of polygon - I thought that was necessary for proper rbush working with polygons but I don't think so anymore, if you encounter any problems with polygons not colliding properly please report asap thank you
  • fixed minor readme typo (in section about inserting bodies to test for collision the body name was collider instead of circle - there was no collider in that scope)
  • regenerated documentation and demos
  • published this version (6.2.0) obviously to npm - as 6.1.0 was missing there (I guess I must've forgotten)
  • fixed dev dependencies vulnerability with terser, now it's all green and clean again

v6.1.0

03 Jul 04:52
Compare
Choose a tag to compare

implemented padding as one of Body creating options

defaults to 0

  • when specified, the body will get a slightly bigger BBox, and
  • the Body will not be removed and reinserted to RBush tree if its real BBox doesnt move outside BBox + padding.

see: https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L69-L78

v6.0.0

30 Jun 21:43
Compare
Choose a tag to compare

as pointed out in #28

other bodies than box could use center() method too, so I implemented it for them all (without circle, and ellipse, which are obviously centered from creation)

breaking changes

1

system.create* functions last parameter angle: number is replaced by options?: BodyOptions - https://prozi.github.io/detect-collisions/interfaces/BodyOptions.html so you can specify either of:

  • angle?: number
  • center?: boolean
  • isStatic?: boolean
  • isTrigger?: boolean

2

new Line(start, end)

won't anymore by default create a centered line (with anchor in the middle). to do that pass { center: true } to line 3rd parameter as written above

v5.0.0

14 Jun 17:40
Compare
Choose a tag to compare
  • breaking change renamed the generic bodies union type from TBody to Body as I wanted to do this for some time.

  • exported SAT.Result from model (so from main export too)

  • updated readme, cleaned up few things, added some types

  • fixed dev dependency security minimist alert

  • upgraded all dependencies to latest

v4.0.0

29 Apr 23:50
Compare
Choose a tag to compare
  • improved types
  • added more strict tslint rules
  • improved code a tiny bit
  • improved raycast is now tiny bit faster with polygons
  • default oval/ellipse step parameter increased for performance, if you need a perfect shape use = 1
  • breaking change changed Oval instances and naming to Ellipse, keep all others api the same

v3.5.0

18 Apr 16:29
Compare
Choose a tag to compare

finally found the time to implement system.raycast(from, to) as requested in #9

this makes all issues closed for the moment and I would call the version stable