Page 1 of 2

Max velocity = 200, why?

Posted: Sat Sep 05, 2009 9:48 pm
by Almost
Huh. I'm trying to use love's physics, but I just discovered that any velocity numbers > than 200 are chopped down to 200. I don't know why, I just know that they are. And that it's annoying. Moving faster than 200 is a must.

Here's a love file that demonstrates this cropping velocity down to 200. If I'm missing something, please tell me now.

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 1:03 am
by Almost
Huh, also: love crashes if a world has 2000 or more physics objects. (actually, I think it's 2048)

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 2:03 am
by osgeld
whats the objects mass?

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 3:38 am
by Almost
Re: Osgeld
the mass is 1, but that shouldn't matter to setVelocity()

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 4:13 am
by Boder
It looks like the 200 m/s limit is a feature of the underlying "Box2D" so you have to scale your simulation to within the limits.

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 4:44 am
by osgeld

Code: Select all

function update(dt)
    world:update(X * dt)
end

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 5:03 am
by Almost
doh, that is a clever fix. I still have issues with 2000+ physics objects though.. I guess I'll just have to have fewer objects..

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 5:09 am
by osgeld
you can have smaller physical worlds, depending on your need for accuracy and scale to shown perspectives, its all a matter of scale

PS: just cause I was bored ....

Code: Select all

function load()
	love.graphics.setFont(love.default_font,12)

	world = love.physics.newWorld(1000,1000)
	body  = {}

	for i = 1, 6 do
		table.insert(body, love.physics.newBody(world,100,(i *100)))
	end
		
	for i = 1, #body do
		body[i]:setVelocity((5 * i),0)
	end
end

function update(dt)
	world:update(50 *dt)
end

function keypressed(key)
	if key == love.key_r then 
		world = nil
		body  = nil
		collectgarbage("collect")
		load()		
	end
end

function draw()
	for i = 1, #body do
		local x, y = body[i]:getPosition()
		love.graphics.circle(love.draw_fill,x,y,10)
		love.graphics.draw('Expected Speed: ' .. (i * 5) ,10,y-15)
		love.graphics.draw('Actual Speed: ' .. body[i]:getVelocity() ,10,y)
	end
	
	love.graphics.draw('R to restart',10,10)
end

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 11:40 am
by rude
From b2Settings.h:

Code: Select all

/// The maximum linear velocity of a body. This limit is very large and is used
/// to prevent numerical problems. You shouldn't need to adjust this.
const float32 b2_maxLinearVelocity = 200.0f;
This limit is very large if you use Box2D as it's intended. In LÖVE 0.5.0, one meter is 1px (not good). In LÖVE 0.6.0 you can set how many pixels one meter should be.

Also b2Settings.h:

Code: Select all

const int32 b2_maxProxies = 2048;
That's the limit of how many shapes you can have.

Re: Max velocity = 200, why?

Posted: Sun Sep 06, 2009 11:45 am
by Robin
rude wrote:In LÖVE 0.5.0, one meter is 1px (not good)
You can change that with CAMERAs. That's how we did it in LovelyBigPlanet.