Box2D Note

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
cag
Citizen
Posts: 65
Joined: Sun Jun 29, 2008 5:09 am

Re: Box2D Note

Post by cag »

I second muku's proposition. LOVE is already kinda meant to work on modern processors, so programmer vs. computation time-wise, it's probably better to specify a single pixel-to-meter scale and take the negligible computation hit than to have the programmer work out values in meters themselves.
u9_
Citizen
Posts: 54
Joined: Thu Oct 23, 2008 7:12 am

Re: Box2D Note

Post by u9_ »

rude wrote:Of course that's possible, but it would involve one multiplication for each ingoing and outgoing numeric value[...]
But aren't you fixing the engine to a predetermined resolution? I am worried that this is crippling LOVE a little, and think that if possible, pixels and your world model should be independent. This is good programming practice, albeit maybe a little advanced for newbies. But then again, when you turn to a physics engine, you are already pretty advanced IMHO.

Another thing is that I would like to see LOVE on other devices in the future, such as the upcoming Pandora. These devices have a very different resolution.

Maybe a function could be provided that defined the size of a pixel in meters?

/u9

P.s. I have yet to make my first "love" yet, so I may be way off.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Box2D Note

Post by rude »

Pixels should be used by default though, if LOVE wants to keep its "easy to use" status. Otherwise, there's nothing wrong with separating the world model and viewport. It simply involves exposing a function like love.graphics.setViewport or something, which should take around 5 minutes.

Added to task list, and thanks for the tip. ^_^
User avatar
Xfcn
Citizen
Posts: 65
Joined: Sat Jul 12, 2008 6:53 am

Re: Box2D Note

Post by Xfcn »

So is this why my jumping dude was so damn difficult to fine-tune?

*EDIT* No, no it isn't. I wasn't using the physics engine in any regard (that I was aware of).
"Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
User avatar
MHD
Prole
Posts: 18
Joined: Fri Nov 14, 2008 11:45 pm
Location: Denmark

Re: Box2D Note

Post by MHD »

I wish the source-physics engine used MKS... :? Instead it uses InchPoundSecond...
I r awsum at looah ^^
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: Box2D Note

Post by osuf oboys »

There seems to be limitation in the lower size of shapes as well. The following crashes on fedora core 9 and supposedly also on OSX. On windows, it does not crash but issues are visible with small shapes, like objects that get stuck in each other. In my experiences, the smallest unit of visible shapes that you want is 300ths to 600ths of the screen width or height. Considering that shapes smaller than 0.08 cannot be used, this dictates that the screen should be at least 24 to 48 metres wide. Scaling everything down 80 times is therefore not an option - a 800x600 resolution would have a width of 10 metres, thereby making the smallest shape only a 100th of the screen. Scaling by 1/20 would be more desirable.

Code: Select all

world = love.physics.newWorld(5,5)
body = love.physics.newBody(world, 0, 0)
shape = love.physics.newRectangleShape(body, 0.08, 1.0) -- works
shape = love.physics.newRectangleShape(body, 0.07, 1.0) -- crashes
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Box2D Note

Post by rude »

Thanks for noting that, osuf. But why do you need shapes that are (much) less than a pixel wide?
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: Box2D Note

Post by osuf oboys »

rude wrote:Thanks for noting that, osuf. But why do you need shapes that are (much) less than a pixel wide?
In camera, http://love2d.org/forum/viewtopic.php?f=5&t=419, I create bodies that are of normal size, such as 2 meter humans instead of 40 pixels = 40 metres, to avoid the problem of making too large shapes. I have overloaded the love.graphics functions to scale these shapes out appropriately on the screen. An object 0.08 = 8cm wide might be drawn on the screen as 5 pixels following this scheme.
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Box2D Note

Post by rude »

Oh, in Camera. I see.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 12 guests