NessEngine Posted July 27, 2015 Share Posted July 27, 2015 Hi all, For one of my projects I wrote a smart & lightweight collision detection lib and decided to publish it. It's not a physical engine, its just the collision part, but made extremely easy and efficient. something like this:var world = new SSCD.World();world.add(new SSCD.Circle(new SSCD.Vector(100, 100), 75));if (world.test_collision(new SSCD.Vector(105, 125))){ alert("Yeah!")}Key features: Collision detection with the following shapes:PointsCirclesRectanglesLinesLine strips (for complex shapes)Composite shapesCollision-World manager to hold and manage all collision shapes.Grid-based optimizations for efficient collision testing.Can easily handle massive worlds with lots of shapes.Collision filters and tags.Built-in debug rendering to show the collision world with all the objects in it (+ camera support).Lightweight minimalistic API. You can get it here: https://github.com/RonenNess/SSCD.jsAny feedback / ideas / Etc. will be appreciated thanks, Quote Link to comment Share on other sites More sharing options...
adngdb Posted July 27, 2015 Share Posted July 27, 2015 This looks a lot like https://github.com/jriecken/sat-js to me, but slightly simpler. It's cool that you made it, I've been struggling to find such a thing for a long time. Have you used it in a game yet? One "small" recommendation: you should add unit tests. They are worth the time, especially since you are building something purely mathematical and thus very easy to test. Quote Link to comment Share on other sites More sharing options...
NessEngine Posted July 28, 2015 Author Share Posted July 28, 2015 This looks a lot like https://github.com/jriecken/sat-js to me, but slightly simpler. It's cool that you made it, I've been struggling to find such a thing for a long time. Have you used it in a game yet? One "small" recommendation: you should add unit tests. They are worth the time, especially since you are building something purely mathematical and thus very easy to test. Hi adrigau, thank you for the feedback When I was working on my project I didn't know about sat-js (somehow I missed it in my search), if I did I could use it as a base and build my collision-world logic and simplified API as a wrapper over it. sat-js looks pretty good! I'm using this lib for a (hobby) game I'm working on, but it will take some time until it sees light. its basically a procedurally-generated endless top-down world, which I think is the best use-case for sscd: I totally agree about the tests, its a huge thing currently missing. I should also add some performance tests too. What I find most important to add in next version is convex polygons collision and transformations (scale & rotation), which I feel like critical features. so while at it I might throw in few tests. note: while I don't have convex polygons I do have line-strips, which can make up any shape. but unlike polygons, line strip will only detect collision when crossing the lines and not if tested completely inside the shape. so I feel like polygons are still missing. Quote Link to comment Share on other sites More sharing options...
mwatt Posted August 25, 2015 Share Posted August 25, 2015 Have you done any comparative performance analysis on your collision detection... say for a circle, vs. a simple square that one might code up? I do a not very complicated collision detection within my game in the Phaser update function, but I'd much rather use a circle. However, performance is extremely important in update.... Quote Link to comment Share on other sites More sharing options...
Guramidev Posted September 11, 2015 Share Posted September 11, 2015 You can do a very easy circle collision detection avoiding Math.sqrt which i observed to increase performance a lot, i hope you get the idea through code: AI.prototype.intersect = function(circle1,circle2) { return this.double(circle1.radius + circle2.radius) >= this.getDistance(circle1,circle2); }; AI.prototype.getDistance = function(circle1,circle2) { return this.double(circle2.x - circle1.x) + this.double(circle2.y - circle1.y); }; AI.prototype.double = function(arg) { return arg*arg; }; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.