projects
/
sixth-3d.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improved code readability
[sixth-3d.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
sixth
/
e3d
/
renderer
/
raster
/
shapes
/
basic
/
texturedpolygon
/
PolygonBorderInterpolator.java
diff --git
a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/texturedpolygon/PolygonBorderInterpolator.java
b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/texturedpolygon/PolygonBorderInterpolator.java
index
1300e3a
..
f35448d
100644
(file)
--- a/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/texturedpolygon/PolygonBorderInterpolator.java
+++ b/
src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/texturedpolygon/PolygonBorderInterpolator.java
@@
-1,26
+1,29
@@
/*
/*
- * Sixth 3D engine. Author: Svjatoslav Agejenko.
+ * Sixth 3D engine. Author: Svjatoslav Agejenko.
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon;
import eu.svjatoslav.sixth.e3d.geometry.Point2D;
* This project is released under Creative Commons Zero (CC0) license.
*/
package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.texturedpolygon;
import eu.svjatoslav.sixth.e3d.geometry.Point2D;
+import static java.lang.Math.abs;
+
public class PolygonBorderInterpolator implements
Comparable<PolygonBorderInterpolator> {
// on-screen coordinates
public class PolygonBorderInterpolator implements
Comparable<PolygonBorderInterpolator> {
// on-screen coordinates
- Point2D p1;
- Point2D p2;
+ Point2D onScreenPoint1;
+ Point2D onScreenPoint2;
+
double distanceFromY1;
double distanceFromY1;
- private int
h
eight;
- private int
w
idth;
- private int
a
bsoluteHeight;
- private double t
w
idth;
- private double t
h
eight;
+ private int
onScreenH
eight;
+ private int
onScreenW
idth;
+ private int
onscreenA
bsoluteHeight;
+ private double t
extureW
idth;
+ private double t
extureH
eight;
// texture coordinates
// texture coordinates
- private Point2D t
p
1;
- private Point2D t
p
2;
+ private Point2D t
exturePoint
1;
+ private Point2D t
exturePoint
2;
@Override
@Override
@@
-32,21
+35,21
@@
public class PolygonBorderInterpolator implements
@Override
public int hashCode() {
@Override
public int hashCode() {
- int result =
w
idth;
- result = 31 * result +
a
bsoluteHeight;
+ int result =
onScreenW
idth;
+ result = 31 * result +
onscreenA
bsoluteHeight;
return result;
}
@Override
return result;
}
@Override
- public int compareTo(final PolygonBorderInterpolator o) {
- if (
absoluteHeight < o.a
bsoluteHeight)
+ public int compareTo(final PolygonBorderInterpolator o
therInterpolator
) {
+ if (
onscreenAbsoluteHeight < otherInterpolator.onscreenA
bsoluteHeight)
return 1;
return 1;
- if (
absoluteHeight > o.a
bsoluteHeight)
+ if (
onscreenAbsoluteHeight > otherInterpolator.onscreenA
bsoluteHeight)
return -1;
return -1;
- if (
width < o.w
idth)
+ if (
onScreenWidth < otherInterpolator.onScreenW
idth)
return 1;
return 1;
- if (
width > o.w
idth)
+ if (
onScreenWidth > otherInterpolator.onScreenW
idth)
return -1;
return 0;
return -1;
return 0;
@@
-54,59
+57,57
@@
public class PolygonBorderInterpolator implements
public boolean containsY(final int y) {
public boolean containsY(final int y) {
- if (p1.y < p2.y) {
- if (y >= p1.y)
- if (y <= p2.y)
- return true;
- } else if (y >= p2.y)
- if (y <= p1.y)
- return true;
+ if (onScreenPoint1.y < onScreenPoint2.y) {
+ if (y >= onScreenPoint1.y)
+ return y <= onScreenPoint2.y;
+ } else if (y >= onScreenPoint2.y)
+ return y <= onScreenPoint1.y;
return false;
}
public double getTX() {
return false;
}
public double getTX() {
- if (
h
eight == 0)
- return (t
p2.x + tp
1.x) / 2d;
+ if (
onScreenH
eight == 0)
+ return (t
exturePoint2.x + texturePoint
1.x) / 2d;
- return t
p1.x + ((twidth * distanceFromY1) / h
eight);
+ return t
exturePoint1.x + ((textureWidth * distanceFromY1) / onScreenH
eight);
}
public double getTY() {
}
public double getTY() {
- if (
h
eight == 0)
- return (t
p2.y + tp
1.y) / 2d;
+ if (
onScreenH
eight == 0)
+ return (t
exturePoint2.y + texturePoint
1.y) / 2d;
- return t
p1.y + ((theight * distanceFromY1) / h
eight);
+ return t
exturePoint1.y + ((textureHeight * distanceFromY1) / onScreenH
eight);
}
public int getX() {
}
public int getX() {
- if (
h
eight == 0)
- return (int) ((
p2.x + p
1.x) / 2d);
+ if (
onScreenH
eight == 0)
+ return (int) ((
onScreenPoint2.x + onScreenPoint
1.x) / 2d);
- return (int) (
p1.x + ((width * distanceFromY1) / h
eight));
+ return (int) (
onScreenPoint1.x + ((onScreenWidth * distanceFromY1) / onScreenH
eight));
}
public void setCurrentY(final int y) {
}
public void setCurrentY(final int y) {
- distanceFromY1 = y -
p
1.y;
+ distanceFromY1 = y -
onScreenPoint
1.y;
}
}
- public void setPoints(final Point2D
p1, final Point2D p
2,
- final Point2D t
p1, final Point2D tp
2) {
+ public void setPoints(final Point2D
onScreenPoint1, final Point2D onScreenPoint
2,
+ final Point2D t
exturePoint1, final Point2D texturePoint
2) {
- this.
p1 = p
1;
- this.
p2 = p
2;
- this.t
p1 = tp
1;
- this.t
p2 = tp
2;
+ this.
onScreenPoint1 = onScreenPoint
1;
+ this.
onScreenPoint2 = onScreenPoint
2;
+ this.t
exturePoint1 = texturePoint
1;
+ this.t
exturePoint2 = texturePoint
2;
-
height = (int) (p2.y - p
1.y);
-
width = (int) (p2.x - p
1.x);
-
absoluteHeight = Math.abs(h
eight);
+
onScreenHeight = (int) (onScreenPoint2.y - onScreenPoint
1.y);
+
onScreenWidth = (int) (onScreenPoint2.x - onScreenPoint
1.x);
+
onscreenAbsoluteHeight = abs(onScreenH
eight);
- t
width = tp2.x - tp
1.x;
- t
height = tp2.y - tp
1.y;
+ t
extureWidth = texturePoint2.x - texturePoint
1.x;
+ t
extureHeight = texturePoint2.y - texturePoint
1.y;
}
}
}
}