The AgGxVertexUpdate enumeration is provided to primitive initialization methods to allow the primitive to optimize for your expected usage.
| Topic | Description |
|---|---|
| None | Use VertexUpdateNone if you don't plan on updating a primitive with a Set or SetPartial methods. For example, this would be used for a polyline primitive that represents a country boundary. |
| Set | Use VertexUpdateSet if you plan on updating the entire primitive frequently with a Set method. |
| SetPartial | Use VertexUpdateSetPartial if you plan on updating a small percent of a primitive's vertices with a SetPartial method. |
Use VertexUpdateNone for static primitives, that is, primitives you do not plan on updating with a Set or SetPartial method. Insight3D will do several things to optimize performance.
- Ask the renderer to use video memory to store the primitive's vertices.
- If needed, divide up the primitive to get the desired precision. The CPU will not have to touch each vertex during rendering.
- The triangle mesh primitive will reorder indices for the GPU's vertex cache.
VertexUpdateNone provides significant performance gains when used with the triangle mesh primitive. The following example renders every STK Area Target for all the countries. This creates 603 triangle mesh primitives with a total of 651,494 triangles.
| AgGxVertexUpdate | fps |
|---|---|
| VertexUpdateNone | 512 |
| VertexUpdateSet | 78 |
VertexUpdateNone is also faster than alternatives for polyline primitives. The following table shows the frame rate of each vertex update when rendering static polyline primitives for each STK Area Target from the batching section.
| AgGxVertexUpdate | fps |
|---|---|
| VertexUpdateNone | 1,500 |
| VertexUpdateSet | 1,500 |
| VertexUpdateSetPartial | 1,000 |
Similar performance improvements are achieved when using VertexUpdateNone with the point batch and text batch primitives.
If you plan on updating the entire primitive frequently with a Set method, use VertexUpdateSet. This is common for data that may be completely recomputed every animation cycle, such as a polyline representing a sensor's intersection with the earth. To demonstrate the performance differences, we used the same data from the above section. 134 polyline primitives with a total of 13,691 were continuously updated with Set every animation cycle. The frame rates are shown below.
| AgGxVertexUpdate | fps |
|---|---|
| VertexUpdateNone | 161 |
| VertexUpdateSet | 218 |
| VertexUpdateSetPartial | 74 |
The code for the OnAnimationUpdate event is:
for (int i = 0; i < _vertices.Count; ++i) { Array ary = _vertices[i]; _lines[i].Set(AgGxPolylineType.PolylineTypeLineStrip, ref ary); }
Use VertexUpdateSetPartial if you plan on updating a small percentage of a primitive's vertices with a SetPartial method. Using the same 134 polyline primitives from the above section, several tests were run using SetPartial to modify different percentages of vertices in each primitive. The code for the OnAnimationUpdate event follows:
for (int i = 0; i < _vertices.Count; ++i) { Array aryVertices = _vertices[i]; Array aryIndices = _indices[i]; _lines[i].SetPartial(ref aryVertices, ref aryIndices, AgGxIndicesOrder.IndicesOrderSortedAscending); }
As shown in the table below, SetPartial becomes more efficient then updating all the vertices with Set (218 fps) as the number of vertices updated is becomes small.
| % Vertices Modified with SetPartial | fps |
|---|---|
| 100% | 165 |
| 90% | 173 |
| 80% | 182 |
| 70% | 191 |
| 60% | 201 |
| 50% | 213 |
| 40% | 225 |
| 30% | 242 |
| 20% | 260 |
| 10% | 282 |
| 1% | 310 |
If your indices are stored in ascending order, provide the IndicesOrderSortedAscending enumeration to SetPartial to achieve the best performance. This indicates that no CPU time should be spent sorting indices.