Skip to content

Commit df3a852

Browse files
authored
DYN-7103, DYN-7127 Fix crash error in Instancing Rendering logic, Fix issue with code block rendering (#15296)
1 parent 19e0b92 commit df3a852

File tree

8 files changed

+1193
-33
lines changed

8 files changed

+1193
-33
lines changed

src/DynamoCoreWpf/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DynamoCoreWpf/Properties/Resources.en-US.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,4 +4004,10 @@ To make this file into a new template, save it to a different folder, then move
40044004
<data name="NodeInCanvasSearchCreationError" xml:space="preserve">
40054005
<value>Failed to create node: </value>
40064006
</data>
4007+
<data name="InstancingRenderFailureDescription" xml:space="preserve">
4008+
<value>Please disable Use Instancing in the Display Settings section of Visual Settings.</value>
4009+
</data>
4010+
<data name="PartialRenderFailureTitle" xml:space="preserve">
4011+
<value>Background Preview had an issue</value>
4012+
</data>
40074013
</root>

src/DynamoCoreWpf/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3991,4 +3991,10 @@ To make this file into a new template, save it to a different folder, then move
39913991
<data name="NodeInCanvasSearchCreationError" xml:space="preserve">
39923992
<value>Failed to create node: </value>
39933993
</data>
3994+
<data name="InstancingRenderFailureDescription" xml:space="preserve">
3995+
<value>Please disable Use Instancing in the Display Settings section of Visual Settings.</value>
3996+
</data>
3997+
<data name="PartialRenderFailureTitle" xml:space="preserve">
3998+
<value>Background Preview had an issue</value>
3999+
</data>
39944000
</root>

src/DynamoCoreWpf/PublicAPI.Unshipped.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4784,6 +4784,7 @@ static Dynamo.Wpf.Properties.Resources.InstalledPackageViewNodeLibrariesLabel.ge
47844784
static Dynamo.Wpf.Properties.Resources.InstalledPackageViewPendingInstallButton.get -> string
47854785
static Dynamo.Wpf.Properties.Resources.InstalledPackageViewTitle.get -> string
47864786
static Dynamo.Wpf.Properties.Resources.InstallMessageCaption.get -> string
4787+
static Dynamo.Wpf.Properties.Resources.InstancingRenderFailureDescription.get -> string
47874788
static Dynamo.Wpf.Properties.Resources.InteractiveGuides.get -> string
47884789
static Dynamo.Wpf.Properties.Resources.InvalidDraggingOperationMessgae.get -> string
47894790
static Dynamo.Wpf.Properties.Resources.InvalidLoginUrl.get -> string
@@ -5133,6 +5134,7 @@ static Dynamo.Wpf.Properties.Resources.PackageViewContextMenuLoadText.get -> str
51335134
static Dynamo.Wpf.Properties.Resources.PackageViewContextMenuLoadTooltip.get -> string
51345135
static Dynamo.Wpf.Properties.Resources.PackageWarningMessageBoxTitle.get -> string
51355136
static Dynamo.Wpf.Properties.Resources.PackageWebsiteLabel.get -> string
5137+
static Dynamo.Wpf.Properties.Resources.PartialRenderFailureTitle.get -> string
51365138
static Dynamo.Wpf.Properties.Resources.Periodic.get -> string
51375139
static Dynamo.Wpf.Properties.Resources.PersistentVisualStatusOfLinterIssues.get -> string
51385140
static Dynamo.Wpf.Properties.Resources.PortPropertiesPromptDescriptionTooltip.get -> string

src/DynamoCoreWpf/ViewModels/Watch3D/HelixWatch3DViewModel.cs

Lines changed: 197 additions & 33 deletions
Large diffs are not rendered by default.

test/VisualizationTests/HelixWatch3DViewModelTests.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,41 @@ public void InstancedShowEdgesAreCorrect()
14731473
System.String.Join(Environment.NewLine, edgeVerts.Select(x=>x.ToString())).Replace(" ",string.Empty));
14741474
}
14751475

