gdx2d icon indicating copy to clipboard operation
gdx2d copied to clipboard

Polygonclass stinks

Open pmudry opened this issue 9 years ago • 3 comments

The class from Nils is a total mess and not complete. For instance, the contains method does not work etc... This class should be replace by the libgdx supporting classes such as Rectangle and Polygon from com.badlogic.gdx.math.Rectangle and com.badlogic.gdx.math.Polygon

pmudry avatar Jun 08 '15 17:06 pmudry

In addition, some infos from a student:

Bonjour, la classe Polygon du package hevs.gdx2d.components.graphics n'est pas finie et le méthode de translation n'existe pas(voir entête). Je veux bien créer une nouvelle classe qui hérite de celle-ci et rajouté les méthodes manquantes, mais je ne sais pas comment procédé avec l'attribut vectorList, qui n'est pas initialisé, mais qui est appelé dans la fonction public boolean contains(Vector2 p) .

pmudry avatar Aug 10 '15 12:08 pmudry

This is dead code: https://github.com/hevs-isi/gdx2d/blob/master/gdx2d-library/gdx2d-core/src/main/java/ch/hevs/gdx2d/components/graphics/Polygon.java#L74

Maybe I missed something but the vectorList is always null.

metc avatar May 13 '16 14:05 metc

Temporary fix :

class PolygonWorking extends Polygon{
    public PolygonWorking(Vector2[] points) {
        super(points);
    }
    
    @Override
    public boolean contains(Vector2 p) {
        Vector2[] v = Polygon.float2vec2(this.getVertices());
        Array<Vector2> a = Array.with(v);
        return Intersector.isPointInPolygon(a, p);      
    }
}

pmudry avatar May 19 '21 07:05 pmudry