Skip to content

Commit

Permalink
- Fixed issue with world space path coordinates vs local space path c…
Browse files Browse the repository at this point in the history
…oordinates

- Improved performance of Okapi UI elements significatly
  • Loading branch information
DiogoDeAndrade committed Feb 3, 2024
1 parent d19b272 commit 7046fe8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Assets/OkapiKit/Data/MasterConfig.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ MonoBehaviour:
m_Name: MasterConfig
m_EditorClassIdentifier:
maxPingTime: 4
displayConditions: 1
displayHypertags: 1
8 changes: 6 additions & 2 deletions Assets/OkapiKit/Scripts/Base/OkapiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,19 @@ public static bool IsPinged(OkapiElement element)
public static bool showTags => (instance) ? (instance.displayHypertags) : (false);
public static bool showConditions => (instance) ? (instance.displayConditions) : (false);

static OkapiConfig _instance = null;

static OkapiConfig instance {
get {
if (_instance) return _instance;

var allConfigs = FindAllInstances<OkapiConfig>();
if (allConfigs.Count == 1)
{
return allConfigs[0];
_instance = allConfigs[0];
}

return null;
return _instance;
}
}

Expand Down
4 changes: 4 additions & 0 deletions Assets/OkapiKit/Scripts/Systems/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ private static Vector3 EvaluateCatmullRomDerivative(Vector3 p0, Vector3 p1, Vect

public Vector2 EvaluateWorld(float t)
{
if (worldSpace) return EvaluateLocal(t);

return transform.TransformPoint(EvaluateLocal(t));
}

Expand Down Expand Up @@ -211,6 +213,8 @@ public Vector2 EvaluateLocal(float t)

public Vector2 EvaluateWorldDir(float t)
{
if (worldSpace) return EvaluateLocalDir(t);

return transform.TransformVector(EvaluateLocalDir(t));
}

Expand Down
15 changes: 4 additions & 11 deletions Assets/OkapiKit/Scripts/Systems/Spawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,30 +497,23 @@ public int GetSpawnPointCount()
}

void GetWorldDirUp(Path path, float t, ref Vector2 dir, ref Vector2 up)
{
GetLocalDirUp(path, t, ref dir, ref up);
dir = path.transform.TransformVector(dir);
up = path.transform.TransformVector(up);
}

void GetLocalDirUp(Path path, float t, ref Vector2 dir, ref Vector2 up)
{
switch (spawnRotation)
{
case SpawnRotation.AlignWithDirection:
dir = path.EvaluateLocalDir(t);
dir = path.EvaluateWorldDir(t);
up = new Vector2(dir.y, -dir.x);
break;
case SpawnRotation.AlignWithInverseDirection:
dir = -path.EvaluateLocalDir(t);
dir = -path.EvaluateWorldDir(t);
up = new Vector2(dir.y, -dir.x);
break;
case SpawnRotation.AlignWithPerpendicular:
up = path.EvaluateLocalDir(t);
up = path.EvaluateWorldDir(t);
dir = new Vector2(up.y, -up.x);
break;
case SpawnRotation.AlignWithInversePerpendicular:
up = path.EvaluateLocalDir(t);
up = path.EvaluateWorldDir(t);
dir = new Vector2(-up.y, up.x);
break;
default:
Expand Down
5 changes: 5 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes

## V1.10.1

- Fixed issue with world space path coordinates vs local space path coordinates
- Improved performance of Okapi UI elements significatly

## V1.10.0

- Added circle, arc and polygon path
Expand Down

0 comments on commit 7046fe8

Please sign in to comment.