Commit Graph

130 Commits

Author SHA1 Message Date
Matthias Richter
8283c13cfb Add shape:inGroup() 2012-12-15 16:01:21 +01:00
Matthias Richter
788c735ef7 Merge branch 'master' of github.com:vrld/HardonCollider 2012-10-12 18:53:01 +02:00
Matthias Richter
6931ca823a More robust way of handling collisons with concave shapes 2012-10-12 18:52:41 +02:00
Matthias Richter
28e80aeb6f Fix #21: CircleShape:collidesWith() incorrect. 2012-10-12 18:17:34 +02:00
Matthias Richter
8b30af1385 Refactor: Remove shape ids in main module. 2012-10-09 00:50:46 +02:00
Matthias Richter
ed495d3306 Report collisions immediately instead of collecting first.
Collecting collisions and then reporting leads to confusing behavior
when a previous collision callback resolved the collision, e.g.
platforms in jump in runs pushing the player upwards when standing on
two platforms at the same time.
2012-10-08 13:48:30 +02:00
Matthias Richter
68de65f22e Fix #19: outcircle not changed when scaling polygon. 2012-07-30 19:27:55 +02:00
Matthias Richter
1d5196cd70 Fix #18: Invalid check for class-commons. 2012-07-22 12:13:10 +02:00
Matthias Richter
de82e88ddf Add HC:shapesInRange(x1,y1, x2,y2)
Returns a set of shapes that are enclosed in the rectangle
(x1,y1)-(x2,y2).
2012-07-10 16:35:27 +02:00
Matthias Richter
317cce31c6 Add HC:addShape(shape).
Shape must have at least two functions:
- shape:bbox()
  must return an axis aligned bounding box of the shape

- shape:collidesWith(other)
  must return false, ... if the two shapes do not collide
  must return true, sx, sy if the two shapes collide, where sx,sy is the
                           separation vector from from shape to other.

Convex shapes can use the supplied GJK algorithm. In that case the shape
must implement shape:support(dx,dy) which returns the point of the shape
that lies furthest in the direction of dx,dy.
2012-07-10 16:29:59 +02:00
Matthias Richter
ebaabd22b7 Code refactoring 2012-07-10 16:29:34 +02:00
Matthias Richter
f1ad856da9 Remove Spatialhash:getNeighbors() in favor of :inRange() 2012-07-10 16:21:33 +02:00
Matthias Richter
1280b0a2d4 Use hash:rangeIter() in HC:update() 2012-07-10 16:19:27 +02:00
Matthias Richter
9badb23125 Add Spatialhash:inRange() and Spatialhash:rangeIter() 2012-07-10 16:18:53 +02:00
Matthias Richter
5125f35e71 Quick exit on shape:collidesWith(shape) 2012-07-10 16:18:20 +02:00
Matthias Richter
b20fc496eb Add shape:scale(s). 2012-07-05 17:30:13 +02:00
Matthias Richter
694cc05024 Fix polygon merging. Add polygon:scale(s, cx, cy).
Polygon merging failed due to invalid computation of shared edge.

polygon:scale(s,cx,cy) scales polygon by factor s wrt point cx,cy.
2012-07-05 17:27:33 +02:00
Matthias Richter
6b23a5c4c4 More numerically stable point-in-triangle test 2012-06-29 12:21:47 +02:00
Matthias Richter
ea49f9df8b Issue #14: Remove usage of collision ID. 2012-06-10 14:24:30 +02:00
Matthias Richter
e03ea9b0a2 Spatial hash to use number instead of table arguments 2012-05-30 15:27:09 +02:00
Matthias Richter
ce4b8011da Collision detection using GJK/EPA instead of SAT.
The Gilbert–Johnson–Keerthi collision detection algorithm is
significantly faster than collision detection using the separating axis
theorem. GJK can only determine whether two shapes collide, but not the
penetration vector. The expanding polytype algorithm can use information
from GJK to quickly find the required vector.
2012-05-20 16:50:35 +02:00
Matthias Richter
490b8775a2 Remove unpackHelper from polygon.lua 2012-05-19 17:31:19 +02:00
Matthias Richter
c3011ad841 Faster Polygon:unpack() 2012-05-19 12:41:25 +02:00
Matthias Richter
bf95f1e5fc Remove debug print in hash:update() 2012-04-26 20:29:33 +02:00
Matthias Richter
7d09bd30e2 Fix issue #10. Fix spatialhash drawing.
Shapes were not inserted into the spatial hash when not moved. Shapes
set to passive directly after creation would not be in the hash,
resulting in no collision reports.

