Update Drone.cs
This commit is contained in:
@ -41,6 +41,7 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
private Vector2 MoveOF = Vector2.Zero;
|
private Vector2 MoveOF = Vector2.Zero;
|
||||||
private uint CountOF = 0;
|
private uint CountOF = 0;
|
||||||
|
private bool ReadyOF = false;
|
||||||
|
|
||||||
public struct Physics
|
public struct Physics
|
||||||
{
|
{
|
||||||
@ -296,7 +297,7 @@ namespace DroneSimulator
|
|||||||
Quat = Quaternion.Identity;
|
Quat = Quaternion.Identity;
|
||||||
}
|
}
|
||||||
else */
|
else */
|
||||||
Rotate(SpdPRY.X * time, SpdPRY.Y * time, SpdPRY.Z * time);
|
Rotate(SpdPRY.X * time, SpdPRY.Y * time, SpdPRY.Z * time);
|
||||||
|
|
||||||
Vector4 ori = GetOrientation();
|
Vector4 ori = GetOrientation();
|
||||||
|
|
||||||
@ -363,10 +364,12 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
bool of = RealOF.Update(of_xy, LaserRange, tick);
|
bool of = RealOF.Update(of_xy, LaserRange, tick);
|
||||||
|
|
||||||
if(of) lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
MoveOF += RealOF.result;
|
MoveOF += RealOF.result;
|
||||||
CountOF += 1;
|
CountOF += 1;
|
||||||
|
|
||||||
|
if (of) ReadyOF = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +533,7 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
if (CountOF != 0)
|
if (ReadyOF && CountOF != 0)
|
||||||
{
|
{
|
||||||
of.X = MoveOF.X / CountOF;
|
of.X = MoveOF.X / CountOF;
|
||||||
of.Y = MoveOF.Y / CountOF;
|
of.Y = MoveOF.Y / CountOF;
|
||||||
@ -545,6 +548,7 @@ namespace DroneSimulator
|
|||||||
|
|
||||||
MoveOF = Vector2.Zero;
|
MoveOF = Vector2.Zero;
|
||||||
CountOF = 0;
|
CountOF = 0;
|
||||||
|
ReadyOF = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getBytes(of);
|
return getBytes(of);
|
||||||
|
Reference in New Issue
Block a user