Releases: Prozi/detect-collisions
v6.3.5
- 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
v6.3.0
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
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
- 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
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 toRBush
tree if its realBBox
doesnt move outsideBBox + padding
.
see: https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L69-L78
v6.0.0
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
-
breaking change renamed the generic bodies union type from
TBody
toBody
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
- 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 toEllipse
, keep all others api the same