Handle render-range in shader.

Instead of re-uploading the mesh each time the range changes, handle the range in the shaders with the new draw-range parameters. This does however, mean the range has to be in vertices, not in elements. This necessitates some changes to the simulation-view, and some added bits deeper in the base code. Mainly, since each time the type of a line changes, there is an extra vertex, there needs to be a type-change count available to get from 'paths' to range indices.
This commit is contained in:
Remco Burema 2021-07-25 22:26:59 +02:00
parent 87d3f6fd22
commit 96ca3b1417
6 changed files with 66 additions and 8 deletions

View file

@ -43,14 +43,22 @@ class Layer:
result = 0
for polygon in self._polygons:
result += polygon.lineMeshVertexCount()
return result
def lineMeshElementCount(self) -> int:
result = 0
for polygon in self._polygons:
result += polygon.lineMeshElementCount()
return result
def lineMeshCumulativeTypeChangeCount(self, path: int) -> int:
result = 0
for polygon in self._polygons:
num_counts = len(polygon.cumulativeTypeChangeCounts)
if path < num_counts:
return result + polygon.cumulativeTypeChangeCounts[path]
path -= num_counts
result += polygon.cumulativeTypeChangeCounts[num_counts - 1]
return result
def build(self, vertex_offset, index_offset, vertices, colors, line_dimensions, feedrates, extruders, line_types, indices):