Skip to content

Commit

Permalink
Small additions to ICoordinates (allowing to set an offset for adding
Browse files Browse the repository at this point in the history
values). Modification of the default precision (O.01) for text displays.
  • Loading branch information
AlexisDrogoul committed Jun 20, 2021
1 parent 55222e8 commit 5cc2139
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ public ICoordinates setTo(final GamaPoint... points2) {
}

@Override
public ICoordinates setTo(final double... points2) {
public ICoordinates setTo(final int index, final double... points2) {
final int size = Math.min(points2.length, points.length * 3);
for (int i = 0; i < size; i += 3) {
for (int i = index; i < size; i += 3) {
final GamaPoint self = points[i / 3];
self.x = points2[i];
self.y = points2[i + 1];
Expand Down
9 changes: 7 additions & 2 deletions msi.gama.core/src/msi/gama/common/geometry/ICoordinates.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,18 @@ default Envelope3D getEnvelope() {
* of the points will not change (only the first 'size' points will be replaced if the length of the parameter / 3
* is greater than the size of the sequence). Allows to maintain 'working sequences' without having to create new
* ones (be aware that if the same working sequence is used in different methods, it might create unexpected side
* effects)
* effects). In the method with an index, the index is expressed in terms of ordinates, not points (an index of 6
* means me will be entering point 2 -- or the 3rd one)
*
* @param points
* an Array of double x, y, z
* @return this
*/
ICoordinates setTo(double... ordinates);
default ICoordinates setTo(final double... ordinates) {
return setTo(0, ordinates);
}

ICoordinates setTo(int begin, double... ordinates);

/**
* Equivalent to the setOrdinate(i, d) method but sets all the ordinates at once. No measure is taken for ensuring
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ public ICoordinates setTo(final GamaPoint... points2) {
}

@Override
public ICoordinates setTo(final double... points2) {
public ICoordinates setTo(final int index, final double... points2) {
growTo(points2.length / 3);
nbPoints = points2.length / 3;
for (int i = 0; i < nbPoints; i++) {
for (int i = index / 3; i < nbPoints; i++) {
points[i].setLocation(points2[i * 3], points2[i * 3 + 1], points2[i * 3 + 2]);
}
ensureClockwiseness();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public ICoordinates setTo(final GamaPoint... points) {
}

@Override
public ICoordinates setTo(final double... points) {
public ICoordinates setTo(final int index, final double... points) {
if (index > 0) return this;
if (points.length < 3) return this;
point.x = points[0];
point.y = points[1];
Expand Down
2 changes: 1 addition & 1 deletion msi.gama.core/src/msi/gama/outputs/LayeredDisplayData.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void notifyListeners(final Changes property, final Object value) {
private Double zoomLevel = INITIAL_ZOOM;
private final LightPropertiesStructure lights[] = new LightPropertiesStructure[8];
public static final ICoordinates KEYSTONE_IDENTITY =
ICoordinates.ofLength(4).setTo(0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0);
ICoordinates.ofLength(4).setTo(0d, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0);

private final ICoordinates keystone = (ICoordinates) KEYSTONE_IDENTITY.clone();
private double zRotationAngleDelta = 0;
Expand Down
3 changes: 1 addition & 2 deletions msi.gama.core/src/msi/gaml/statements/draw/DrawingData.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class DrawingData extends AttributeHolder {
final Attribute<ILocation> anchor;
final Attribute<Boolean> empty;
final Attribute<GamaColor> border, color;
// private final Attribute<IList<GamaColor>> colors;
final Attribute<GamaFont> font;
final Attribute<IList> texture;
final Attribute<GamaMaterial> material;
Expand Down Expand Up @@ -82,7 +81,7 @@ public DrawingData(final DrawStatement symbol) {
}, Types.POINT, null, constSizeCaster);
this.lighting = create(IKeyword.LIGHTED, Types.BOOL, true);
this.depth = create(IKeyword.DEPTH, Types.FLOAT, null);
this.precision = create("precision", Types.FLOAT, 0.1);
this.precision = create("precision", Types.FLOAT, 0.01);
final Function<IExpression, AxisAngle> constRotationCaster = (exp) -> {
if (exp.getGamlType().getGamlType() == Types.PAIR) {
final GamaPair currentRotation = Cast.asPair(null, exp.getConstValue(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,14 @@ private void normalize(final int[] normalCount) {

public void drawOn(final OpenGL openGL) {
final GL2 gl = openGL.getGL();
gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL2.GL_NORMAL_ARRAY);
openGL.enable(GL2.GL_VERTEX_ARRAY);
openGL.enable(GL2.GL_NORMAL_ARRAY);
if (outputsTextures) {
gl.glEnableClientState(GL2.GL_TEXTURE_COORD_ARRAY);
openGL.enable(GL2.GL_TEXTURE_COORD_ARRAY);
} else {
gl.glDisable(GL.GL_TEXTURE_2D);
}
if (outputsColors) { gl.glEnableClientState(GL2.GL_COLOR_ARRAY); }
if (outputsColors) { openGL.enable(GL2.GL_COLOR_ARRAY); }
try {
gl.glVertexPointer(3, GL2.GL_DOUBLE, 0, vertexBuffer);
gl.glNormalPointer(GL2.GL_DOUBLE, 0, normalBuffer);
Expand All @@ -264,7 +264,7 @@ public void drawOn(final OpenGL openGL) {
}
}
if (outputsLines) {
if (!outputsColors) { gl.glEnableClientState(GL2.GL_COLOR_ARRAY); }
if (!outputsColors) { openGL.enable(GL2.GL_COLOR_ARRAY); }
gl.glColorPointer(3, GL2.GL_DOUBLE, 0, lineColorBuffer);
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_LINE);
if (triangles) {
Expand All @@ -276,10 +276,10 @@ public void drawOn(final OpenGL openGL) {
gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
}
} finally {
gl.glDisableClientState(GL2.GL_VERTEX_ARRAY);
gl.glDisableClientState(GL2.GL_NORMAL_ARRAY);
if (outputsTextures) { gl.glDisableClientState(GL2.GL_TEXTURE_COORD_ARRAY); }
if (outputsColors || outputsLines) { gl.glDisableClientState(GL2.GL_COLOR_ARRAY); }
openGL.disable(GL2.GL_VERTEX_ARRAY);
openGL.disable(GL2.GL_NORMAL_ARRAY);
if (outputsTextures) { openGL.disable(GL2.GL_TEXTURE_COORD_ARRAY); }
if (outputsColors || outputsLines) { openGL.disable(GL2.GL_COLOR_ARRAY); }

}
if (withText) { drawLabels(openGL); }
Expand Down

0 comments on commit 5cc2139

Please sign in to comment.