diff --git a/src/DynamoCoreWpf/ViewModels/Watch3D/DynamoEffectsManager.cs b/src/DynamoCoreWpf/ViewModels/Watch3D/DynamoEffectsManager.cs
index f8e7ca3b4fe..bd4f312c6b6 100644
--- a/src/DynamoCoreWpf/ViewModels/Watch3D/DynamoEffectsManager.cs
+++ b/src/DynamoCoreWpf/ViewModels/Watch3D/DynamoEffectsManager.cs
@@ -20,13 +20,7 @@ public DynamoEffectsManager() : base() {
AddDynamoTechniques();
}
- ///
- /// Load effects used by Dynamo for rendering. Custom input layouts are
- /// created which specify extra COLOR components used to hold data
- /// about the selection state and vertex coloration of objects.
- /// See , , and
- /// for examples of how these layouts are used.
- ///
+
protected void AddDynamoTechniques()
{
var custom = new TechniqueDescription("RenderCustom")
diff --git a/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs b/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs
index 2e26308b23b..c3ab5d47c50 100644
--- a/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs
@@ -258,25 +258,6 @@ protected void OnRequestZoomToFit(BoundingBox bounds)
RequestZoomToFit(bounds);
}
}
-
- public event Func RequestRemoveViewportItem;
- private bool OnRequestRemoveViewportItem(Element3D item)
- {
- if(RequestRemoveViewportItem != null)
- {
- return RequestRemoveViewportItem(item);
- }
- return false;
- }
-
- public event Action RequestAddViewportItem;
- private void OnRequestAddViewportItem(Element3D item)
- {
- if(RequestAddViewportItem != null)
- {
- RequestAddViewportItem(item);
- }
- }
#endregion
#region properties
@@ -461,6 +442,20 @@ private void UpdateSceneItems()
if (sceneItems == null)
sceneItems = new ObservableElement3DCollection();
+ //perform these updates here instead of everytime we add a single render package.
+ foreach(var geoModel3d in values)
+ {
+ if(geoModel3d is HelixToolkit.Wpf.SharpDX.GeometryModel3D)
+ {
+ var geo = (geoModel3d as HelixToolkit.Wpf.SharpDX.GeometryModel3D).Geometry;
+
+ geo.UpdateVertices();
+ geo.UpdateColors();
+ geo.UpdateBounds();
+ geo.UpdateTriangles();
+ }
+ }
+
sceneItems.Clear();
sceneItems.AddRange(values);
}
@@ -480,6 +475,7 @@ public IEnumerable SceneItems
public IEffectsManager EffectsManager { get; private set; }
+ [Obsolete("Not Implemented - Do Not Use.")]
public bool SupportDeferredRender { get; private set; }
#endregion
@@ -644,7 +640,6 @@ protected override void OnClear()
foreach (var key in Element3DDictionary.Keys.Except(keysList).ToList())
{
var model = Element3DDictionary[key] as GeometryModel3D;
- OnRequestRemoveViewportItem(model);
Element3DDictionary.Remove(key);
model.Dispose();
@@ -886,7 +881,6 @@ private void DeleteGeometries(KeyValuePair[] geometryModels,
var frozenModel = AttachedProperties.GetIsFrozen(model3D);
if (frozenModel) continue;
- OnRequestRemoveViewportItem(model3D);
Element3DDictionary.Remove(kvp.Key);
model3D.Dispose();
@@ -1065,6 +1059,9 @@ internal void ComputeFrameUpdate()
private void OnSceneItemsChanged()
{
UpdateSceneItems();
+ //TODO unclear if these are still required.
+ //since sceneItems are observable and we force them to update
+ //by clearing and readdding all items.
RaisePropertyChanged("SceneItems");
OnRequestViewRefresh();
}
@@ -1488,7 +1485,6 @@ public override void AddLabelForPath(string path)
{
// first, remove current labels of the node
// it does not crash if there is no such key in dictionary
- OnRequestRemoveViewportItem(Element3DDictionary[labelName]);
var sceneItemsChanged = Element3DDictionary.Remove(labelName);
// it may be requested an array of items to put labels
@@ -1529,7 +1525,6 @@ public override void AddLabelForPath(string path)
}
Element3DDictionary.Add(labelName, bbText);
- OnRequestAddViewportItem(bbText);
sceneItemsChanged = true;
nodesSelected[nodePath] = path;
@@ -1564,7 +1559,6 @@ public override void ClearPathLabel(string path)
var labelName = nodePath + TextKey;
lock (Element3DDictionaryMutex)
{
- OnRequestRemoveViewportItem(Element3DDictionary[labelName]);
var sceneItemsChanged = Element3DDictionary.Remove(labelName);
if (sceneItemsChanged)
@@ -1673,10 +1667,10 @@ private void AggregateRenderPackages(IEnumerable packages)
{
pointGeometry3D = CreatePointGeometryModel3D(rp);
Element3DDictionary.Add(id, pointGeometry3D);
- OnRequestAddViewportItem(pointGeometry3D);
}
- var points = pointGeometry3D.Geometry as PointGeometry3D;
+ var points = pointGeometry3D.Geometry == null ? HelixRenderPackage.InitPointGeometry()
+ : pointGeometry3D.Geometry as PointGeometry3D;
var startIdx = points.Positions.Count;
points.Positions.AddRange(p.Positions);
@@ -1694,11 +1688,12 @@ private void AggregateRenderPackages(IEnumerable packages)
}
AddLabelPlace(baseId, p.Positions[0], rp);
- pointGeometry3D.Geometry = points;
+ if (pointGeometry3D.Geometry == null)
+ {
+ pointGeometry3D.Geometry = points;
+ }
pointGeometry3D.Name = baseId;
- points.UpdateVertices();
- points.UpdateColors();
}
var l = rp.Lines;
@@ -1719,10 +1714,10 @@ private void AggregateRenderPackages(IEnumerable packages)
// edges of meshes. Draw them with a different thickness.
lineGeometry3D = CreateLineGeometryModel3D(rp, rp.MeshVertices.Any()?0.5:1.0);
Element3DDictionary.Add(id, lineGeometry3D);
- OnRequestAddViewportItem(lineGeometry3D);
}
- var lineSet = lineGeometry3D.Geometry as LineGeometry3D;
+ var lineSet = lineGeometry3D.Geometry == null ? HelixRenderPackage.InitLineGeometry()
+ : lineGeometry3D.Geometry as LineGeometry3D;
var startIdx = lineSet.Positions.Count;
lineSet.Positions.AddRange(l.Positions);
@@ -1742,11 +1737,13 @@ private void AggregateRenderPackages(IEnumerable packages)
: Enumerable.Range(startIdx, startIdx + l.Positions.Count));
AddLabelPlace(baseId, lineSet.Positions[startIdx], rp);
- lineGeometry3D.Geometry = lineSet;
+ if(lineGeometry3D.Geometry == null)
+ {
+ lineGeometry3D.Geometry = lineSet;
+ }
+
lineGeometry3D.Name = baseId;
- lineSet.UpdateVertices();
- lineSet.UpdateColors();
}
var m = rp.Mesh;
@@ -1765,7 +1762,6 @@ private void AggregateRenderPackages(IEnumerable packages)
{
meshGeometry3D = CreateDynamoGeometryModel3D(rp);
Element3DDictionary.Add(id, meshGeometry3D);
- OnRequestAddViewportItem(meshGeometry3D);
}
var mesh = meshGeometry3D.Geometry == null ? HelixRenderPackage.InitMeshGeometry()
@@ -1803,10 +1799,6 @@ private void AggregateRenderPackages(IEnumerable packages)
meshGeometry3D.Geometry = mesh;
meshGeometry3D.Name = baseId;
- mesh.UpdateVertices();
- mesh.UpdateColors();
- mesh.UpdateTextureCoordinates();
- mesh.UpdateTriangles();
}
}
@@ -1877,8 +1869,6 @@ private bool UpdateGeometryModelForSpecialRenderPackage(HelixRenderPackage rp, s
manipulator.Material = PhongMaterials.Blue;
Element3DDictionary[id] = manipulator;
- OnRequestRemoveViewportItem(model);
- OnRequestAddViewportItem(manipulator);
return true;
case RenderDescriptions.AxisLine:
var centerline = model as DynamoLineGeometryModel3D;
@@ -1889,8 +1879,6 @@ private bool UpdateGeometryModelForSpecialRenderPackage(HelixRenderPackage rp, s
}
centerline.Geometry = rp.Lines;
Element3DDictionary[id] = centerline;
- OnRequestRemoveViewportItem(model);
- OnRequestAddViewportItem(centerline);
return true;
case RenderDescriptions.ManipulatorPlane:
var plane = model as DynamoLineGeometryModel3D;
@@ -1901,8 +1889,6 @@ private bool UpdateGeometryModelForSpecialRenderPackage(HelixRenderPackage rp, s
}
plane.Geometry = rp.Lines;
Element3DDictionary[id] = plane;
- OnRequestRemoveViewportItem(model);
- OnRequestAddViewportItem(plane);
return true;
default:
return false;
@@ -1997,7 +1983,6 @@ private void CreateOrUpdateText(string baseId, Vector3 pt, IRenderPackage rp)
Geometry = HelixRenderPackage.InitText3D(),
};
Element3DDictionary.Add(textId, bbText);
- OnRequestAddViewportItem(bbText);
}
var geom = bbText.Geometry as BillboardText3D;
@@ -2051,7 +2036,7 @@ private DynamoLineGeometryModel3D CreateLineGeometryModel3D(HelixRenderPackage r
{
var lineGeometry3D = new DynamoLineGeometryModel3D()
{
- Geometry = HelixRenderPackage.InitLineGeometry(),
+ //Do not set Geometry here
Transform = new MatrixTransform3D(rp.Transform.ToMatrix3D()),
Color = Colors.White,
Thickness = thickness,
@@ -2065,7 +2050,7 @@ private DynamoPointGeometryModel3D CreatePointGeometryModel3D(HelixRenderPackage
{
var pointGeometry3D = new DynamoPointGeometryModel3D
{
- Geometry = HelixRenderPackage.InitPointGeometry(),
+ //Do not set Geometry here
Transform = new MatrixTransform3D(rp.Transform.ToMatrix3D()),
Color = Colors.White,
Figure = PointFigure.Ellipse,
diff --git a/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml b/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml
index 1345eed1ec3..9921948d588 100644
--- a/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml
+++ b/src/DynamoCoreWpf/Views/Preview/Watch3DView.xaml
@@ -108,10 +108,10 @@
-
+ />