Page 1 of 9

Fizz X

Posted: Sat Feb 04, 2012 6:31 am
by ivan
Hi everybody, this is my small contribution to the Love2D community: a modified version of the collision detection lib Fizz.

Lib: FizzX
Licence: MIT License
Description:
Fizz is a lightweight collision library in Lua.
Fizz is designed specifically for old-school platformers and overhead action games.

Fizz supports three different shape types: circles, rectangles and line segments.
Note that rectangles are represented by a center point and half-width and half-height extents.
Rectangles are always axis-aligned and cannot have rotation.
Line segments are useful for making slopes and possibly "one-sided" platforms.
The direction of line segments affects how they handle collisions.
Line segments "push" other intersecting shapes at 90 degrees counter-clockwise of the segment slope.

In addition, there are three classes of shapes: static, kinematic and dynamic.
Static shapes are immobile and do not respond to collisions or gravity.
Static shapes can be used to represent walls and platforms in your game.
Kinematic shapes do not respond to collisions or gravity, but can be moved by manually changing their velocity.
Kinematic shapes can be used to simulate moving platforms and doors.
Dynamic shapes respond to collisions and gravity.
Dynamic shapes can be used to simulate the moving objects in your game.

Fizz uses quadtree partitioning to reduce the number of collision tests.
Partitioning can be disabled although this is not recommended especially if your simulation contains a large number of dynamic shapes.

Authors: Ivan & Taehl (original developer)
Repository and docs: https://github.com/2dengine/fizzx
Official support forum: http://2dengine.com/forum/

Version 10:
-improved collisions with slopes/line segments
-disabled partitioning
-mass and density support (wip)

Version 9:
-modified api
-refactored and optimized
-fizz.getDisplacement(shape)
-fixes some bugs with circle-rect and circle-circle
-fixes the damping

Version 8:
-new and improved implementation of line shapes
-various fixes
-updated to work with the latest version of Love2D

Possible Todo:
-looks like there are some bugs with the resolution for line shapes
-bounce and friction need testing
-mass
-sensor/ghost shapes

Re: Fizz X

Posted: Sat Feb 04, 2012 7:26 am
by MarekkPie
Coincidentally, I just described how to do circle-to-rectangle collision in another thread: viewtopic.php?f=4&t=7842#p48681

Nice work.

Re: Fizz X

Posted: Sun Feb 05, 2012 3:30 am
by Taehl
Based on that demo, the platform-movement mechanics are all... Bizarre would be a nice term for it. The air control is not what platformer players would expect. And you can fly instead of jumping.

As far as the physics itself, it seems you can no longer stand on moving platforms (and indeed, you disabled the platform I had moving in my demo?). Also, I'm seeing a lot of penetration:

Image

Now, please understand, I'm not trying to discourage you. I'm actually quite pleasantly surprised that you're trying to improve Fizz (lord knows I can't make it any better, myself). I'm just offering constructive criticism. By all means, feel free to keep working on it.

One last note: You may want to consider a name change before anyone gets the impression that Love2D now supports PhysX.

Re: Fizz X

Posted: Sun Feb 05, 2012 3:38 am
by MarekkPie
OMG LOVE SUPPORT PHYSX! I need to update my blog!

Re: Fizz X

Posted: Sun Feb 05, 2012 6:08 am
by ivan
Hi Taehl, where you the person who originally wrote Fizz?
Taehl wrote:Based on that demo, the platform-movement mechanics are all... Bizarre would be a nice term for it. The air control is not what platformer players would expect. And you can fly instead of jumping.
Yes, the WASD keys simply set a new velocity for the player.
Taehl wrote:As far as the physics itself, it seems you can no longer stand on moving platforms (and indeed, you disabled the platform I had moving in my demo?).
I removed the 'movex, movey' properties which some objects had.
It seems that objects (including the player) should be moved using forces or impulses so that they can also respond to collisions.
Taehl wrote:Also, I'm seeing a lot of penetration:
Stacking bugs might be fixed in the future by using continous collisions and perhaps an iterative solver.
It should be noted that the original Fizz code didn't 'properly' resolve stacking of shapes either.
Taehl wrote:Now, please understand, I'm not trying to discourage you. I'm actually quite pleasantly surprised that you're trying to improve Fizz (lord knows I can't make it any better, myself). I'm just offering constructive criticism. By all means, feel free to keep working on it.
Hey no worries, I'm glad you don't mind me editing the code.

