Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f9830fa
jobs: Remove job for populating octree.
freezy Sep 22, 2025
075328c
refactor: Split render pipeline interface into runtime and editor.
freezy Sep 22, 2025
46c3bdf
perf: Add frame pacing stats overlay.
freezy Sep 22, 2025
a2edfde
perf: Use busy time.
freezy Sep 22, 2025
3a1693b
perf: Plot physics loop.
freezy Sep 23, 2025
6776d1c
perf: Fix CPU usage.
freezy Sep 23, 2025
505f4f1
perf: Print stats to the right.
freezy Sep 25, 2025
87766ef
perf: Fix stats window placing.
freezy Sep 25, 2025
5721c00
perf: Make FPS big.
freezy Sep 25, 2025
16ce6d2
physics: Commit old code
freezy Feb 1, 2026
6a97e67
physics: Add POC of simulation threads.
freezy Feb 1, 2026
9250900
physics: Use external timing for polling input data.
freezy Feb 2, 2026
43b9f97
physics: Fix allocation and threading issues.
freezy Feb 2, 2026
fedb761
physics: Allocator fix.
freezy Feb 2, 2026
a11e5da
gle: Add better lifecycle handling.
freezy Feb 7, 2026
19a0f47
gle: Clean up debug code.
freezy Feb 7, 2026
d7734d8
gle: Make event reception thread-safe.
freezy Feb 15, 2026
bcba911
fix: Switch dispatch issues.
freezy Feb 16, 2026
d45b9d2
perf: Show CPU busy.
freezy Feb 17, 2026
5c463a9
perf: Properly pull physics duration.
freezy Feb 17, 2026
1e93a23
perf: Plot input latency
freezy Feb 17, 2026
bbbb64d
gle: Add support for SetTimeFence()
freezy Feb 17, 2026
fa83599
physics: Align threading logic with vpinball's.
freezy Mar 1, 2026
3f9187e
physics: Address threading issues.
freezy Mar 1, 2026
a9dad29
physics: Remove physics lock for ApplyMovements, and fix kinematic co…
freezy Mar 1, 2026
b0c5e43
cleanup: Remove legacy lock-based fallback path in PhysicsEngine.Appl…
freezy Mar 1, 2026
73b8f57
physics: Move physics context and threading code into a separate class.
freezy Mar 1, 2026
02d3b9f
physics. Rebuild kinematic octree only once a frame, and only if dirty.
freezy Mar 1, 2026
af20baa
physics: Various performance improvements.
freezy Mar 1, 2026
7518450
physics: Use use Unity-scaled clock model as the main thread phyisics…
freezy Mar 6, 2026
c4c6a6a
physics: Never mutate state directly from main thread.
freezy Mar 6, 2026
018fdf2
physics: Make collider state changes sim-thread-owned.
freezy Mar 6, 2026
2f8e2e4
physics: Remove direct main-thread `OnTransformationChanged(...)` phy…
freezy Mar 6, 2026
7a97605
physics: Define and enforce a hard thread-ownership contract.
freezy Mar 6, 2026
b7abdc7
physics: Stop running managed callbacks under `PhysicsLock`.
freezy Mar 6, 2026
bb4e30f
physics: Shorten `InputActionsLock` hold time.
freezy Mar 6, 2026
dc18da1
physics: Batch kinematic staging.
freezy Mar 6, 2026
ae186d9
physics: Fix disposal bug.
freezy Mar 6, 2026
3611cde
physics: Bound or instrument all cross-thread queues.
freezy Mar 6, 2026
5fbec75
fix: Too optimistic ball creation logic.
freezy Mar 6, 2026
82a6711
physics: Tighten `SetTimeFence(...)` cadence.
freezy Mar 6, 2026
dc16087
physics: Generalize low-latency coil handling.
freezy Mar 6, 2026
3a96cca
physics: Finish shared-state publication for PinMAME outputs.
freezy Mar 6, 2026
72d0039
physics: Reevaluate lamp/GI polling strategy.
freezy Mar 6, 2026
1177376
perf: Optimize animation snapshot production.
freezy Mar 6, 2026
0745f51
perf: Rework `ScheduledActions` into a low-overhead scheduler.
freezy Mar 6, 2026
50beb22
fix: Another race window...
freezy Mar 6, 2026
7b694fe
debug: Add CPU perf stats.
freezy Mar 6, 2026
2a94841
perf: Fix some GC issues.
freezy Mar 6, 2026
0da2c64
physics: Make scheduling more solid.
freezy Mar 6, 2026
e4d805a
fix: DMD colors.
freezy Mar 6, 2026
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
19 changes: 14 additions & 5 deletions VisualPinball.Engine/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static class PhysicsConstants
public const float DefaultStepTimeS = 0.01f; // DEFAULT_STEPTIME_S


public const double PhysFactor = PhysicsStepTimeS / DefaultStepTimeS; // PHYS_FACTOR
public const float PhysFactor = (float)(PhysicsStepTimeS / DefaultStepTimeS); // PHYS_FACTOR


