Skip to content

Commit

Permalink
Merge pull request DynamoDS#8519 from ramramps/master
Browse files Browse the repository at this point in the history
Add Default Camera to view block if CameraData is null
  • Loading branch information
ramramps authored Feb 7, 2018
2 parents c0e1412 + 951ee95 commit b4a2071
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/DynamoCoreWpf/ViewModels/Core/WorkspaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ public DynamoPreferencesData DynamoPreferences
/// of Graph.Json.
/// </summary>
[JsonProperty("Camera")]
public CameraData Camera
{
get { return DynamoViewModel.BackgroundPreviewViewModel.GetCameraInformation(); }
}
public CameraData Camera => DynamoViewModel.BackgroundPreviewViewModel.GetCameraInformation() ?? new CameraData();

/// <summary>
/// ViewModel that is used in InCanvasSearch in context menu and called by Shift+DoubleClick.
Expand Down
19 changes: 19 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions test/DynamoCoreWpfTests/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b4a2071

Please sign in to comment.