1476+
[Test]
1477+
public void StandardCurvesAndInstancedCurvesAndAreAddedToBackGroundPreviewForWhenTesselatedFromOneNodeExample1()
1478+
{
1479+
ViewModel.RenderPackageFactoryViewModel.UseRenderInstancing = true;
1480+
1481+
Model.LibraryServices.ImportLibrary("FFITarget.dll");
1482+
OpenVisualizationTest("MixedListOfInstancedAndStandardCurves.dyn");
1483+
RunCurrentModel();
1484+
DispatcherUtil.DoEvents();
1485+
1486+
//this graph displays a 3 lines.
1487+
Assert.AreEqual(3, BackgroundPreviewGeometry.TotalCurvesMinusInstances());
1488+
1489+
//this graph displays 2 rectangle instances.
1490+
Assert.AreEqual(2, BackgroundPreviewGeometry.TotalLineInstancesToRender());
1491+
1492+
Assert.AreEqual(false, BackgroundPreviewGeometry.AnyLargerIndicesThanVertexCount());
1493+
1494+
Assert.AreEqual(false, BackgroundPreviewGeometry.AnyNegativeIndices());
1495+
}
1496+
1497+
[Test]
1498+
public void InstanceGeometryWithinCodeBlock()
1499+
{
1500+
ViewModel.RenderPackageFactoryViewModel.UseRenderInstancing = true;
1501+
1502+
Model.LibraryServices.ImportLibrary("FFITarget.dll");
1503+
OpenVisualizationTest("InstancingWithinCodeBlock.dyn");
1504+
RunCurrentModel();
1505+
DispatcherUtil.DoEvents();
1506+
1507+
//this graph displays 2 rectangle instances.
1508+
Assert.AreEqual(2, BackgroundPreviewGeometry.TotalLineInstancesToRender());
1509+
}
1510+
14761511
[Test]
14771512
public void Watch3dNodeDisposal_DoesNotBreakBackGroundPreview()
14781513
{
@@ -1598,6 +1633,45 @@ public static int TotalCurves(this IEnumerable<Element3D> dictionary)
15981633
: 0;
15991634
}
16001635

