diff --git a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs index 3f9aac2cb9a..c7df3151789 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs @@ -220,10 +220,7 @@ public DynamoPreferencesData DynamoPreferences /// of Graph.Json. /// [JsonProperty("Camera")] - public CameraData Camera - { - get { return DynamoViewModel.BackgroundPreviewViewModel.GetCameraInformation(); } - } + public CameraData Camera => DynamoViewModel.BackgroundPreviewViewModel.GetCameraInformation() ?? new CameraData(); /// /// ViewModel that is used in InCanvasSearch in context menu and called by Shift+DoubleClick. diff --git a/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs b/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs index e3fa862c1bd..2bc5dd8978b 100644 --- a/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs @@ -95,6 +95,25 @@ public CameraData() UpY = defaultCameraUpDirection.Y; UpZ = defaultCameraUpDirection.Z; } + + public override bool Equals(object obj) + { + var other = obj as CameraData; + return obj is CameraData && this.Name == other.Name + && Math.Abs(this.EyeX - other.EyeX) < 0.0001 + && Math.Abs(this.EyeY - other.EyeY) < 0.0001 + && Math.Abs(this.EyeZ - other.EyeZ) < 0.0001 + && Math.Abs(this.LookX - other.LookX) < 0.0001 + && Math.Abs(this.LookY - other.LookY) < 0.0001 + && Math.Abs(this.LookZ - other.LookZ) < 0.0001 + && Math.Abs(this.UpX - other.UpX) < 0.0001 + && Math.Abs(this.UpY - other.UpY) < 0.0001 + && Math.Abs(this.UpZ - other.UpZ) < 0.0001 + && Math.Abs(this.NearPlaneDistance - other.NearPlaneDistance) < 0.0001 + && Math.Abs(this.FarPlaneDistance - other.FarPlaneDistance) < 0.0001; + } + + } /// diff --git a/test/DynamoCoreWpfTests/SerializationTests.cs b/test/DynamoCoreWpfTests/SerializationTests.cs index 41bccd28010..c3a82e6597b 100644 --- a/test/DynamoCoreWpfTests/SerializationTests.cs +++ b/test/DynamoCoreWpfTests/SerializationTests.cs @@ -414,9 +414,9 @@ public void JSONisSameBeforeAndAfterSaveWithDummyNodes() var jsonText1 = File.ReadAllText(openPath); var jobject1 = JObject.Parse(jsonText1); - // We need to replace the camera with null so it will match the null camera produced by the + // We need to replace the camera with default camera so it will match the deafult camera produced by the // save without a real view below. - jobject1["View"]["Camera"] = null; + jobject1["View"]["Camera"] = JToken.FromObject(new CameraData()); jsonText1 = jobject1.ToString(); jobject1 = JObject.Parse(jsonText1);