77import java .util .ArrayList ;
88import java .util .Collection ;
99import java .util .List ;
10+ import java .util .Objects ;
1011
1112import org .osm2world .map_data .data .TagSet ;
1213import org .osm2world .math .VectorXZ ;
1314import org .osm2world .math .shapes .LineSegmentXZ ;
1415import org .osm2world .math .shapes .PolygonWithHolesXZ ;
1516import org .osm2world .math .shapes .SimplePolygonXZ ;
1617import org .osm2world .scene .material .Material ;
18+ import org .osm2world .world .modules .building .BuildingPart ;
1719
1820public class RoundRoof extends RoofWithRidge {
1921
20- private final static double ROOF_SUBDIVISION_METER = 2.5 ;
22+ private final static double ROOF_SUBDIVISIONS_PER_HEIGHT_METER = 1 ;
2123
2224 private final List <LineSegmentXZ > capParts ;
2325 private final int rings ;
@@ -26,9 +28,14 @@ public RoundRoof(PolygonWithHolesXZ originalPolygon, TagSet tags, Material mater
2628
2729 super (0 , originalPolygon , tags , material );
2830
29- rings = (int )max (3 , maxDistanceToRidge /ROOF_SUBDIVISION_METER );
31+ /* determine how many segments to use to simulate a round surface */
32+
33+ double height = Objects .requireNonNullElse (super .calculatePreliminaryHeight (), BuildingPart .DEFAULT_RIDGE_HEIGHT );
34+ rings = (int )max (3 , height / ROOF_SUBDIVISIONS_PER_HEIGHT_METER );
35+
36+ /* decide where to place the segments */
37+
3038 capParts = new ArrayList <>(rings *2 );
31- // TODO: would be good to vary step size with slope
3239 float step = 0.5f / (rings + 1 );
3340 for (int i = 1 ; i <= rings ; i ++) {
3441 capParts .add (new LineSegmentXZ (
0 commit comments