Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Open issues

Ángel Serrano edited this page Mar 7, 2014 · 1 revision

Use-cases for advanced geometrical utilities (boolean operations, triangulation, ...)

This is related to pull request #18 (currently blocked until #21 confirms that it works in GWT). The goal is to establish what kind of geometrical utilities we will need, and provide a simple target API.

I propose the following target:

creation and modification of complex 2D shapes during editing
use of complex 2D shapes to filter textures, allowing their use as sprite-masks
collision detection between such shapes in the engine & editor, allowing their use as control-areas

At a low level, boolean shape operations are easy to understand and implement, and provide almost the same degree of fine control as much more complex selection mechanisms. The use of merge() and substract(), plus associated methods to tranfer from the geometry world to libgdx and vice-versa (gdxToJts() and jtsToGdx()), cover creation and modification.

To filter textures, the polygons must be triangulated. Triangulation of non-convex shapes in JTS requires each generated triangle to be queried to check if it is empty space or actual figure. This can be done efficiently for JTS MultiPolygons, which must not overlap. Since MultiPolygons are difficult to manage (boolean operations on them need not return a valid MultiPolygon), both merge() and substract() work on their components: the individual non-overlapping JTS Polygons. Hence the use of ArrayList as an intermediate representation.

Finally, once a list of polygons is collapsed into a MultiPolygon, any point (or similar shape) can be trivially [tested for intersection](http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html#intersects(com.vividsolutions.jts.geom.Geometry\). This allows complex, irregular shapes to be used for control areas.

Please add comments to refine or amend the proposed use-cases / API

Clone this wiki locally