Skip to content

Add physical drop target mechanics#565

Draft
freezy wants to merge 8 commits into
masterfrom
physics/drop-target-mechanics
Draft

Add physical drop target mechanics#565
freezy wants to merge 8 commits into
masterfrom
physics/drop-target-mechanics

Conversation

@freezy

@freezy freezy commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Fixes #536.

Summary

  • add opt-in Legacy, RothCompatible, and Mechanical drop-target physics modes while preserving Legacy as the default for existing content
  • add explicit collider roles and package schema migration for front sensors, physical faces, and back faces
  • reproduce the common Roth mass correction, brick classification, backside behavior, timing, and optional deterministic vertical bouncer without table scripts
  • simulate Mechanical targets with finite effective mass, frictional contact, rear spring and stop, latch release/relatch, downward travel, down-stop rebound, reset motion, and moving-collider ball lift
  • resolve simultaneous contacts in stable order and preserve the original collision ordering on tables without Mechanical targets
  • support sliding and hinged target deflection, including point-dependent effective mass for hinged blades
  • add reusable physics profiles, validation warnings, travel gizmos, runtime diagnostics, profiler markers, documentation, and VPX export warnings

Validation

  • Unity 6.5 EditMode: 37/37 drop-target tests pass
  • generated Unity solution compiles with zero errors
  • DocFX builds with zero errors; the remaining FlipperApi xref warning is pre-existing and unrelated
  • full branch diff passes git diff --check

Rollout notes

  • the bundled Generic Sliding Blade profile is explicitly provisional and is not presented as measured real-machine calibration
  • promoting a profile to measured still requires recorded mechanism data, held-out validation shots, and the documented 20-target performance benchmark
  • VPX export retains ordinary target data but cannot preserve the advanced VPE physics settings

@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds opt-in advanced drop-target physics. The main changes are:

  • Legacy, Roth-compatible, and Mechanical physics modes.
  • New collider roles and package fields for front, collision, and back meshes.
  • Finite-mass mechanical target state, impact, reset, and switch behavior.
  • Editor validation, runtime diagnostics, profiles, tests, and documentation.

Confidence Score: 4/5

The mechanical reset collision path needs a fix before merging.

  • Passive back-face contacts can receive powered reset impulses.
  • The issue is contained to mechanical drop-target reset and settle collisions.
  • The package migration and legacy default paths look consistent from the inspected changes.

VisualPinball.Unity/VisualPinball.Unity/VPT/HitTarget/TargetCollider.cs

Important Files Changed

Filename Overview
VisualPinball.Unity/VisualPinball.Unity/Game/PhysicsCycle.cs Adds special grouping and reduction for mechanical drop-target contacts.
VisualPinball.Unity/VisualPinball.Unity/VPT/HitTarget/TargetCollider.cs Adds mode-specific drop-target collision handling, with a role-filtering bug during reset contacts.
VisualPinball.Unity/VisualPinball.Unity/VPT/HitTarget/MechanicalDropTargetPhysics.cs Adds the mechanical target state machine, impact solver, reset motion, and pose publishing.
VisualPinball.Unity/VisualPinball.Unity/VPT/HitTarget/DropTargetPackable.cs Extends package data for physics modes, profiles, Roth settings, mechanical settings, and the third collider mesh.
VisualPinball.Unity/VisualPinball.Unity/VPT/HitTarget/DropTargetApi.cs Adds mode-aware drop/reset commands and collider generation for the new target modes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Ball hits mechanical drop target] --> B{Target resetting or settling?}
  B -->|Yes| C{Collider role is physical face?}
  C -->|Yes| D[Apply powered reset contact]
  C -->|No| E[Use passive wall or back-face collision]
  B -->|No| F{Collider role is physical face?}
  F -->|Yes| G[Apply mechanical face impact]
  F -->|No| E
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
  A[Ball hits mechanical drop target] --> B{Target resetting or settling?}
  B -->|Yes| C{Collider role is physical face?}
  C -->|Yes| D[Apply powered reset contact]
  C -->|No| E[Use passive wall or back-face collision]
  B -->|No| F{Collider role is physical face?}
  F -->|Yes| G[Apply mechanical face impact]
  F -->|No| E
Loading

Reviews (1): Last reviewed commit: "physics: clean up drop target whitespace" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop Target Physics

1 participant