Skip to content

Commit

Permalink
doc: Update changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
freezy committed Jan 6, 2025
1 parent 60b18b4 commit f1d17a2
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 89 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Built with Unity 2022.3.x

### Added

- Free transformation ([#500](https://github.com/freezy/VisualPinball.Engine/pull/500))
- Kinematic collisions ([#460](https://github.com/freezy/VisualPinball.Engine/pull/460))
- Flipper tricks by nFozzy ([#436](https://github.com/freezy/VisualPinball.Engine/pull/436))
- Asset Library now has thumbnails.
Expand Down
8 changes: 3 additions & 5 deletions VisualPinball.Unity/VisualPinball.Unity/Physics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ approach is the following:
result in a rectangle parallel and orthogonal to the playfield, which wouldn't be
desired.
- But more on that problem later. What's important is that for transformations
*supported by the VPX physics code*, we have a method that allows to transform
each collider, based on a matrix.
- Additionally, colliders are instantiated without a transformation matrix. That means
by default, they are placed at the origin and have no rotation or scale.
*supported by the VPX physics code*, we have a method that allows to transform each collider, based on a matrix.
- Additionally, colliders are always instantiated without any transformation. That means by default, they are placed at the origin and have no rotation or scale.
- Finally, each collider gets a `TransformAABBs(float4x4)` method that only transforms
the collider's axis-aligned bounding boxes.

Expand All @@ -193,7 +191,7 @@ So, with all of the above, we do the following when the game starts:
3. We check which kind of transformation the VPX physics code supports for the type of
collider and compare it to the transformation of playfield-to-local matrix.
- If all transformations are supported, we simply transform the collider with the item's
transformation matrix.
transformation matrix.
- If not, we check whether this collider might be replaceable by another type of collider
that supports the transformation. For example, a line collider can be replaced by two
triangle colliders, which then are 100% transformable.
Expand Down
18 changes: 17 additions & 1 deletion VisualPinball.Unity/VisualPinball.Unity/VPT/ISurfaceComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
using UnityEngine;
// 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 UnityEngine;

namespace VisualPinball.Unity
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

// ReSharper disable InconsistentNaming

using Unity.Mathematics;
using UnityEngine;
using VisualPinball.Engine.VPT.MetalWireGuide;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@
// 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 VisualPinball.Engine.VPT;

namespace VisualPinball.Unity
{
internal static class TriggerAnimation
{
internal static void Update(ref TriggerAnimationState animation, ref TriggerMovementState movement, in TriggerStaticState staticState,
float dTimeMs)
{
// var oldTimeMsec = animation.TimeMsec < dTimeMs ? animation.TimeMsec : dTimeMs;
// animation.TimeMsec = dTimeMs;
// var diffTimeMsec = dTimeMs - oldTimeMsec;

var animLimit = staticState.Shape == TriggerShape.TriggerStar ? staticState.Radius * (float)(1.0 / 5.0) : 32.0f;
if (staticState.Shape == TriggerShape.TriggerButton) {
animLimit = staticState.Radius * (float)(1.0 / 10.0);
}
if (staticState.Shape == TriggerShape.TriggerWireC) {
animLimit = 60.0f;
}
if (staticState.Shape == TriggerShape.TriggerWireD) {
animLimit = 25.0f;
}

var limit = animLimit * staticState.TableScaleZ;

if (animation.HitEvent) {
animation.DoAnimation = true;
animation.HitEvent = false;
// unhitEvent = false; // Bugfix: If HitEvent and unhitEvent happen at the same time, you want to favor the unhit, otherwise the switch gets stuck down.
movement.HeightOffset = 0.0f;
animation.MoveDown = true;
}
if (animation.UnHitEvent) {
animation.DoAnimation = true;
animation.UnHitEvent = false;
animation.HitEvent = false;
//movement.HeightOffset = limit;
animation.MoveDown = false;
}

if (animation.DoAnimation) {
var step = dTimeMs * staticState.AnimSpeed * staticState.TableScaleZ;
if (animation.MoveDown) {
step = -step;
}
movement.HeightOffset += step;

if (animation.MoveDown) {
if (movement.HeightOffset <= -limit) {
movement.HeightOffset = -limit;
animation.DoAnimation = false;
animation.MoveDown = false;
}

} else {
if (movement.HeightOffset >= 0.0f) {
movement.HeightOffset = 0.0f;
animation.DoAnimation = false;
animation.MoveDown = true;
}
}
}
}
}
}
// 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 VisualPinball.Engine.VPT;

namespace VisualPinball.Unity
{
internal static class TriggerAnimation
{
internal static void Update(ref TriggerAnimationState animation, ref TriggerMovementState movement, in TriggerStaticState staticState,
float dTimeMs)
{
// var oldTimeMsec = animation.TimeMsec < dTimeMs ? animation.TimeMsec : dTimeMs;
// animation.TimeMsec = dTimeMs;
// var diffTimeMsec = dTimeMs - oldTimeMsec;

var animLimit = staticState.Shape == TriggerShape.TriggerStar ? staticState.Radius * (float)(1.0 / 5.0) : 32.0f;
if (staticState.Shape == TriggerShape.TriggerButton) {
animLimit = staticState.Radius * (float)(1.0 / 10.0);
}
if (staticState.Shape == TriggerShape.TriggerWireC) {
animLimit = 60.0f;
}
if (staticState.Shape == TriggerShape.TriggerWireD) {
animLimit = 25.0f;
}

var limit = animLimit * staticState.TableScaleZ;

if (animation.HitEvent) {
animation.DoAnimation = true;
animation.HitEvent = false;
// unhitEvent = false; // Bugfix: If HitEvent and unhitEvent happen at the same time, you want to favor the unhit, otherwise the switch gets stuck down.
movement.HeightOffset = 0.0f;
animation.MoveDown = true;
}
if (animation.UnHitEvent) {
animation.DoAnimation = true;
animation.UnHitEvent = false;
animation.HitEvent = false;
//movement.HeightOffset = limit;
animation.MoveDown = false;
}

if (animation.DoAnimation) {
var step = dTimeMs * staticState.AnimSpeed * staticState.TableScaleZ;
if (animation.MoveDown) {
step = -step;
}
movement.HeightOffset += step;

if (animation.MoveDown) {
if (movement.HeightOffset <= -limit) {
movement.HeightOffset = -limit;
animation.DoAnimation = false;
animation.MoveDown = false;
}

} else {
if (movement.HeightOffset >= 0.0f) {
movement.HeightOffset = 0.0f;
animation.DoAnimation = false;
animation.MoveDown = true;
}
}
}
}
}
}

0 comments on commit f1d17a2

Please sign in to comment.