Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions VisualPinball.Engine.Test/Math/VectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,15 @@ public void ShouldCorrectlyCrossVectors()
.Should().BeEquivalentTo(new Vertex3D(-162.5f, -128.5f, 141.25f));
}

[Test]
public void ShouldCorrectlyLerpDragPoints()
{
var dp0 = new DragPointData(2f, 3f);
var dp1 = new DragPointData(8f, 12f);

dp0.Lerp(dp1, 0).Center.Should().Be(new Vertex3D(2f, 3f, 0f));
dp0.Lerp(dp1, 0.2f).Center.Should().Be(new Vertex3D(3.2f, 4.8f, 0f));
dp0.Lerp(dp1, 1).Center.Should().Be(new Vertex3D(8f, 12f, 0f));
}
}
}
22 changes: 22 additions & 0 deletions VisualPinball.Engine/Math/DragPointData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable ConvertToConstant.Global
// ReSharper disable CompareOfFloatsByEqualityOperator
// ReSharper disable InconsistentNaming
#endregion

using System;
Expand Down Expand Up @@ -72,13 +73,33 @@ public override string ToString()
return $"DragPoint({Center.X}/{Center.Y}/{Center.Z}, {(IsSmooth ? "S" : "")}{(IsSlingshot ? "SS" : "")}{(HasAutoTexture ? "A" : "")})";
}

public DragPointData Lerp(DragPointData dp, float pos)
{
return new DragPointData(Center + pos * (dp.Center - Center)) {
IsSmooth = dp.IsSmooth,
IsSlingshot = dp.IsSlingshot,
HasAutoTexture = dp.HasAutoTexture,
TextureCoord = dp.TextureCoord,
IsLocked = dp.IsLocked,
EditorLayer = dp.EditorLayer,
EditorLayerName = dp.EditorLayerName,
EditorLayerVisibility = EditorLayerVisibility
};
}

#region BIFF

static DragPointData()
{
Init(typeof(DragPointData), Attributes);
}

public DragPointData(Vertex3D center) : base(null)
{
Center = center;
HasAutoTexture = true;
}

public DragPointData(float x, float y) : base(null)
{
Center = new Vertex3D(x, y, 0f);
Expand Down Expand Up @@ -112,5 +133,6 @@ public override void Write(BinaryWriter writer, HashWriter hashWriter)
private static readonly Dictionary<string, List<BiffAttribute>> Attributes = new Dictionary<string, List<BiffAttribute>>();

#endregion

}
}
4 changes: 2 additions & 2 deletions VisualPinball.Engine/VPT/Surface/SurfaceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ public class SurfaceData : ItemData, ISurfaceData
public bool SlingshotAnimation = true;

[BiffFloat("ELAS", Pos = 20)]
public float Elasticity;
public float Elasticity = 0.3f;

[BiffFloat("ELFO", Pos = 21, WasAddedInVp107 = true)]
public float ElasticityFalloff;

[BiffFloat("WFCT", Pos = 22)]
public float Friction;
public float Friction = 0.3f;

[BiffFloat("WSCT", Pos = 23)]
public float Scatter;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions VisualPinball.Unity/Assets/Editor/Icons/large_blue/slingshot.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 108 additions & 0 deletions VisualPinball.Unity/Assets/Editor/Icons/large_gray/slingshot.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading