[Mono] Tabs -> Spaces

This commit is contained in:
Aaron Franke 2018-09-06 21:08:16 -04:00
parent 864a314340
commit 4743852466
3 changed files with 132 additions and 132 deletions

View File

@ -378,51 +378,51 @@ namespace Godot
); );
} }
public Quat Quat() { public Quat Quat() {
real_t trace = _x[0] + _y[1] + _z[2]; real_t trace = _x[0] + _y[1] + _z[2];
if (trace > 0.0f) { if (trace > 0.0f) {
real_t s = Mathf.Sqrt(trace + 1.0f) * 2f; real_t s = Mathf.Sqrt(trace + 1.0f) * 2f;
real_t inv_s = 1f / s; real_t inv_s = 1f / s;
return new Quat( return new Quat(
(_z[1] - _y[2]) * inv_s, (_z[1] - _y[2]) * inv_s,
(_x[2] - _z[0]) * inv_s, (_x[2] - _z[0]) * inv_s,
(_y[0] - _x[1]) * inv_s, (_y[0] - _x[1]) * inv_s,
s * 0.25f s * 0.25f
); );
} }
if (_x[0] > _y[1] && _x[0] > _z[2]) { if (_x[0] > _y[1] && _x[0] > _z[2]) {
real_t s = Mathf.Sqrt(_x[0] - _y[1] - _z[2] + 1.0f) * 2f; real_t s = Mathf.Sqrt(_x[0] - _y[1] - _z[2] + 1.0f) * 2f;
real_t inv_s = 1f / s; real_t inv_s = 1f / s;
return new Quat( return new Quat(
s * 0.25f, s * 0.25f,
(_x[1] + _y[0]) * inv_s, (_x[1] + _y[0]) * inv_s,
(_x[2] + _z[0]) * inv_s, (_x[2] + _z[0]) * inv_s,
(_z[1] - _y[2]) * inv_s (_z[1] - _y[2]) * inv_s
); );
} }
if (_y[1] > _z[2]) { if (_y[1] > _z[2]) {
real_t s = Mathf.Sqrt(-_x[0] + _y[1] - _z[2] + 1.0f) * 2f; real_t s = Mathf.Sqrt(-_x[0] + _y[1] - _z[2] + 1.0f) * 2f;
real_t inv_s = 1f / s; real_t inv_s = 1f / s;
return new Quat( return new Quat(
(_x[1] + _y[0]) * inv_s, (_x[1] + _y[0]) * inv_s,
s * 0.25f, s * 0.25f,
(_y[2] + _z[1]) * inv_s, (_y[2] + _z[1]) * inv_s,
(_x[2] - _z[0]) * inv_s (_x[2] - _z[0]) * inv_s
); );
} else { } else {
real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f; real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f;
real_t inv_s = 1f / s; real_t inv_s = 1f / s;
return new Quat( return new Quat(
(_x[2] + _z[0]) * inv_s, (_x[2] + _z[0]) * inv_s,
(_y[2] + _z[1]) * inv_s, (_y[2] + _z[1]) * inv_s,
s * 0.25f, s * 0.25f,
(_y[0] - _x[1]) * inv_s (_y[0] - _x[1]) * inv_s
); );
} }
} }
public Basis(Quat quat) public Basis(Quat quat)
{ {

View File

@ -4,22 +4,22 @@ using System.Threading;
namespace Godot namespace Godot
{ {
public class GodotSynchronizationContext : SynchronizationContext public class GodotSynchronizationContext : SynchronizationContext
{ {
private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>(); private readonly BlockingCollection<KeyValuePair<SendOrPostCallback, object>> queue = new BlockingCollection<KeyValuePair<SendOrPostCallback, object>>();
public override void Post(SendOrPostCallback d, object state) public override void Post(SendOrPostCallback d, object state)
{ {
queue.Add(new KeyValuePair<SendOrPostCallback, object>(d, state)); queue.Add(new KeyValuePair<SendOrPostCallback, object>(d, state));
} }
public void ExecutePendingContinuations() public void ExecutePendingContinuations()
{ {
KeyValuePair<SendOrPostCallback, object> workItem; KeyValuePair<SendOrPostCallback, object> workItem;
while (queue.TryTake(out workItem)) while (queue.TryTake(out workItem))
{ {
workItem.Key(workItem.Value); workItem.Key(workItem.Value);
} }
} }
} }
} }

View File

@ -6,89 +6,89 @@ using System.Threading.Tasks;
namespace Godot namespace Godot
{ {
public class GodotTaskScheduler : TaskScheduler public class GodotTaskScheduler : TaskScheduler
{ {
private GodotSynchronizationContext Context { get; set; } private GodotSynchronizationContext Context { get; set; }
private readonly LinkedList<Task> _tasks = new LinkedList<Task>(); private readonly LinkedList<Task> _tasks = new LinkedList<Task>();
public GodotTaskScheduler() public GodotTaskScheduler()
{ {
Context = new GodotSynchronizationContext(); Context = new GodotSynchronizationContext();
SynchronizationContext.SetSynchronizationContext(Context); SynchronizationContext.SetSynchronizationContext(Context);
} }
protected sealed override void QueueTask(Task task) protected sealed override void QueueTask(Task task)
{ {
lock (_tasks) lock (_tasks)
{ {
_tasks.AddLast(task); _tasks.AddLast(task);
} }
} }
protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) protected sealed override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
{ {
if (SynchronizationContext.Current != Context) if (SynchronizationContext.Current != Context)
{ {
return false; return false;
} }
if (taskWasPreviouslyQueued) if (taskWasPreviouslyQueued)
{ {
TryDequeue(task); TryDequeue(task);
} }
return TryExecuteTask(task); return TryExecuteTask(task);
} }
protected sealed override bool TryDequeue(Task task) protected sealed override bool TryDequeue(Task task)
{ {
lock (_tasks) lock (_tasks)
{ {
return _tasks.Remove(task); return _tasks.Remove(task);
} }
} }
protected sealed override IEnumerable<Task> GetScheduledTasks() protected sealed override IEnumerable<Task> GetScheduledTasks()
{ {
lock (_tasks) lock (_tasks)
{ {
return _tasks.ToArray(); return _tasks.ToArray();
} }
} }
public void Activate() public void Activate()
{ {
ExecuteQueuedTasks(); ExecuteQueuedTasks();
Context.ExecutePendingContinuations(); Context.ExecutePendingContinuations();
} }
private void ExecuteQueuedTasks() private void ExecuteQueuedTasks()
{ {
while (true) while (true)
{ {
Task task; Task task;
lock (_tasks) lock (_tasks)
{ {
if (_tasks.Any()) if (_tasks.Any())
{ {
task = _tasks.First.Value; task = _tasks.First.Value;
_tasks.RemoveFirst(); _tasks.RemoveFirst();
} }
else else
{ {
break; break;
} }
} }
if (task != null) if (task != null)
{ {
if (!TryExecuteTask(task)) if (!TryExecuteTask(task))
{ {
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
} }
} }
} }
} }
} }