Skip to content

Commit

Permalink
Updates from internal projects prior to release
Browse files Browse the repository at this point in the history
Yup. 0.4 is releasing real soon!

A lot of the new stuff was developed against non-public projects, hence a few things in this commit like the new Psyshock stuff and bug fixes seem to come out of nowhere.

I did make a last-minute update to the Rng though. Thanks to a helpful soul in the comments of the GDC video, I learned that on Twitter there was a new version of the noise function. Even better, it came with a proper license! I can sleep better at night now.

Builds are primed. Docs are written. I am working on the Optimization Adventure as I type this, and once that is done, I just have to get the final touches in place and publish. This is by far the most relaxed I have been for a feature release. Feels nice!
  • Loading branch information
Dreaming381 committed Aug 7, 2021
1 parent aaf377a commit 5547e8a
Show file tree
Hide file tree
Showing 52 changed files with 444 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Assets/BuildProfiles/BaseBuildConfig.buildconfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"$type": "Unity.Build.Common.GeneralSettings, Unity.Build",
"ProductName": "LsssBuild",
"CompanyName": "Dreaming381",
"Version": "0.3.1.0"
"Version": "0.4.0.0"
},
{
"$type": "Unity.Build.Common.SceneList, Unity.Build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct AiRng : IComponentData

protected override void OnUpdate()
{
var rng = sceneBlackboardEntity.GetComponentData<AiRng>().rng.Update();
var rng = sceneBlackboardEntity.GetComponentData<AiRng>().rng.Shuffle();
sceneBlackboardEntity.SetComponentData(new AiRng { rng = rng });

var ecb = latiosWorld.syncPoint.CreateEntityCommandBuffer();
Expand Down
2 changes: 1 addition & 1 deletion Assets/_Code/SubSystems/AI/AiExploreSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct AiRng : IComponentData
protected override void OnUpdate()
{
float arenaRadius = sceneBlackboardEntity.GetComponentData<ArenaRadius>().radius;
var rng = sceneBlackboardEntity.GetComponentData<AiRng>().rng.Update();
var rng = sceneBlackboardEntity.GetComponentData<AiRng>().rng.Shuffle();
sceneBlackboardEntity.SetComponentData(new AiRng { rng = rng });

Entities.WithAll<AiTag>().ForEach((int entityInQueryIndex, ref AiExploreOutput output, ref AiExploreState state, in AiExplorePersonality personality,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct AiRng : IComponentData

protected override void OnUpdate()
{
var rng = sceneBlackboardEntity.GetComponentData<AiRng>().rng.Update();
var rng = sceneBlackboardEntity.GetComponentData<AiRng>().rng.Shuffle();
sceneBlackboardEntity.SetComponentData(new AiRng { rng = rng });

var ecb = latiosWorld.syncPoint.CreateEntityCommandBuffer();
Expand Down
2 changes: 1 addition & 1 deletion Assets/_Code/SubSystems/AI/AiShipRadarScanSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private JobHandle BuildRadarLayer(FactionMember factionMember, out CollisionLaye
if (radar.cosFov < 0f)
{
//Todo: Create tighter bounds here too.
aabbs[entityInQueryIndex] = Physics.CalculateAabb(sphere, transform);
aabbs[entityInQueryIndex] = Physics.AabbFrom(sphere, transform);
}
else
{
Expand Down
35 changes: 10 additions & 25 deletions Assets/_Code/SubSystems/Gameplay/MoveShipsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Latios;
using Latios.Psyshock;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
Expand Down Expand Up @@ -38,31 +39,15 @@ protected override void OnUpdate()
bool isBoosting = desiredActions.boost && boostTank.boost > 0f;
bool isReverse = speed.speed < 0f;

float gas = math.saturate(desiredActions.gas);
float maxSpeed = math.select(stats.topSpeed, stats.boostSpeed, isBoosting) * gas;
float maxAccel = math.select(stats.acceleration, stats.boostAcceleration, isBoosting);
float accel = gas * maxAccel;
accel = math.select(accel, -stats.deceleration * 0.5f, speed.speed > maxSpeed);
float decel = math.saturate(-desiredActions.gas) * -stats.deceleration * 0.5f;
float a = accel + decel;
float forwardSpeed = speed.speed + a * dt;
forwardSpeed = math.select(forwardSpeed, math.min(forwardSpeed, maxSpeed), a >= 0f);
forwardSpeed = math.select(forwardSpeed, math.max(forwardSpeed, maxSpeed), a < 0f);

gas = math.saturate(-desiredActions.gas);
maxSpeed = stats.reverseSpeed * gas;
accel = gas * stats.acceleration;
accel = math.select(accel, -stats.deceleration * 0.5f, -speed.speed > maxSpeed);
decel = math.saturate(desiredActions.gas) * -stats.deceleration * 0.5f;
a = accel + decel;
float backwardSpeed = speed.speed - a * dt;
backwardSpeed = math.select(backwardSpeed, math.max(backwardSpeed, -maxSpeed), a >= 0f);
backwardSpeed = math.select(backwardSpeed, math.min(backwardSpeed, -maxSpeed), a < 0f);

bool useBackward = speed.speed < 0f;
useBackward |= speed.speed == 0f && desiredActions.gas < 0f;

speed.speed = math.select(forwardSpeed, backwardSpeed, useBackward);
speed.speed = Physics.StepVelocityWithInput(desiredActions.gas,
speed.speed,
math.select(stats.acceleration, stats.boostAcceleration, isBoosting),
stats.deceleration,
math.select(stats.topSpeed, stats.boostSpeed, isBoosting),
stats.acceleration,
stats.deceleration,
stats.reverseSpeed,
dt);

//Translation
translation.Value += math.forward(newRotation) * speed.speed * dt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void Execute(FindPairsResult result)
{
if (Physics.DistanceBetween(result.bodyA.collider, result.bodyA.transform, result.bodyB.collider, result.bodyB.transform, 0f, out _))
{
var aabb = Physics.CalculateAabb(result.bodyB.collider, RigidTransform.identity);
var aabb = Physics.AabbFrom((CompoundCollider)result.bodyB.collider, RigidTransform.identity);
float forwardOffset = -aabb.min.z * 2; //Distance to butt doubled for safety

var destEntity = destCDFE[result.entityA].wormholeDestination;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public static float3 RotateExtents(float3 extents, float3x3 rotationMatrix)
return RotateExtents(extents, rotationMatrix.c0, rotationMatrix.c1, rotationMatrix.c2);
}

public static float2 ComplexMul(float2 a, float2 b)
{
return new float2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
}

#endregion Transformations

#region NumberTricks
Expand Down
24 changes: 16 additions & 8 deletions Packages/com.latios.latios-framework/Core/Core/Math/Rng.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public Rng(string seedString)
m_state = math.asuint(seedString.GetHashCode());
}

public Rng Update()
public Rng Shuffle()
{
var sequence = new RngSequence(new uint2(m_state, math.asuint(int.MinValue)));
m_state = sequence.NextUInt();
Expand All @@ -40,13 +40,20 @@ public RngSequence(uint2 initialState)
uint NextState()
{
//From https://www.youtube.com/watch?v=LWFzPP8ZbdU
var val = m_state.x * 0x68e31da4;
val *= m_state.y;
val ^= (val >> 8);
val += 0xb5297a4d;
val ^= (val << 8);
val *= 0x1b56c4e9;
val ^= (val >> 8);
//This version is SquirrelNoise5, which was posted on the author's Twitter: https://twitter.com/SquirrelTweets/status/1421251894274625536.
// This is a Unity C# adaptation of SquirrelNoise5 - Squirrel's Raw Noise utilities (version 5).
// The following code within this scope is licensed by Squirrel Eiserloh under the Creative Commons Attribution 3.0 license (CC-BY-3.0 US).
var val = m_state.x * 0xd2a80a3f;
val += m_state.y;
val ^= (val >> 9);
val += 0xa884f197;
val ^= (val >> 11);
val *= 0x6c736f4b;
val ^= (val >> 13);
val += 0xb79f3abb;
val ^= (val >> 15);
val += 0x1b56c4f5;
val ^= (val >> 17);
m_state.x = val;
return val;
}
Expand Down Expand Up @@ -85,6 +92,7 @@ uint NextState()

public float2 NextFloat2Direction() => RngToolkit.AsFloat2Direction(NextState());
public float3 NextFloat3Direction() => RngToolkit.AsFloat3Direction(NextUInt2());
public quaternion NextQuaternionRotation() => RngToolkit.AsQuaternionRotation(NextUInt3());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void Execute(int i)
var t = transforms[j + range.x];
blobColliders[j] = c;
blobTransforms[j] = t;
var newbox = Physics.CalculateAabb(c, t);
var newbox = Physics.AabbFrom(c, t);
aabb.min = math.min(aabb.min, newbox.min);
aabb.max = math.max(aabb.max, newbox.max);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5547e8a

Please sign in to comment.