1636+
public static int TotalCurvesMinusInstances(this IEnumerable<Element3D> dictionary)
1637+
{
1638+
var lines = dictionary.Where(g => g is LineGeometryModel3D && !keyList.Contains(g.Name) && ((LineGeometryModel3D)g).Instances == null).ToArray();
1639+
1640+
return lines.Any()
1641+
? lines.SelectMany(g => ((LineGeometryModel3D)g).Geometry.Positions).Count() / 2
1642+
: 0;
1643+
}
1644+
1645+
public static bool AnyNegativeIndices(this IEnumerable<Element3D> dictionary)
1646+
{
1647+
var lines = dictionary.Where(g => g is LineGeometryModel3D && !keyList.Contains(g.Name) && ((LineGeometryModel3D)g).Instances == null).ToArray();
1648+
1649+
foreach(var line in lines)
1650+
{
1651+
var indices = ((LineGeometryModel3D)line).Geometry.Indices;
1652+
if (indices.Any(i => i < 0))
1653+
return true;
1654+
}
1655+
1656+
return false;
1657+
}
1658+
1659+
public static bool AnyLargerIndicesThanVertexCount(this IEnumerable<Element3D> dictionary)
1660+
{
1661+
var lines = dictionary.Where(g => g is LineGeometryModel3D && !keyList.Contains(g.Name) && ((LineGeometryModel3D)g).Instances == null).ToArray();
1662+
1663+
foreach (var line in lines)
1664+
{
1665+
var max = ((LineGeometryModel3D)line).Geometry.Positions.Count();
1666+
1667+
var indices = ((LineGeometryModel3D)line).Geometry.Indices;
1668+
if (indices.Any(i => i > max))
1669+
return true;
1670+
}
1671+
1672+
return false;
1673+
}
1674+
16011675
public static int TotalText(this IEnumerable<Element3D> dictionary)
16021676
{
16031677
var text = dictionary
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
{
2+
"Uuid": "db6f1cd5-06d1-47c7-83a2-9865a281864a",
3+
"IsCustomNode": false,
4+
"Description": "",
5+
"Name": "InstancingWithinCodeBlock",
6+
"ElementResolver": {
7+
"ResolutionMap": {
8+
"Cuboid": {
9+
"Key": "Autodesk.DesignScript.Geometry.Cuboid",
10+
"Value": "ProtoGeometry.dll"
11+
},
12+
"Circle": {
13+
"Key": "Autodesk.DesignScript.Geometry.Circle",
14+
"Value": "ProtoGeometry.dll"
15+
},
16+
"Point": {
17+
"Key": "Autodesk.DesignScript.Geometry.Point",
18+
"Value": "ProtoGeometry.dll"
19+
},
20+
"Sphere": {
21+
"Key": "Autodesk.DesignScript.Geometry.Sphere",
22+
"Value": "ProtoGeometry.dll"
23+
},
24+
"Line": {
25+
"Key": "Autodesk.DesignScript.Geometry.Line",
26+
"Value": "ProtoGeometry.dll"
27+
},
28+
"Rectangle": {
29+
"Key": "Autodesk.DesignScript.Geometry.Rectangle",
30+
"Value": "ProtoGeometry.dll"
31+
}
32+
}
33+
},
34+
"Inputs": [],
35+
"Outputs": [],
36+
"Nodes": [
37+
{
38+
"ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore",
39+
"Id": "c0a1361e543f46858c92564816649e7d",
40+
"NodeType": "CodeBlockNode",
41+
"Inputs": [],
42+
"Outputs": [
43+
{
44+
"Id": "cda3b41512bc427c8c0829cb70650ebe",
45+
"Name": "",
46+
"Description": "Value of expression at line 1",
47+
"UsingDefaultValue": false,
48+
"Level": 2,
49+
"UseLevels": false,
50+
"KeepListStructure": false
51+
},
52+
{
53+
"Id": "9195bd7048384b09b1477631d0a9f135",
54+
"Name": "",
55+
"Description": "Value of expression at line 2",
56+
"UsingDefaultValue": false,
57+
"Level": 2,
58+
"UseLevels": false,
59+
"KeepListStructure": false
60+
}
61+
],
62+
"Replication": "Disabled",
63+
"Description": "Allows for DesignScript code to be authored directly",
64+
"Code": "Rectangle.ByWidthLength(2,4);\nRectangle.ByWidthLength(1,2);"
65+
}
66+
],
67+
"Connectors": [],
68+
"Dependencies": [],
69+
"NodeLibraryDependencies": [],
70+
"EnableLegacyPolyCurveBehavior": true,
71+
"Thumbnail": "",
72+
"GraphDocumentationURL": null,
73+
"ExtensionWorkspaceData": [
74+
{
75+
"ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670",
76+
"Name": "Properties",
77+
"Version": "3.3",
78+
"Data": {}
79+
}
80+
],
81+
"Author": "",
82+
"Linting": {
83+
"activeLinter": "None",
84+
"activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a",
85+
"warningCount": 0,
86+
"errorCount": 0
87+
},
88+
"Bindings": [],
89+
"View": {
90+
"Dynamo": {
91+
"ScaleFactor": 1.0,
92+
"HasRunWithoutCrash": true,
93+
"IsVisibleInDynamoLibrary": true,
94+
"Version": "3.3.0.5237",
95+
"RunType": "Automatic",
96+
"RunPeriod": "1000"
97+
},
98+
"Camera": {
99+
"Name": "_Background Preview",
100+
"EyeX": -18.08238983154297,
101+
"EyeY": 25.974166870117188,
102+
"EyeZ": 2.616847038269043,
103+
"LookX": 13.082389831542969,
104+
"LookY": -14.974166870117188,
105+
"LookZ": -10.616847038269043,
106+
"UpX": 0.3794049024581909,
107+
"UpY": 0.872495710849762,
108+
"UpZ": -0.3079013228416443
109+
},
110+
"ConnectorPins": [],
111+
"NodeViews": [
112+
{
113+
"Id": "c0a1361e543f46858c92564816649e7d",
114+
"Name": "Code Block",
115+
"IsSetAsInput": false,
116+
"IsSetAsOutput": false,
117+
"Excluded": false,
118+
"ShowGeometry": true,
119+
"X": 2097.06910448662,
120+
"Y": 724.121483527379
121+
}
122+
],
123+
"Annotations": [],
124+
"X": -2146.757813379982,
125+
"Y": -478.75882791579454,
126+
"Zoom": 1.1129446513066208
127+
}
128+
}

0 commit comments

Comments
 (0)