First Flight Polish
FIX: Gravity waves weren't lining up properly between the GPU and CPU implementations Inventory menu wasn't highlighting rotated items correctly
This commit is contained in:
parent
c4be204cd0
commit
1df7f1bc67
15 changed files with 500 additions and 78 deletions
|
|
@ -176,12 +176,12 @@ public class SectorRenderer : MonoBehaviour
|
|||
{
|
||||
var shipInstance = new ShipInstance();
|
||||
shipInstance.Ship = ship;
|
||||
shipInstance.Transform = Instantiate(UnityHelpers.LoadAsset<GameObject>(hullData.Prefab)).transform;
|
||||
shipInstance.Transform = Instantiate(UnityHelpers.LoadAsset<GameObject>(hullData.Prefab), ZoneRoot).transform;
|
||||
shipInstance.Thrusters = ship.GetBehaviors<Thruster>().ToArray();
|
||||
shipInstance.ThrusterParticles = shipInstance.Thrusters
|
||||
.Select(x =>
|
||||
{
|
||||
var particles = Instantiate(UnityHelpers.LoadAsset<ParticleSystem>(((ThrusterData) x.Data).ParticlesPrefab));
|
||||
var particles = Instantiate(UnityHelpers.LoadAsset<ParticleSystem>(((ThrusterData) x.Data).ParticlesPrefab), shipInstance.Transform, false);
|
||||
var particlesShape = particles.shape;
|
||||
particlesShape.meshRenderer = shipInstance.Transform.Find(x.Entity.Hardpoints[x.Item.Position.x, x.Item.Position.y].Transform)
|
||||
.GetComponent<MeshRenderer>();
|
||||
|
|
@ -359,7 +359,7 @@ public class SectorRenderer : MonoBehaviour
|
|||
planet.Value.Body.transform.localPosition = new Vector3(0, _zone.GetHeight(p) + planetInstance.BodyRadius.Value * 2, 0);
|
||||
if(planet.Value is GasGiantObject gasGiantObject)
|
||||
{
|
||||
gasGiantObject.GravityWaves.material.SetFloat("_Phase", Time * Settings.PlanetSettings.WaveSpeed.Evaluate(planetInstance.BodyData.Mass.Value));
|
||||
gasGiantObject.GravityWaves.material.SetFloat("_Phase", Time * ((GasGiant) _zone.PlanetInstances[planet.Key]).GravityWavesSpeed.Value);
|
||||
if(!(planet.Value is SunObject))
|
||||
{
|
||||
var toParent = normalize(_zone.GetOrbitPosition(_zone.Orbits[planetInstance.BodyData.Orbit].Data.Parent) - p);
|
||||
|
|
@ -375,6 +375,8 @@ public class SectorRenderer : MonoBehaviour
|
|||
var h = _zone.GetHeight(ship.Key.Position);
|
||||
ship.Value.Transform.position = new Vector3(ship.Key.Position.x,h + hullData.GridOffset,ship.Key.Position.y);
|
||||
var normal = _zone.GetNormal(ship.Key.Position);
|
||||
var f = new float2(normal.x, normal.z);
|
||||
ship.Key.Velocity += f * Settings.PlanetSettings.GravityStrength;// * lengthsq(f);
|
||||
//Debug.Log($"Normal: {normal}");
|
||||
var shipRight = ship.Key.Direction.Rotate(ItemRotation.Clockwise);
|
||||
var forward = Vector3.Cross(new Vector3(shipRight.x,0,shipRight.y), normal);
|
||||
|
|
|
|||
|
|
@ -272,23 +272,23 @@ public class Zone
|
|||
foreach (var body in PlanetInstances.Values)
|
||||
{
|
||||
var p = (position - body.Orbit.Position); //GetOrbitPosition(body.BodyData.Orbit)
|
||||
var dist = lengthsq(p);
|
||||
var distSqr = lengthsq(p);
|
||||
var gravityRadius = body.GravityWellRadius.Value;
|
||||
if (dist < gravityRadius*gravityRadius)
|
||||
if (distSqr < gravityRadius*gravityRadius)
|
||||
{
|
||||
var depth = body.GravityWellDepth.Value;
|
||||
result -= PowerPulse(sqrt(dist) / gravityRadius, body.BodyData.GravityDepthExponent.Value) * depth;
|
||||
result -= PowerPulse(sqrt(distSqr) / gravityRadius, body.BodyData.GravityDepthExponent.Value) * depth;
|
||||
}
|
||||
|
||||
if (body is GasGiant gas)
|
||||
{
|
||||
var waveRadius = gas.GravityWavesRadius.Value;
|
||||
if(dist < waveRadius*waveRadius)
|
||||
if(distSqr < waveRadius*waveRadius)
|
||||
{
|
||||
var depth = gas.GravityWavesDepth.Value;
|
||||
var frequency = _settings.WaveFrequency.Evaluate(body.BodyData.Mass.Value);
|
||||
var speed = _settings.WaveSpeed.Evaluate(body.BodyData.Mass.Value);
|
||||
result -= RadialWaves(sqrt(dist) / waveRadius, 8, 1.5f, frequency, _time * speed) * depth;
|
||||
var speed = gas.GravityWavesSpeed.Value;
|
||||
result -= RadialWaves(sqrt(distSqr) / waveRadius, 8, 1.25f, frequency, _time * speed) * depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -312,8 +312,8 @@ public class Zone
|
|||
|
||||
public static float RadialWaves(float x, float maskExponent, float sineExponent, float frequency, float phase)
|
||||
{
|
||||
x *= 2;
|
||||
return PowerPulse(x, maskExponent) * cos(pow(x, sineExponent) * frequency + phase);
|
||||
//x *= 2;
|
||||
return PowerPulse(x, maskExponent) * cos(pow(x*2, sineExponent) * frequency + phase);
|
||||
}
|
||||
|
||||
public float3 GetNormal(float2 pos, float step = .1f, float mul = 1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue