Skip to content

Commit

Permalink
Release 6.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Release Automat committed May 3, 2024
1 parent e06d16f commit cb79b81
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Packages/tlp.udonutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:

All notable changes to this project will be documented in this file.

### [6.1.1] - 2024-05-03

#### 🚀 Features

- *(Physics)* Add PhysicsUtils class with function CalculateAccelerationAndVelocity from positions

#### 🐛 Bug Fixes

- *(DemoBlackListToggle)* Add check for unset White-/Blacklist buttons

#### ⚙️ Miscellaneous Tasks

- Prevent creating new branches on Github

### [6.0.0] - 2024-04-19

#### 🚀 Features
Expand Down
47 changes: 47 additions & 0 deletions Packages/tlp.udonutils/Runtime/Physics/PhysicsUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using JetBrains.Annotations;
using UnityEngine;

namespace TLP.UdonUtils.Runtime.Physics
{
/// <summary>
/// Utilities to calculate velocities, accelerations etc.
/// </summary>
public static class PhysicsUtils
{
/// <summary>
/// Based on s(t) = 0.5 at² + v0t + s0 solved to a = 2(s(t) - v0t - s0) / t² with t != 0; v(t) = at + v0
///
/// <remarks>The accuracy of the results is HIGHLY dependent
/// on the correctness of the <see cref="initialVelocity"/>!
/// Using this function multiple times with the output velocity as input will eventually produce wrong results
/// due to floating point errors!!! If possible calculate the initial velocity differently.</remarks>
/// </summary>
/// <param name="firstPosition"></param>
/// <param name="secondPosition"></param>
/// <param name="initialVelocity">Velocity at <see cref="firstPosition"/></param>
/// <param name="deltaTime">Time elapsed while the position changed from
/// <see cref="firstPosition"/> to <see cref="secondPosition"/></param>
/// <param name="acceleration">result: calculated acceleration, is zero if t == 0</param>
/// <param name="velocity">calculated velocity based on calculated <see cref="acceleration"/>
/// at point <see cref="secondPosition"/></param>
[PublicAPI]
public static void CalculateAccelerationAndVelocity(
Vector3 firstPosition,
Vector3 secondPosition,
Vector3 initialVelocity,
float deltaTime,
out Vector3 acceleration,
out Vector3 velocity
) {
if (deltaTime == 0) {
acceleration = Vector3.zero; // technically it is infinity, but that is not usable
velocity = initialVelocity;
return;
}

acceleration = 2f * (secondPosition - initialVelocity * deltaTime - firstPosition) /
(deltaTime * deltaTime);
velocity = acceleration * deltaTime + initialVelocity;
}
}
}
3 changes: 3 additions & 0 deletions Packages/tlp.udonutils/Runtime/Physics/PhysicsUtils.cs.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
Expand Up @@ -24,6 +24,16 @@ public class DemoBlackListToggle : TlpBaseBehaviour
public PlayerBlackList PlayerBlackList;

public void OnEnable() {
if (!Utilities.IsValid(WhiteListButton)) {
ErrorAndDisableGameObject($"{nameof(WhiteListButton)} is not set");
return;
}

if (!Utilities.IsValid(BlackListButton)) {
ErrorAndDisableGameObject($"{nameof(BlackListButton)} is not set");
return;
}

WhiteListButton.gameObject.SetActive(PlayerBlackList.IsBlackListed(Networking.LocalPlayer.DisplayNameSafe()));
BlackListButton.gameObject.SetActive(PlayerBlackList.IsWhiteListed(Networking.LocalPlayer.DisplayNameSafe()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: TestGameTimeVsDeltaTime
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 2ca44091b1ff76846a13041f0c977bba,
serializedUdonProgramAsset: {fileID: 11400000, guid: 9c341850c7f1bdd4c9ae387ce71e6693,
type: 2}
udonAssembly:
assemblyError:
Expand Down
2 changes: 1 addition & 1 deletion Packages/tlp.udonutils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tlp.udonutils",
"displayName": "TLP UdonUtils",
"version": "6.0.0",
"version": "6.1.1",
"description": "Contains the base scripts/tools for TLP packages as well as prefabs and potentially helpful scripts for VRChat worlds.",
"gitDependencies": {},
"legacyFolders": {
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:

All notable changes to this project will be documented in this file.

### [6.1.1] - 2024-05-03

#### 🚀 Features

- *(Physics)* Add PhysicsUtils class with function CalculateAccelerationAndVelocity from positions

#### 🐛 Bug Fixes

- *(DemoBlackListToggle)* Add check for unset White-/Blacklist buttons

#### ⚙️ Miscellaneous Tasks

- Prevent creating new branches on Github

### [6.0.0] - 2024-04-19

#### 🚀 Features
Expand Down

0 comments on commit cb79b81

Please sign in to comment.