PolygonShape size issues?

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
LilaQ
Prole
Posts: 7
Joined: Mon Apr 30, 2012 9:45 pm

PolygonShape size issues?

Post by LilaQ »

Hey guys,

currently I'm experiencing some troubles with newPolygonShape()

e.g.

Code: Select all

test = love.physics.newPolygonShape(0,0,0,3,3,3,3,0)
Does not work, gives "Box2D assertion failed: false" error

Code: Select all

test = love.physics.newPolygonShape(0,0,0,4,4,4,4,0)
Does work.

It seems height/width of a PolygonShape have to be > 3 to work. But if I try to make a smaller Shape like this:

Code: Select all

test = love.physics.newRectangleShape(0.000001, 0.0001)
there is no problem at all.

Anyone has an explanation to this? Or even better, a solution? For my project I need to be able to make small PolygonShapes...

Thanks in advance!

LilaQ
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: PolygonShape size issues?

Post by slime »

Try making the meter size smaller (with [wiki]love.physics.setMeter[/wiki].)

EDIT: For those wondering why this happens, box2d's newPolygonShape function will merge vertices which are very close to each other (in terms of box2d's meters). If you decrease the meter size, it means the vertices you specify are further apart to box2d.
Last edited by slime on Fri Mar 07, 2014 11:01 pm, edited 1 time in total.
LilaQ
Prole
Posts: 7
Joined: Mon Apr 30, 2012 9:45 pm

Re: PolygonShape size issues?

Post by LilaQ »

Nice, that did the trick.

Thanks slime!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests