Skip to content

Commit d3d9ce1

Browse files
committed
Refactoring. Extracted methods.
1 parent 641debc commit d3d9ce1

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/main/java/mesh/modifier/BendModifier.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,26 @@ private void simpleDeformBend(Vector3f v) {
2626
float sinTheta = Mathf.sin(theta);
2727
float cosTheta = Mathf.cos(theta);
2828

29-
if (Mathf.abs(factor) > EPSILON) {
30-
float bx = -(v.y - 1.0f / factor) * sinTheta;
31-
float by = (v.y - 1.0f / factor) * cosTheta + 1.0f / factor;
32-
float bz = v.z;
33-
v.set(bx, by, bz);
34-
}
29+
float bx = -(v.y - 1.0f / factor) * sinTheta;
30+
float by = (v.y - 1.0f / factor) * cosTheta + 1.0f / factor;
31+
float bz = v.z;
32+
33+
v.set(bx, by, bz);
34+
}
35+
36+
private void bend(Mesh3D mesh) {
37+
for (Vector3f v : mesh.vertices)
38+
simpleDeformBend(v);
39+
}
40+
41+
private boolean isFactorValid() {
42+
return Mathf.abs(factor) > EPSILON;
3543
}
3644

3745
@Override
3846
public Mesh3D modify(Mesh3D mesh) {
39-
for (Vector3f v : mesh.vertices)
40-
simpleDeformBend(v);
47+
if (isFactorValid())
48+
bend(mesh);
4149
return mesh;
4250
}
4351

0 commit comments

Comments
 (0)