Skip to content

Commit

Permalink
Adjust static friction and adjust steam locomotive power
Browse files Browse the repository at this point in the history
* Boiler pressure traction adjustment
* steam slip coefficient adjustment
* better static/kinetic friction values
* syncronized client/server slipping
  • Loading branch information
cam72cam committed Jun 4, 2024
1 parent bef835d commit f646954
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/main/java/cam72cam/immersiverailroading/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ public static class ConfigBalance {
@Comment("Traction Multiplier: Higher numbers decreases wheel slip, lower numders increase wheel slip")
@Range(min = 0, max = 10)
public static double tractionMultiplier = 1.0;


@Comment("Steam Traction At Pressure: Most locomotives traction is calculated at 85%. Modelers should override this in config (eventually)")
@Range(min = 0.1, max = 10)
public static double steamTractionAtPressure = 0.85;

@Comment( "How heavy is a single block in Kg" )
@Range(min = 0, max = 100)
public static int blockWeight = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public abstract class Locomotive extends FreightTank {
@TagField("cogging")
private boolean cogging = false;

@TagSync
@TagField("slipping")
protected boolean slipping = false;

/*
Expand Down Expand Up @@ -611,7 +613,7 @@ public void setBell(int newBell) {
}

public double slipCoefficient(Speed speed) {
double slipMult = 0.5; //TODO Assumes dirty rails. Set this back to 1.0 and adjust physics coefficients
double slipMult = 1.0;
World world = getWorld();
if (world.isPrecipitating() && world.canSeeSky(getBlockPosition())) {
if (world.isRaining(getBlockPosition())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public double getAppliedTractiveEffort(Speed speed) {

// This is terrible, but allows wheel slip for both legacy and updated hp vs te
double traction_N = Math.max(
this.getDefinition().getStartingTractionNewtons(gauge),
this.getDefinition().getStartingTractionNewtons(gauge) / ConfigBalance.steamTractionAtPressure,
this.getDefinition().getHorsePower(gauge) * 375 / Math.max(Math.abs(speed.imperial()), 1.0)
);
if (Config.isFuelRequired(gauge)) {
Expand Down Expand Up @@ -143,9 +143,11 @@ public double slipCoefficient(Speed speed) {

// TODO better approximation
// assume wheel diameter == 5m
/*
double ratio = 0.35;
double hammer = ratio + (slipping ? 0 : Math.abs(Math.sin(Math.toRadians(360 * distanceTraveled / (5f * gauge.scale()/ 2))) * (1-ratio)));
slipMult *= hammer;
*/

return slipMult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ private boolean match(PhysicalMaterials materialA, PhysicalMaterials materialB,
private float friction(PhysicalMaterials other, boolean kinetic) {
// unless otherwise specified: https://structx.com/Material_Properties_005a.html

float dirty = 0.5f;

if (match(STEEL, STEEL, this, other)) {
// assume slightly dirty / non-ideal surfaces
return kinetic ? 0.42f : 0.7f;
return (kinetic ? 0.5f : 0.8f) * dirty;
}
if (match(STEEL, CAST_IRON, this, other)) {
return kinetic ? 0.25f : 0.4f;
return (kinetic ? 0.25f : 0.4f) * dirty;
}
if (match(STEEL, WOOD, this, other)) {
return kinetic ? 0.2f : 0.6f;
return (kinetic ? 0.2f : 0.6f) * dirty;
}

return 0;
Expand Down

0 comments on commit f646954

Please sign in to comment.