Polygon is not convex
by Christian Rousselle · in Torque Game Builder · 05/15/2007 (1:05 pm) · 5 replies
Although I only use the GUI Editor to draw collision polys I sometimes get this error message. I am not sure if this has to do with precision errors of if it is something new in Beta3.
#2
05/16/2007 (12:29 am)
The issue is not that I do not understand what a convex polygon is or why Torque works with convex polygons. The problem is that it seems to be possible to use the editor to create a non convex polygon. By design it should not be possible to draw a non convex polygon and it never looks like one in the editor but (maybe because of precision problems) it seems to be possible to create one.
#3
So a more intuitive (maybe?) way to think about it is that if the polygon you describe and its "rubber band shape" are the same, then it should work.
The reason Torque (and most such things) use convex polygons is that if you know your polygon is convex it is significantly easier to determine whether or not a given point is inside of it, which is important for collision detection. If you need a more complicated shape you might consider a dummy object with its own collision boundaries and the same reaction as the real object... (dunno how well this would work in practice)
05/20/2007 (9:09 pm)
A convex polygon doesn't have any "bites" taken out of it- one way to think of it is is with a rubber band. If you wrap a rubber band around a C, the actual band will form a O shape (more or less) because C isn't convex (it has that interior bit). If you wrap a rubber band around an octagon, say, the rubber band will exactly conform to the shape of the octagon. But if we were to take one of the octagon's corners and drag it inward towards the center, we'd have a mismatch between the polygon and the rubber band- the rubber band still wants to be the same octagon as before, but our polygon is different.So a more intuitive (maybe?) way to think about it is that if the polygon you describe and its "rubber band shape" are the same, then it should work.
The reason Torque (and most such things) use convex polygons is that if you know your polygon is convex it is significantly easier to determine whether or not a given point is inside of it, which is important for collision detection. If you need a more complicated shape you might consider a dummy object with its own collision boundaries and the same reaction as the real object... (dunno how well this would work in practice)
#4
05/20/2007 (9:57 pm)
@Samuel: I think you must have misunderstood Christian here... he said that he knows why convex polygons are used. But normally TGB doesn't let you set up a non convex polygon... it always snapped back to 180
#5
05/21/2007 (5:47 am)
Oops! Missed that "not"... damn sign errors.
Torque Owner Luke Larson