Skip to content

Commit

Permalink
Support padding for road marking arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
tordanik committed May 28, 2024
1 parent 5e1f21f commit 1d70476
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/main/java/org/osm2world/core/world/modules/RoadModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.osm2world.core.target.common.material.TextureDataDimensions;
import org.osm2world.core.target.common.mesh.Mesh;
import org.osm2world.core.target.common.texcoord.TexCoordFunction;
import org.osm2world.core.target.common.texcoord.TexCoordUtil;
import org.osm2world.core.util.enums.LeftRight;
import org.osm2world.core.world.data.LegacyWorldObject;
import org.osm2world.core.world.data.ProceduralWorldObject;
Expand Down Expand Up @@ -2271,22 +2272,12 @@ private static Material addTurnArrows(Material material,
* To reduce the number of necessary textures, it uses mirrored versions of
* the various right-pointing arrows for left-pointing arrows.
*/
private static class ArrowTexCoordFunction implements TexCoordFunction {

private final RoadPart roadPart;
private final boolean rightHandTraffic;
private final boolean mirrorLeftRight;
private final TextureDataDimensions textureDimensions;

private ArrowTexCoordFunction(RoadPart roadPart,
boolean rightHandTraffic, boolean mirrorLeftRight, TextureDataDimensions textureDimensions) {

this.roadPart = roadPart;
this.rightHandTraffic = rightHandTraffic;
this.mirrorLeftRight = mirrorLeftRight;
this.textureDimensions = textureDimensions;

}
private record ArrowTexCoordFunction (
RoadPart roadPart,
boolean rightHandTraffic,
boolean mirrorLeftRight,
TextureDataDimensions textureDimensions
) implements TexCoordFunction {

@Override
public List<VectorXZ> apply(List<VectorXYZ> vs) {
Expand All @@ -2295,7 +2286,7 @@ public List<VectorXZ> apply(List<VectorXYZ> vs) {
throw new IllegalArgumentException("not a triangle strip lane");
}

List<VectorXZ> result = new ArrayList<VectorXZ>(vs.size());
List<VectorXZ> result = new ArrayList<>(vs.size());

boolean forward = roadPart == RoadPart.LEFT ^ rightHandTraffic;

Expand Down Expand Up @@ -2361,7 +2352,8 @@ public List<VectorXZ> apply(List<VectorXYZ> vs) {
t = higher ? 0 : 1;
}

result.add(new VectorXZ(s, t));
VectorXZ rawTexCoord = new VectorXZ(s, t);
result.add(TexCoordUtil.applyPadding(rawTexCoord, textureDimensions));

}

Expand Down

0 comments on commit 1d70476

Please sign in to comment.