Skip to content

Commit

Permalink
Merge branch 'model_scale_fixes' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Sep 12, 2023
2 parents 575f192 + a7e1f8a commit 9fb8130
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public class TrackModel extends OBJModel {
private final String compare;
private final double size;
private final double height;
public final double spacing;

public TrackModel(String condition, Identifier resource, double model_gauge_m) throws Exception {
public TrackModel(String condition, Identifier resource, double model_gauge_m, double spacing) throws Exception {
super(resource, 0, Gauges.STANDARD / model_gauge_m);
this.compare = condition.substring(0, 1);
this.size = Double.parseDouble(condition.substring(1));
Expand All @@ -22,6 +23,7 @@ public TrackModel(String condition, Identifier resource, double model_gauge_m) t
}
}
height = maxOfGroup(groups).y;
this.spacing = spacing * (Gauges.STANDARD / model_gauge_m);
}

public boolean canRender(double gauge) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ public class TrackDefinition {
this.bumpiness = object.getValue("bumpiness").asFloat(clack ? 1f : 0f);
this.cog = object.getValue("cog").asBoolean(false);
this.model_gauge_m = object.getValue("model_gauge_m").asDouble(Gauges.STANDARD);
double spacing = object.getValue("model_spacing_m").asDouble( model_gauge_m / Gauges.STANDARD);

this.models = new ArrayList<>();
DataBlock models = object.getBlock("models");
for (Map.Entry<String, DataBlock.Value> entry : models.getValueMap().entrySet()) {
this.models.add(new TrackModel(entry.getKey(), entry.getValue().asIdentifier(), model_gauge_m));
this.models.add(new TrackModel(entry.getKey(), entry.getValue().asIdentifier(), model_gauge_m, spacing));
}

DataBlock mats = object.getBlock("materials");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public List<VecYawPitch> getRenderData() {
List<VecYawPitch> data = new ArrayList<VecYawPitch>();

double scale = info.settings.gauge.scale();
List<PosStep> points = getPath(scale);
List<PosStep> points = getPath(scale * info.getTrackModel().spacing);

boolean switchStraight = info.switchState == SwitchState.STRAIGHT;
int switchSize = 0;
Expand Down

0 comments on commit 9fb8130

Please sign in to comment.