Commit Graph

61 Commits

Author SHA1 Message Date
Alex Szpakowski 20b77bd28c Changed World:update(dt) to default to Box2D's recommended 3 internal position iterations instead of 6. Added a new variant World:update(dt, velocityiterations, positioniterations) which lets you specify the number of velocity and position iterations Box2D performs when updating the world. The defaults are 8 and 3 respectively, higher numbers increase precision and reduce performance.
Resolves issue #1135.

--HG--
branch : minor
2016-02-14 20:06:16 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski aca369e5d4 Fixed memory leaks in love.physics. When a World is garbage-collected it now implicitly calls World:destroy, which also destroys all Bodies, Fixtures, and Joints that belong to it. 2015-11-17 01:27:48 -04:00
Alex Szpakowski 2cce18946d Fixed objects which store Lua callback functions to avoid attempting to use dead coroutines when deleting the reference to the callback function. Should fix crashes when coroutines are mixed with those objects.
Also improved the performance of World:rayCast and World:queryBoundingBox.
2015-07-18 03:26:07 -03:00
Alex Szpakowski 64b9d40f00 Fixed World:getCallbacks and World:getContactFilter to use the active coroutine's lua state. 2015-07-17 19:00:42 -03:00
Alex Szpakowski 6e92bd8302 Improved the argument type checking for World:setCallbacks, World:setContactFilter, World:queryBoundingBox, and World:rayCast. 2015-04-27 18:48:13 -03:00
Alex Szpakowski 2f419c1c83 Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.
--HG--
branch : minor
2015-03-01 18:32:41 -04:00
Alex Szpakowski c7b45b3505 Updated copyright for the new year 2014-12-31 19:32:43 -04:00
Alex Szpakowski da7cd267ea Changed luax_pushtype to retain the pushed object itself, but only if the object isn't in the Lua state already.
Previously, calling e.g. love.graphics.getFont() 10,000 times would retain the object 10,000 times (and release it 10,000 times when the Font object was garbage-collected in the Lua state.) Now it will only retain it once and release it once.
2014-08-09 16:04:59 -03:00
Alex Szpakowski d59c76a55f Reduced the number of explicit retain/release method calls on love objects. Less chance of bugs! 2014-08-07 14:53:17 -03:00
Alex Szpakowski 9ab9a393d5 Added Contact:getFixtures and Body:getContactList (see issue #905).
The list of Contacts associated with bodies changes during World:update (potentially multiple times), so you might miss collisions if you don't use the World callbacks at all.
2014-07-07 15:24:24 -03:00
Alex Szpakowski 2ae4e9cd5a Fixed a potential memory leak in the love.physics World callbacks. 2014-06-18 16:24:38 -03:00
Alex Szpakowski 3120a0e650 Goodbye 2013, hello 2014! 2014-01-03 17:28:58 -04:00
Alex Szpakowski 5e3a0fbc6e Updated box2d from 2.2.1 to 2.3.0
--HG--
branch : box2d-2.3
2013-11-09 04:30:36 -04:00
Alex Szpakowski 95eedcd1be Using auto for some iterators for less dense-looking code 2013-09-30 02:35:10 -03:00
Alex Szpakowski 93a782d445 Renamed World:setAllowSleeping and World:getAllowSleeping to World:setSleepingAllowed and World:isSleepingAllowed (see issue #691, also consistent with the Body methods) 2013-08-31 21:15:09 -03:00
Alex Szpakowski ec9dec6b80 Replaced luax_newtype with luax_pushtype (and added luax_rawnewtype for the old functionality of luax_newtype.)
luax_pushtype keeps the object in a weak table and checks the table before creating a new userdata, so it re-uses the object's existing wrapper userdata if it can, whenever the object is pushed to Lua.

This fixes some subtle issues with love objects, where using them as keys in tables would not always work as expected (https://love2d.org/forums/viewtopic.php?f=4&t=39398&p=112388#p112415). It also decreases the amount of new Lua objects created, saving the garbage collector some work.
2013-08-29 00:40:06 -03:00
Alex Szpakowski 96161c66f6 Updated copyright text for the new year 2013-02-05 05:32:49 -04:00
Boolsheet cde5aa3307 Import box2d-contacts branch from love-experiments
Fix issues with Contact lifetime, based on the work of
Matteo "teomat" Goggi
2012-07-24 23:59:42 +02:00
Bart van Strien 7793e7f02f CRLF to LF 2012-07-04 14:40:24 +02:00
rude 81c38e22d0 Applied the new style guidelines.
Well, sort of. Lot's more to be done, but this is a start.
2012-06-28 23:52:33 +02:00
Aidan Gauland 27b62b5c9c Removed scaling of unit vectors. 2012-04-17 20:54:12 +12:00
Bart van Strien 66aef58075 Use a clearer error message when the raycast callback doesn't return a number (issue #356) 2012-03-03 12:11:06 +01:00
Bart van Strien 0c9d8f3c41 Handle masks and categories in our contact filter
Turns out, setting our own contact filter bypasses the inbuilt mask and category handling,
this means, however, that masks and categories are processed before your contact filter is
called, so if you really want to do all the filtering manually, you should just make sure
you never change the default masks and category, or restore it.
2012-02-09 20:26:18 +01:00
Bill Meltsner 4aa3939311 Actually register Box2D worlds as contact filters 2012-02-04 19:07:24 -05:00
Bart van Strien a67b5b501f Fix a leak on destruction of a physics world 2012-01-24 23:00:18 +01:00
Bart van Strien 9dc4138366 Fix a comment 2012-01-12 11:26:22 +01:00
Bill Meltsner be55579a22 Happy New Year, have an enormous diff 2012-01-09 02:41:11 -06:00
Bart van Strien c1f68e058d Use Box2D's callbacks for destruction of physics objects and wait until the end of the timestep before destroying them.
Merge of box2d-id2 from love-experiments
2012-01-08 13:16:50 +01:00
Bart van Strien 0aae9684b3 Automated formatting fix 2011-11-16 11:32:41 +01:00
Bart van Strien cf2bfcc4a2 Fix more memory leaks (issue #327) 2011-11-12 15:00:26 +01:00
Bill Meltsner 56ae3a95fc Bring back some elements of better Body destruction that got lost in the merge 2011-10-12 13:51:47 -05:00
Bill Meltsner 16fb73e92a Callbacks now actually fire when they're supposed to, instead of post-step (means PreSolve collision filtering works)
--HG--
branch : box2d-update
2011-09-26 20:22:03 -04:00
Bill Meltsner 413f5026fa Fix invalid pointer issue in PostSolve callback
--HG--
branch : box2d-update
2011-09-26 19:13:44 -03:00
Bill Meltsner 5886977baa Fix World:getCallbacks/getContactFilter to not return any arguments passed (though you shouldn't be passing any arguments anyway, that's silly)
--HG--
branch : box2d-update
2011-09-26 11:20:26 -04:00
Bill Meltsner de908f3354 Missing retain() calls in get*List functions
--HG--
branch : box2d-update
2011-09-25 12:35:57 -04:00
Bill Meltsner 28c5982d92 Fix table creation for getList() functions, and ignore the ground body
--HG--
branch : box2d-update
2011-09-25 12:18:13 -04:00
Bill Meltsner 624e1bf8f5 Missed a bunch of retain() calls
--HG--
branch : box2d-update
2011-09-24 23:52:56 -04:00
Bill Meltsner dd3993623b Add World:isLocked and const-ify a few worthy methods
--HG--
branch : box2d-update
2011-09-24 16:59:45 -04:00
Bill Meltsner 6a0c5b485b Memoize Contacts, and add List-fetching functions to World (they return arrays)
--HG--
branch : box2d-update
2011-09-24 16:46:07 -04:00
Bill Meltsner f852c9bac2 Add World:rayCast
--HG--
branch : box2d-update
2011-09-24 16:26:41 -04:00
Bill Meltsner e2b832015b Add World:queryBoundingBox
--HG--
branch : box2d-update
2011-09-24 16:15:09 -04:00
Bill Meltsner 055238659b Change Contact callbacks to pass the actual Fixtures instead of just the userdata
--HG--
branch : box2d-update
2011-09-24 13:51:11 -04:00
Bill Meltsner 7e039dd1ef Add ContactFilter callback to World
--HG--
branch : box2d-update
2011-09-24 13:45:24 -04:00
Bill Meltsner c705063597 First attempt at implementing Memoization for certain Box2D objects
--HG--
branch : box2d-update
2011-09-24 12:20:59 -04:00
Bill Meltsner 542ae2f736 Actually create groundBody when creating a World with gravity (i.e. all the time)
--HG--
branch : box2d-update
2011-09-24 01:16:34 -04:00
Bill Meltsner 367dbc2ecc Update Body API.
--HG--
branch : box2d-update
2011-09-23 22:21:14 -04:00
Bill Meltsner 0678eac453 A first attempt at overhauling collision. New everything.
--HG--
branch : box2d-update
2011-09-23 21:25:41 -04:00
Bill Meltsner 95f6047417 Update World contact callback definitions, get ready for collision overhaul
--HG--
branch : box2d-update
2011-09-23 17:01:53 -04:00
Bill Meltsner 4980797afc World no longer has an explicit size
--HG--
branch : box2d-update
2011-09-23 16:27:59 -04:00