Update RealMode.cs
This commit is contained in:
@ -162,6 +162,24 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
public void Update(Vector3 value, uint time)
|
public void Update(Vector3 value, uint time)
|
||||||
{
|
{
|
||||||
|
Vector3 v = value;
|
||||||
|
|
||||||
|
int noise = (int)(Noise * 1000);
|
||||||
|
v.X += ((float)rand.Next(-noise, noise)) / 1000;
|
||||||
|
v.Y += ((float)rand.Next(-noise, noise)) / 1000;
|
||||||
|
v.Z += ((float)rand.Next(-noise, noise)) / 1000;
|
||||||
|
|
||||||
|
uint clock = (uint)(Lateness * 1000);
|
||||||
|
|
||||||
|
uint tick = time - last;
|
||||||
|
last = time;
|
||||||
|
while (tick != 0)
|
||||||
|
{
|
||||||
|
tick--;
|
||||||
|
laten[index++] = v;
|
||||||
|
if (index >= clock) index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Enable)
|
if (!Enable)
|
||||||
{
|
{
|
||||||
result = Vector3.NaN;
|
result = Vector3.NaN;
|
||||||
@ -176,29 +194,12 @@ namespace DroneSimulator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int noise = (int)(Noise * 1000);
|
v = laten[index];
|
||||||
value.X += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Y += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Z += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
uint freq = 1000 / Freq;
|
||||||
|
|
||||||
if (timer + freq <= time)
|
if (timer + freq <= time)
|
||||||
{
|
{
|
||||||
result = value;
|
result = v;
|
||||||
timer = time;
|
timer = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,9 +228,24 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
public void Update(float value, uint time)
|
public void Update(float value, uint time)
|
||||||
{
|
{
|
||||||
//value = Pressure - value * 12.15f;
|
|
||||||
value = Pressure * MathF.Exp(-0.02896f * 9.81f * value / (8.314f * (Temperature + 273.15f)));
|
value = Pressure * MathF.Exp(-0.02896f * 9.81f * value / (8.314f * (Temperature + 273.15f)));
|
||||||
|
|
||||||
|
float v = value;
|
||||||
|
|
||||||
|
int noise = (int)(Noise * 1000);
|
||||||
|
v += ((float)rand.Next(-noise, noise)) / 1000;
|
||||||
|
|
||||||
|
uint clock = (uint)(Lateness * 1000);
|
||||||
|
|
||||||
|
uint tick = time - last;
|
||||||
|
last = time;
|
||||||
|
while (tick != 0)
|
||||||
|
{
|
||||||
|
tick--;
|
||||||
|
laten[index++] = v;
|
||||||
|
if (index >= clock) index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Enable)
|
if (!Enable)
|
||||||
{
|
{
|
||||||
result = float.NaN;
|
result = float.NaN;
|
||||||
@ -241,30 +257,15 @@ namespace DroneSimulator
|
|||||||
{
|
{
|
||||||
result = value;
|
result = value;
|
||||||
timer = time;
|
timer = time;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int noise = (int)(Noise * 1000);
|
v = laten[index];
|
||||||
value += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
uint freq = 1000 / Freq;
|
||||||
|
|
||||||
if (timer + freq <= time)
|
if (timer + freq <= time)
|
||||||
{
|
{
|
||||||
result = value;
|
result = v;
|
||||||
timer = time;
|
timer = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,6 +297,27 @@ namespace DroneSimulator
|
|||||||
{
|
{
|
||||||
value *= Lens;
|
value *= Lens;
|
||||||
|
|
||||||
|
Vector2 v = value;
|
||||||
|
|
||||||
|
if (Range > MaxHeight) v = Vector2.Zero;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int noise = (int)(Noise * 1000);
|
||||||
|
v.X += ((float)rand.Next(-noise, noise)) / 1000;
|
||||||
|
v.Y += ((float)rand.Next(-noise, noise)) / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint clock = (uint)(Lateness * 1000);
|
||||||
|
|
||||||
|
uint tick = time - last;
|
||||||
|
last = time;
|
||||||
|
while (tick != 0)
|
||||||
|
{
|
||||||
|
tick--;
|
||||||
|
laten[index++] = v;
|
||||||
|
if (index >= clock) index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Enable)
|
if (!Enable)
|
||||||
{
|
{
|
||||||
result = Vector2.NaN;
|
result = Vector2.NaN;
|
||||||
@ -310,32 +332,12 @@ namespace DroneSimulator
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Range > MaxHeight) value = Vector2.Zero;
|
v = laten[index];
|
||||||
else
|
|
||||||
{
|
|
||||||
int noise = (int)(Noise * 1000);
|
|
||||||
value.X += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
value.Y += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
uint freq = 1000 / Freq;
|
||||||
|
|
||||||
if (timer + freq <= time)
|
if (timer + freq <= time)
|
||||||
{
|
{
|
||||||
result = value;
|
result = v;
|
||||||
timer = time;
|
timer = time;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -366,6 +368,26 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
public void Update(float value, uint time)
|
public void Update(float value, uint time)
|
||||||
{
|
{
|
||||||
|
float v = value;
|
||||||
|
|
||||||
|
if (v > MaxHeight) v = -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int noise = (int)(Noise * 1000);
|
||||||
|
v += ((float)rand.Next(-noise, noise)) / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint clock = (uint)(Lateness * 1000);
|
||||||
|
|
||||||
|
uint tick = time - last;
|
||||||
|
last = time;
|
||||||
|
while (tick != 0)
|
||||||
|
{
|
||||||
|
tick--;
|
||||||
|
laten[index++] = v;
|
||||||
|
if (index >= clock) index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Enable)
|
if (!Enable)
|
||||||
{
|
{
|
||||||
result = float.NaN;
|
result = float.NaN;
|
||||||
@ -380,31 +402,12 @@ namespace DroneSimulator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value > MaxHeight) value = -1;
|
v = laten[index];
|
||||||
else
|
|
||||||
{
|
|
||||||
int noise = (int)(Noise * 1000);
|
|
||||||
value += ((float)rand.Next(-noise, noise)) / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint clock = (uint)(Lateness * 1000);
|
|
||||||
|
|
||||||
uint tick = time - last;
|
|
||||||
last = time;
|
|
||||||
while (tick != 0)
|
|
||||||
{
|
|
||||||
tick--;
|
|
||||||
laten[index++] = value;
|
|
||||||
if (index >= clock) index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = laten[index];
|
|
||||||
|
|
||||||
uint freq = 1000 / Freq;
|
uint freq = 1000 / Freq;
|
||||||
|
|
||||||
if (timer + freq <= time)
|
if (timer + freq <= time)
|
||||||
{
|
{
|
||||||
result = value;
|
result = v;
|
||||||
timer = time;
|
timer = time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user