GeometryBuffer minor improvements (#703)

This commit is contained in:
Gustl22
2019-03-19 15:06:54 +01:00
committed by Emux
parent fb8e6dab20
commit 1051aacc7c

View File

@@ -107,7 +107,7 @@ public class GeometryBuffer {
/** /**
* Instantiates a new geometry buffer. * Instantiates a new geometry buffer.
* *
* @param numPoints the num of expected points * @param numPoints the num of expected 2D points
* @param numIndices the num of expected indices * @param numIndices the num of expected indices
*/ */
public GeometryBuffer(int numPoints, int numIndices) { public GeometryBuffer(int numPoints, int numIndices) {
@@ -152,6 +152,7 @@ public class GeometryBuffer {
/** /**
* @param out PointF to set coordinates to. * @param out PointF to set coordinates to.
* @param i the 2D point position.
* @return when out is null a temporary PointF is * @return when out is null a temporary PointF is
* returned which belongs to GeometryBuffer. * returned which belongs to GeometryBuffer.
*/ */
@@ -160,16 +161,25 @@ public class GeometryBuffer {
out.y = points[(i << 1) + 1]; out.y = points[(i << 1) + 1];
} }
/**
* @param i the 2D point position.
* @return the x-coordinate of point.
*/
public float getPointX(int i) { public float getPointX(int i) {
return points[(i << 1)]; return points[(i << 1)];
} }
/**
* @param i the 2D point position.
* @return the y-coordinate of point.
*/
public float getPointY(int i) { public float getPointY(int i) {
return points[(i << 1) + 1]; return points[(i << 1) + 1];
} }
/** /**
* @return PointF belongs to GeometryBuffer. * @param i the 2D point position.
* @return the PointF that belongs to GeometryBuffer.
*/ */
public PointF getPoint(int i) { public PointF getPoint(int i) {
PointF out = mTmpPoint; PointF out = mTmpPoint;
@@ -178,10 +188,25 @@ public class GeometryBuffer {
return out; return out;
} }
/**
* Get the number of 2D points.
*
* @return the number of 2D points.
*/
public int getNumPoints() { public int getNumPoints() {
return pointNextPos >> 1; return pointNextPos >> 1;
} }
/**
* Get the used size of points array.
* Equal to the next position to insert point in points array.
*
* @return the size of point array.
*/
public int getPointsSize() {
return pointNextPos;
}
/** /**
* Reset buffer. * Reset buffer.
*/ */
@@ -229,9 +254,9 @@ public class GeometryBuffer {
/** /**
* Sets the point x,y at position pos. * Sets the point x,y at position pos.
* *
* @param pos the pos * @param pos the 2D point position
* @param x the x ordinate * @param x the x coordinate (abscissa)
* @param y the y ordinate * @param y the y coordinate (ordinate)
*/ */
public void setPoint(int pos, float x, float y) { public void setPoint(int pos, float x, float y) {
points[(pos << 1) + 0] = x; points[(pos << 1) + 0] = x;