public const float LowNormVel = 0.0001f; // C_LOWNORMVEL
Expand Down Expand Up @@ -113,10 +113,19 @@ public static class PhysicsConstants
public const float ToleranceEndPoints = 0.0f; // C_TOL_ENDPNTS
public const float ToleranceRadius = 0.005f; // C_TOL_RADIUS

/// <summary>
/// Precision level and cycles for interative calculations // acceptable contact time ... near zero time
/// </summary>
public const int Internations = 20; // C_INTERATIONS
/// <summary>
/// Precision level and cycles for interative calculations // acceptable contact time ... near zero time
/// </summary>
public const int Internations = 20; // C_INTERATIONS

/// <summary>
/// Maximum number of physics sub-steps per <see cref="PhysicsStepTime"/> frame.
/// If the physics loop falls behind (e.g. due to a frame hitch), it
/// will catch up for at most this many iterations before skipping
/// physics time forward. Prevents hitch cascades.
/// <para>200 iterations = 200ms of physics at 1kHz step rate.</para>
/// </summary>
public const int MaxSubSteps = 200; // PHYSICS_MAX_LOOPS
}

public static class InputConstants
Expand Down
30 changes: 29 additions & 1 deletion VisualPinball.Unity/Assets/Resources/Prefabs/DefaultBall.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 3881672604355561253}
- component: {fileID: 6075728238804368159}
- component: {fileID: 5180081487853661404}
- component: {fileID: 8313200498354517976}
m_Layer: 0
m_Name: DefaultBall
m_TagString: Untagged
Expand All @@ -25,12 +26,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8289283333368007096}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &6075728238804368159
MeshFilter:
Expand All @@ -51,11 +53,17 @@ MeshRenderer:
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
Expand All @@ -77,7 +85,27 @@ MeshRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &8313200498354517976
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8289283333368007096}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a04fca20ce2246b9abf456441b587efd, type: 3}
m_Name:
m_EditorClassIdentifier: VisualPinball.Unity::VisualPinball.Unity.BallComponent
Radius: 25
Mass: 1
Velocity:
x: 0
y: 0
z: 0
IsFrozen: 0
3 changes: 3 additions & 0 deletions VisualPinball.Unity/VisualPinball.Unity.Editor/Rendering.meta

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Visual Pinball Engine
// Copyright (C) 2023 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Linq;
using NLog;
using UnityEngine;
using Logger = NLog.Logger;

namespace VisualPinball.Unity.Editor
{
/// <summary>
/// A common interface for all render pipelines that covers material
/// creation, lighting setup and ball creation.
/// </summary>
public interface IRenderPipelineConverter
{
/// <summary>
/// Name of the render pipeline
/// </summary>
string Name { get; }

/// <summary>
/// Type of the render pipeline.
/// </summary>
RenderPipelineType Type { get; }

/// <summary>
/// Provides a bunch of helper methods for setting common attributes
/// in materials.
/// </summary>
IMaterialAdapter MaterialAdapter { get; }

/// <summary>
/// Provides access to VPE's game item prefabs.
/// </summary>
IPrefabProvider PrefabProvider { get; }
}

/// <summary>
/// A global static class that checks which render pipeline implementations
/// are available and instantiates an SRP if available or the included
/// built-in instance otherwise.
/// </summary>
public static class RenderPipelineConverter
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();

private static IRenderPipelineConverter _current;

/// <summary>
/// Returns the currently instantiated render pipeline.
/// </summary>
public static IRenderPipelineConverter Current {
get {
if (_current == null) {
Debug.Log("Detecting render pipeline converter...");
var t = typeof(IRenderPipelineConverter);
var pipelines = AppDomain.CurrentDomain.GetAssemblies()
.Where(x => x.FullName.StartsWith("VisualPinball."))
.SelectMany(x => x.GetTypes())
.Where(x => x.IsClass && t.IsAssignableFrom(x))
.Select(x => (IRenderPipelineConverter) Activator.CreateInstance(x))
.ToArray();

Debug.Log("Found pipelines: " + string.Join(", ", pipelines.Select(p => p.Name)));

_current = pipelines.Length == 1
? pipelines.First()
: pipelines.First(p => p.Type != RenderPipelineType.Standard);

Debug.Log($"Instantiated {_current.Name}.");
Logger.Info($"Instantiated {_current.Name}.");
}
return _current;
}
}
}
}

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@

// ReSharper disable UnusedType.Global

using VisualPinball.Unity.Editor;

namespace VisualPinball.Unity
{
public class StandardRenderPipeline : IRenderPipeline
public class StandardRenderPipeline : IRenderPipelineConverter
{
public string Name { get; } = "Built-in Render Pipeline";

public RenderPipelineType Type { get; } = RenderPipelineType.Standard;
public IMaterialConverter MaterialConverter { get; } = new StandardMaterialConverter();
public IMaterialAdapter MaterialAdapter { get; } = new StandardMaterialAdapter();
public ILightConverter LightConverter { get; } = new StandardLightConverter();
public IBallConverter BallConverter { get; } = new StandardBallConverter();
public IPrefabProvider PrefabProvider { get; } = new StandardPrefabProvider();
}
}
Loading
Loading