Skip to content

Commit cb79b81

Browse files
author
Release Automat
committed
Release 6.1.1
1 parent e06d16f commit cb79b81

File tree

7 files changed

+90
-2
lines changed

7 files changed

+90
-2
lines changed

Packages/tlp.udonutils/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:
3030

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

33+
### [6.1.1] - 2024-05-03
34+
35+
#### 🚀 Features
36+
37+
- *(Physics)* Add PhysicsUtils class with function CalculateAccelerationAndVelocity from positions
38+
39+
#### 🐛 Bug Fixes
40+
41+
- *(DemoBlackListToggle)* Add check for unset White-/Blacklist buttons
42+
43+
#### ⚙️ Miscellaneous Tasks
44+
45+
- Prevent creating new branches on Github
46+
3347
### [6.0.0] - 2024-04-19
3448

3549
#### 🚀 Features
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using JetBrains.Annotations;
2+
using UnityEngine;
3+
4+
namespace TLP.UdonUtils.Runtime.Physics
5+
{
6+
/// <summary>
7+
/// Utilities to calculate velocities, accelerations etc.
8+
/// </summary>
9+
public static class PhysicsUtils
10+
{
11+
/// <summary>
12+
/// 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
13+
///
14+
/// <remarks>The accuracy of the results is HIGHLY dependent
15+
/// on the correctness of the <see cref="initialVelocity"/>!
16+
/// Using this function multiple times with the output velocity as input will eventually produce wrong results
17+
/// due to floating point errors!!! If possible calculate the initial velocity differently.</remarks>
18+
/// </summary>
19+
/// <param name="firstPosition"></param>
20+
/// <param name="secondPosition"></param>
21+
/// <param name="initialVelocity">Velocity at <see cref="firstPosition"/></param>
22+
/// <param name="deltaTime">Time elapsed while the position changed from
23+
/// <see cref="firstPosition"/> to <see cref="secondPosition"/></param>
24+
/// <param name="acceleration">result: calculated acceleration, is zero if t == 0</param>
25+
/// <param name="velocity">calculated velocity based on calculated <see cref="acceleration"/>
26+
/// at point <see cref="secondPosition"/></param>
27+
[PublicAPI]
28+
public static void CalculateAccelerationAndVelocity(
29+
Vector3 firstPosition,
30+
Vector3 secondPosition,
31+
Vector3 initialVelocity,
32+
float deltaTime,
33+
out Vector3 acceleration,
34+
out Vector3 velocity
35+
) {
36+
if (deltaTime == 0) {
37+
acceleration = Vector3.zero; // technically it is infinity, but that is not usable
38+
velocity = initialVelocity;
39+
return;
40+
}
41+
42+
acceleration = 2f * (secondPosition - initialVelocity * deltaTime - firstPosition) /
43+
(deltaTime * deltaTime);
44+
velocity = acceleration * deltaTime + initialVelocity;
45+
}
46+
}
47+
}

Packages/tlp.udonutils/Runtime/Physics/PhysicsUtils.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Packages/tlp.udonutils/Runtime/Scenes/Examples/BlackListing/DemoBlackListToggle.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ public class DemoBlackListToggle : TlpBaseBehaviour
2424
public PlayerBlackList PlayerBlackList;
2525

2626
public void OnEnable() {
27+
if (!Utilities.IsValid(WhiteListButton)) {
28+
ErrorAndDisableGameObject($"{nameof(WhiteListButton)} is not set");
29+
return;
30+
}
31+
32+
if (!Utilities.IsValid(BlackListButton)) {
33+
ErrorAndDisableGameObject($"{nameof(BlackListButton)} is not set");
34+
return;
35+
}
36+
2737
WhiteListButton.gameObject.SetActive(PlayerBlackList.IsBlackListed(Networking.LocalPlayer.DisplayNameSafe()));
2838
BlackListButton.gameObject.SetActive(PlayerBlackList.IsWhiteListed(Networking.LocalPlayer.DisplayNameSafe()));
2939
}

Packages/tlp.udonutils/Runtime/Testing/Prefabs/TestGameTimeVsDeltaTime/TestGameTimeVsDeltaTime.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MonoBehaviour:
1212
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
1313
m_Name: TestGameTimeVsDeltaTime
1414
m_EditorClassIdentifier:
15-
serializedUdonProgramAsset: {fileID: 11400000, guid: 2ca44091b1ff76846a13041f0c977bba,
15+
serializedUdonProgramAsset: {fileID: 11400000, guid: 9c341850c7f1bdd4c9ae387ce71e6693,
1616
type: 2}
1717
udonAssembly:
1818
assemblyError:

Packages/tlp.udonutils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tlp.udonutils",
33
"displayName": "TLP UdonUtils",
4-
"version": "6.0.0",
4+
"version": "6.1.1",
55
"description": "Contains the base scripts/tools for TLP packages as well as prefabs and potentially helpful scripts for VRChat worlds.",
66
"gitDependencies": {},
77
"legacyFolders": {

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ The used pattern MAJOR.MINOR.PATCH indicates:
3030

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

33+
### [6.1.1] - 2024-05-03
34+
35+
#### 🚀 Features
36+
37+
- *(Physics)* Add PhysicsUtils class with function CalculateAccelerationAndVelocity from positions
38+
39+
#### 🐛 Bug Fixes
40+
41+
- *(DemoBlackListToggle)* Add check for unset White-/Blacklist buttons
42+
43+
#### ⚙️ Miscellaneous Tasks
44+
45+
- Prevent creating new branches on Github
46+
3347
### [6.0.0] - 2024-04-19
3448

3549
#### 🚀 Features

0 commit comments

Comments
 (0)