Problem loading Concave Polygon into HardonCollider

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
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Problem loading Concave Polygon into HardonCollider

Post by kexisse »

I'm trying to use concave shapes with HardonCollider, but I'm having problems.

When drawing the shapes to the screen, they look fine, concave.

But I get the following error from HardonCollider

Code: Select all

Error: hardoncollider/polygon.lua:295: Cannot triangulate polygon (is the polygon intersecting itself?)
The polygon isn't intersecting itself, as far as I can see.

What am I doing wrong?

My polygon point data is:

Code: Select all

points = {
    -186.24919315577,-124.44773219639,
    -192.16694276235,-79.598153931939,
    -188.31077383742,-37.457341827097,
    -165.52664392134,28.721597311731,
    -150.64705042928,53.902376542755,
    -132.25322264852,74.920525218927,
    -111.31350528423,91.352632919565,
    -211.66110344361,113.13521683824,
    -246.87732695419,81.557252503712,
    -276.96942279014,41.084532847501,
    -299.90964560886,-7.3623685568735,
    -313.85128972903,-62.428903045161,
}
I've attached a simple .love program that shows the poly shape, and tries to create the HardonCollider shape when you hit Space.
Attachments
concave_test.love
Showing the concave poly. Hit space to try to load into HardonCollider.
(22.05 KiB) Downloaded 69 times
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Problem loading Concave Polygon into HardonCollider

Post by vrld »

Welcome to the world of numerical instabilities! Your polygon is indeed concave, but especially on the segment 4->5->6 barely so:
concave.png
concave.png (10.51 KiB) Viewed 1415 times
I've replaced the relevant code with a (hopefully) more stable bit. However, you might want to consider replacing concave edges with an angle close to 180 degree with a straight line to avoid such problems in the future.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Re: Problem loading Concave Polygon into HardonCollider

Post by kexisse »

Amazing! Thanks! I'll try it with the new version :D

Edit: It works! I get an error when I make a poly that intersects itself. I'm trying to catch it manually by using pcall, but I have to wrap all calls up the tree with pcall so it's not ideal... Is there a better way?
Post Reply

Who is online

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