Spatialhash drawing updated to the new cell indexing method.
2012-04-22 01:10:28 +02:00
Matthias Richter
9ac3d870ff Remove output on console 2012-04-22 01:10:11 +02:00
Matthias Richter
5b12e72aae Switch to light vector module 2012-04-12 16:07:50 +02:00
Matthias Richter
8a182a902f Rename HC:testPoint to HC:shapesAt. More efficient implementation. 2012-03-05 10:37:36 +01:00
Matthias Richter
1fd4dff37e Merge remote-tracking branch 'technocat/master' 2012-03-05 10:32:51 +01:00
Matthias Richter
a7c65630ef Iterators for active and neighboring shapes. 2012-03-05 10:26:14 +01:00
Danny "TechnoCat" Fritz
b58631465c Added HC:testPoint(x, y) -- Test point for collisions with active objects. 2012-03-03 20:06:39 -06:00
Matthias Richter
87f964cb43 Fix shape:intersectsRay(). 2012-02-20 13:13:49 +01:00
Matthias Richter
ac27eee778 Fix HC:remove(shape, ...) to accept varargs. 2012-02-20 10:54:07 +01:00
Matthias Richter
940266e0dc Add shape:bbox(). Simplify hash aware functions 2012-02-11 19:38:09 +01:00
Matthias Richter
d8af7e3d2d Fix typo in HC:clear(): self._hash instead of self.hash. 2012-01-29 14:19:59 +01:00
Matthias Richter
c681391033 Fix triangulation. Use class-commons. Add hash:draw()
Polygon triangulation bug:
In some cases Kongs triangulation algorithm produces triangles
with collinear points. The Polygon constructor removes one of
these and throws an error because there are not enough vertices.
Checking if the current points in a triangulation step are
collinear and discarding those triangles fixes the problem.

Class-commons lets you use any supporting class system as
backend for HC.

Add SpatialHash:draw() for debug purposes.
2012-01-22 00:09:54 +01:00
Matthias Richter
ab08c5744b Silly me, Lua doesn't work this way 2011-11-13 16:00:08 +01:00
Matthias Richter
956df262d5 Avoid using module(). Make main module a class. 2011-11-13 14:15:46 +01:00
Matthias Richter
5aa6b335be Add HC.clear() 2011-08-12 13:00:54 +02:00
Matthias Richter
eb2ef94212 Update class lib 2011-08-12 13:00:44 +02:00
Matthias Richter
06dc6bed68 Merge start and persits callback. Add HC.setPassive 2011-06-03 18:06:42 +02:00
Matthias Richter
8b29ebc616 Add shape:setRotation() and shape:rotation() 2011-02-27 17:00:49 +01:00
Matthias Richter
06ae1d0910 Fix polygon rotation. 2011-02-27 14:48:46 +01:00
Matthias Richter
68af2448fd Fix typo 2011-02-26 21:39:24 +01:00
Matthias Richter
4e6d4be0e9 rawset! 2011-02-26 18:57:21 +01:00
Matthias Richter
736c9ba933 Fix PointShape:intersectsRay() - return true only of point on ray 2011-02-26 17:43:22 +01:00
Matthias Richter
787c980fdd Add point shape 2011-02-26 17:27:04 +01:00
Matthias Richter
7a97797108 Invert reported MTV when delaying collision detection to other shape 2011-02-23 18:04:45 +01:00
Matthias Richter
8ae0f831da Fix circle/circle collision, Fix MTV computation 2011-02-23 17:33:35 +01:00
Matthias Richter
97b470b059 Fix bug: Polygon:contains() fails for rectangles when point left of shape 2011-02-21 17:16:13 +01:00