Skip to content

Commit

Permalink
improved error handling around pose camera updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuki-Codes committed Nov 27, 2021
1 parent 1a20f5d commit dff468a
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions Anamnesis/Posing/Views/Pose3DView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Anamnesis.PoseModule.Views
using System.Windows.Media.Media3D;
using Anamnesis.Posing.Visuals;
using PropertyChanged;
using Serilog;
using XivToolsWpf;
using Colors = System.Windows.Media.Colors;

Expand Down Expand Up @@ -177,23 +178,30 @@ private async Task UpdateCamera()
await Task.Delay(33);
await Dispatch.MainThread();

if (this.Skeleton == null || CameraService.Instance.Camera == null)
try
{
if (this.Skeleton == null || CameraService.Instance.Camera == null)
continue;

this.Skeleton.ReadTranforms();
this.Skeleton.ReadTranforms();

// TODO: allow the user to rotate camera with the mouse instead
this.CameraRotation = CameraService.Instance.Camera.Rotation3d;
// TODO: allow the user to rotate camera with the mouse instead
this.CameraRotation = CameraService.Instance.Camera.Rotation3d;

// Apply camera rotation
QuaternionRotation3D rot = (QuaternionRotation3D)this.CameraRotaion.Rotation;
rot.Quaternion = this.CameraRotation;
this.CameraRotaion.Rotation = rot;
// Apply camera rotation
QuaternionRotation3D rot = (QuaternionRotation3D)this.CameraRotaion.Rotation;
rot.Quaternion = this.CameraRotation;
this.CameraRotaion.Rotation = rot;

// Apply camera position
Point3D pos = this.Camera.Position;
pos.Z = -this.CameraDistance;
this.Camera.Position = pos;
// Apply camera position
Point3D pos = this.Camera.Position;
pos.Z = -this.CameraDistance;
this.Camera.Position = pos;
}
catch (Exception ex)
{
Log.Error(ex, "Failed to update pose camera");
}
}

this.cameraIsTicking = false;
Expand Down

0 comments on commit dff468a

Please sign in to comment.