Added new mesh class Rewrite mesh algorithms to be less error prone Make code more concise Tried to add some documentation Added half edge set
69 lines
1.7 KiB
Java
69 lines
1.7 KiB
Java
package com.aaaaahhhhhhh.bananapuncher714.tess4j;
|
|
|
|
import com.aaaaahhhhhhh.bananapuncher714.mesh.Vector2d;
|
|
|
|
public class Vertex {
|
|
private HalfWing wing;
|
|
private Vector2d position;
|
|
|
|
public Vertex( HalfWing wing ) {
|
|
setWing( wing );
|
|
setPosition( new Vector2d() );
|
|
}
|
|
|
|
public HalfWing getWing() {
|
|
return wing;
|
|
}
|
|
|
|
public Vertex setWing( HalfWing wing ) {
|
|
this.wing = wing;
|
|
return this;
|
|
}
|
|
|
|
public Vector2d getPosition() {
|
|
return position;
|
|
}
|
|
|
|
public Vertex setPosition( Vector2d vec ) {
|
|
this.position = vec;
|
|
return this;
|
|
}
|
|
|
|
public void update() {
|
|
HalfWing wing = this.wing;
|
|
do {
|
|
wing.setOrigin( this );
|
|
} while ( ( wing = wing.getPrev() ) != this.wing );
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
final int prime = 31;
|
|
int result = 1;
|
|
result = prime * result + ((position == null) ? 0 : position.hashCode());
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj)
|
|
return true;
|
|
if (obj == null)
|
|
return false;
|
|
if (getClass() != obj.getClass())
|
|
return false;
|
|
Vertex other = (Vertex) obj;
|
|
if (position == null) {
|
|
if (other.position != null)
|
|
return false;
|
|
} else if (!position.equals(other.position))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Vertex{x=" + position.getX() + ",y=" + position.getY() + "}";
|
|
}
|
|
}
|