Re: Fizz X

Posted: Sun Feb 05, 2012 11:21 pm
by Taehl
ivan wrote:Hi Taehl, where you the person who originally wrote Fizz?
Indeed.
ivan wrote:I removed the 'movex, movey' properties which some objects had.
It seems that objects (including the player) should be moved using forces or impulses so that they can also respond to collisions.
So how do you plan on making things like smooth-moving elevators which can handle variable weight, unsteady dt, etc.? I may be biased, but I thought movex/movey did a pretty good job. And this is a feature that's pretty much required.
ivan wrote:Stacking bugs might be fixed in the future by using continous collisions and perhaps an iterative solver.
It should be noted that the original Fizz code didn't 'properly' resolve stacking of shapes either.
I know. But my naive solution never actually had anything inside anything else - it would be pushed through, worst case scenario... I don't know, I guess even if it wasn't perfect, collisions at least felt consistent in the original Fizz. In X, I can't figure out what makes some objects penetrate partially, some shoot all the way through, and other times work fine.

Re: Fizz X

Posted: Sun Feb 05, 2012 11:21 pm
by Taehl
EDIT) My message somehow got duplicated? Weird. I'd appreciate it if a mod with a free moment would delete this post, please.

Re: Fizz X

Posted: Mon Feb 06, 2012 4:36 pm
by tsturzl
Taehl wrote:BOne last note: You may want to consider a name change before anyone gets the impression that Love2D now supports PhysX.
I really don't think this will be an issue, Phsyx for 2D is rather pointless, especially if the platform doesn't support CUDA hardware acceleration. Physx on the CPU is supposedly slower than box2D, and box2D better suits 2D application. With Physx you'd have to add joint constraits to keep it on a 2D axis.

IMO, physx would be completely pointless to add to love, especially when box2D has already been implemented. Box2D's CPU load isn't bad, and hardware acceleration is almost completely usless, you'd never need that much physics in a 2D game where a GPU would be needed in order to process all the entities.

I doubt there will be much confusion, and if there is you should consider the above points. Physx is a technology geared for 3D application, love is focused on 2D. Keep it that way.

Re: Fizz X

Posted: Mon Feb 06, 2012 5:00 pm
by MarekkPie
I think the point of a name change is for someone who doesn't already know everything there ever is to know about PhysX. Perhaps they just recognize the name, see "Fizz X," and wonder why they can't do (insert feature here) from (insert game that uses PhysX).

Never under-estimate the stupidity of the Internet.

Re: Fizz X

Posted: Tue Feb 07, 2012 10:29 pm
by ivan
Hi again.
Taehl wrote:So how do you plan on making things like smooth-moving elevators which can handle variable weight, unsteady dt, etc.? I may be biased, but I thought movex/movey did a pretty good job. And this is a feature that's pretty much required.
Perhaps there could be a 'kinematic' class of shapes that don't react to collisions (like in the latest versions of Box2D) but you can move them by setting their velocity.
Taehl wrote:I know. But my naive solution never actually had anything inside anything else - it would be pushed through, worst case scenario... I don't know, I guess even if it wasn't perfect, collisions at least felt consistent in the original Fizz. In X, I can't figure out what makes some objects penetrate partially, some shoot all the way through, and other times work fine.
Yeah, I don't know if there is a simple solution to the stacking problem.
Fortunately, most platformer/top-down 2D games don't need to simulate stacking of objects.
By the way, check out the latest revision of Fizz X (new name suggestions are welcome) I've added bounce/damping/friction and some basic collision response.