bendmorris / spinehaxe

Spine runtime for Haxe 3. Based on current AS3/libgdx runtimes.
Other
64 stars 28 forks source link

SkeletonBounds.hx : helper suggestion #22

Closed jhice closed 7 years ago

jhice commented 9 years ago

Hi again,

It is more a suggestion than an issue. In the helpers of SkeletonBounds.hx, the method intersectsSegment() return the first bounding box that contains the line segment. I added a method to return an array of all the bounding boxes that contains the line :

    /** Returns all bounding box attachments that contains the line segment, or null. When doing many checks, it is usually
     * more efficient to only call this method if {@link #aabbIntersectsSegment(float, float, float, float)} returns true. */
    public function intersectsSegmentMultiple(x1:Float, y1:Float, x2:Float, y2:Float):Array<BoundingBoxAttachment> {
        var i:Int = 0;
        var n:Int = polygons.length;
        var bBoxes:Array<BoundingBoxAttachment> = [];
        while(i < n) {
            if (polygons[i].intersectsSegment(x1, y1, x2, y2))
                bBoxes.push(boundingBoxes[i]);
            i++;
        }
        if (bBoxes.length > 0)
            return bBoxes;
        return null;
    }

Do you think it's useful to put this in spinehaxe or is it better keeping that on my side ?

bendmorris commented 7 years ago

I'm staying as close as possible to the official runtimes - you can either keep that helper on your end, or try submitting it as a PR to the official runtimes repo.