Strange physics error when creating rectangle with 0 height

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Strange physics error when creating rectangle with 0 height

Post by BlackBulletIV »

I'm getting a strange physics error when I create a rectangle with a height of 0. This is the code:

Code: Select all

function Entity:setRectangleShape(x, y, angle)
    self.shape = love.physics.newRectangleShape(self.body, x or 0, y or 0, self.width, self.height, angle or 0)
end
I call the function with no parameters passed in, and the entity's width set to a certain value greater than 0 and the height to 0. This causes love.app to display a window with nothing but gray, freeze for a bit and then quit. This message is displayed in the terminal:

Code: Select all

2011-01-09 15:37:02.110 love[3047:903] Can't open input server /Library/InputManagers/Inquisitor
Assertion failed: (edge.LengthSquared() > 1.19209290e-7F * 1.19209290e-7F), function b2PolygonShape, file /Users/bill/love/platform/macosx/../../src/modules/physics/box2d/Source/Collision/Shapes/b2PolygonShape.cpp, line 161.
Abort trap
Please note, the "Can't open input server" appears all the time, so it's nothing to worry about I assume. Anyway, it me a while to work out I was making a rectangle with a height of 0, and when I changed the height the problem was fixed.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Strange physics error when creating rectangle with 0 hei

Post by Robin »

There's nothing strange about that. You're trying to create a rectangle with a height of 0. That's not a rectangle, it's a True Line™. Box2D doesn't do that, since it doesn't make sense to simulate lines.

You can use a very thin rectangle — 3 pixels was the minimum, IIRC. Unless you use setMeter, but then the rest of the world should be adjusted too.
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Strange physics error when creating rectangle with 0 hei

Post by BlackBulletIV »

I understand that. What I was posting about is the weird Love handled the error. Love doesn't normally freeze, show a grey screen and then spit out an error message to the console telling me that some assertion failed in a Box2D file ( which by the way has another username, my username is michael).
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Strange physics error when creating rectangle with 0 hei

Post by Robin »

BlackBulletIV wrote:I understand that. What I was posting about is the weird Love handled the error. Love doesn't normally freeze, show a grey screen and then spit out an error message to the console telling me that some assertion failed in a Box2D file
That's just how Box2D asserts work, unfortunately. There has been some fixing, I don't know how far they are.
BlackBulletIV wrote:( which by the way has another username, my username is michael).
bill == anjo, the mac guy.
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Strange physics error when creating rectangle with 0 hei

Post by BlackBulletIV »

Robin wrote:That's just how Box2D asserts work, unfortunately. There has been some fixing, I don't know how far they are.
Well I guess Box2D was programming with C++ in mind. That would be fine when running C++ programs from the console; but unfortunately it means the error doesn't get to Lua.
Robin wrote:bill == anjo, the mac guy.
Ah ok. :)
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Strange physics error when creating rectangle with 0 hei

Post by bmelts »

That's, uh, really weird that it popped my name up. I'm guessing I did something dumb like not strip the binary properly or... something. Beats me :crazy:
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Strange physics error when creating rectangle with 0 hei

Post by BlackBulletIV »

:) That's what I thought.

EDIT: Yay! Citizen rank.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 5 guests