trackeditor: use inherited value for banking start when splitting segments
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9263 30fe4595-0a0c-4342-8851-515496e4dcbd
This commit is contained in:
parent
a99a804bd6
commit
7df9df071c
|
@ -665,20 +665,20 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
if (!Double.isNaN(heightStart) && oldShape.hasHeightEndLeft())
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEndLeft());
|
||||
double leftHeight = heightStart + (oldShape.getHeightEndLeft() - heightStart) * splitPoint;
|
||||
newShape.setHeightStartLeft(leftHeight);
|
||||
oldShape.setHeightEndLeft(leftHeight);
|
||||
double splitHeight = heightStart + (oldShape.getHeightEndLeft() - heightStart) * splitPoint;
|
||||
newShape.setHeightStartLeft(splitHeight);
|
||||
oldShape.setHeightEndLeft(splitHeight);
|
||||
}
|
||||
|
||||
if (!Double.isNaN(heightStart) && oldShape.hasHeightEndRight())
|
||||
{
|
||||
newShape.setHeightEnd(oldShape.getHeightEndRight());
|
||||
double leftHeight = heightStart + (oldShape.getHeightEndRight() - heightStart) * splitPoint;
|
||||
newShape.setHeightStartRight(leftHeight);
|
||||
oldShape.setHeightEndRight(leftHeight);
|
||||
double splitHeight = heightStart + (oldShape.getHeightEndRight() - heightStart) * splitPoint;
|
||||
newShape.setHeightStartRight(splitHeight);
|
||||
oldShape.setHeightEndRight(splitHeight);
|
||||
}
|
||||
|
||||
double bankingStart = getBankingStart(oldShape);
|
||||
double bankingStart = oldShape.getValidBankingStart(editorFrame);
|
||||
|
||||
if (!Double.isNaN(bankingStart) && oldShape.hasBankingEnd())
|
||||
{
|
||||
|
@ -701,28 +701,6 @@ public class CircuitView extends JComponent implements KeyListener, MouseListene
|
|||
newShape.setSurface(oldShape.getSurface());
|
||||
}
|
||||
|
||||
private double getBankingStart(Segment shape)
|
||||
{
|
||||
double banking = shape.getBankingStart();
|
||||
|
||||
if (!Double.isNaN(banking))
|
||||
{
|
||||
return banking;
|
||||
}
|
||||
|
||||
if (!Double.isNaN(shape.getHeightStart()))
|
||||
{
|
||||
return 0; // flat
|
||||
}
|
||||
|
||||
if (!Double.isNaN(shape.getHeightStartLeft()) && !Double.isNaN(shape.getHeightStartRight()))
|
||||
{
|
||||
return Math.atan2(shape.getHeightStartLeft() - shape.getHeightStartRight(), editorFrame.getTrackData().getMainTrack().getWidth()) * 180.0 / Math.PI;
|
||||
}
|
||||
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
private ObjectMap findObjectMap(ObjShapeObject object)
|
||||
{
|
||||
for (int i = 0; i < editorFrame.getObjectMaps().size(); i++)
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Properties
|
|||
private static Properties instance = new Properties();
|
||||
private Vector<ActionListener> propertiesListeners = new Vector<ActionListener>();
|
||||
public final String title = "sd2-trackeditor";
|
||||
public final String version = "1.4.9";
|
||||
public final String version = "1.4.10";
|
||||
private String path;
|
||||
|
||||
private double imageScale = 1;
|
||||
|
|
|
@ -1789,7 +1789,7 @@ public class Segment implements Cloneable
|
|||
{
|
||||
Segment previous = this;
|
||||
|
||||
// try to get missing attribute from previous segments first
|
||||
// try to get missing attribute from previous segments
|
||||
while (previous != null)
|
||||
{
|
||||
if (previous.hasHeightStart())
|
||||
|
@ -1826,7 +1826,7 @@ public class Segment implements Cloneable
|
|||
{
|
||||
Segment previous = this;
|
||||
|
||||
// try to get missing attribute from previous segments first
|
||||
// try to get missing attribute from previous segments
|
||||
while (previous != null)
|
||||
{
|
||||
if (previous.hasHeightStartLeft())
|
||||
|
@ -1859,7 +1859,7 @@ public class Segment implements Cloneable
|
|||
{
|
||||
Segment previous = this;
|
||||
|
||||
// try to get missing attribute from previous segments first
|
||||
// try to get missing attribute from previous segments
|
||||
while (previous != null)
|
||||
{
|
||||
if (previous.hasHeightStartRight())
|
||||
|
@ -1888,6 +1888,61 @@ public class Segment implements Cloneable
|
|||
return Double.NaN;
|
||||
}
|
||||
|
||||
public double getValidBankingStart(EditorFrame editorFrame)
|
||||
{
|
||||
Segment previous = this;
|
||||
|
||||
// try to get missing attribute from previous segments
|
||||
while (previous != null)
|
||||
{
|
||||
if (previous.hasBankingStart())
|
||||
{
|
||||
return previous.bankingStart;
|
||||
}
|
||||
else if (previous.hasHeightStart())
|
||||
{
|
||||
return 0; // flat
|
||||
}
|
||||
else if (previous.hasHeightStartLeft() && previous.hasHeightStartRight())
|
||||
{
|
||||
if (previous.heightStartLeft == previous.heightStartRight)
|
||||
{
|
||||
return 0; // flat
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.atan2(previous.heightStartLeft - previous.heightStartRight, editorFrame.getTrackData().getMainTrack().getWidth()) * 180.0 / Math.PI;
|
||||
}
|
||||
}
|
||||
previous = previous.previousShape;
|
||||
if (previous == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (previous.hasBankingEnd())
|
||||
{
|
||||
return previous.bankingEnd;
|
||||
}
|
||||
else if (previous.hasHeightEnd())
|
||||
{
|
||||
return 0; // flat
|
||||
}
|
||||
else if (previous.hasHeightEndLeft() && previous.hasHeightEndRight())
|
||||
{
|
||||
if (previous.heightEndLeft == previous.heightEndRight)
|
||||
{
|
||||
return 0; // flat
|
||||
}
|
||||
else
|
||||
{
|
||||
return Math.atan2(previous.heightEndLeft - previous.heightEndRight, editorFrame.getTrackData().getMainTrack().getWidth()) * 180.0 / Math.PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Double.NaN;
|
||||
}
|
||||
|
||||
public void inheritProperties(Segment previousShape)
|
||||
{
|
||||
setSurface(previousShape.getSurface());
|
||||
|
|
Loading…
Reference in New Issue