diff options
author | Remco Burema <rburema@gmail.com> | 2021-07-25 23:26:59 +0300 |
---|---|---|
committer | Remco Burema <rburema@gmail.com> | 2021-07-25 23:26:59 +0300 |
commit | 96ca3b14170c7e3e8b1b13215a9e27ab32893f5e (patch) | |
tree | 332c1d3bfcaf5c09ec36842dc3d1fe8a27d62206 /cura/LayerPolygon.py | |
parent | 87d3f6fd22a1c6bf6a32703da5b058fadca64c54 (diff) |
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.
Diffstat (limited to 'cura/LayerPolygon.py')
-rw-r--r-- | cura/LayerPolygon.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cura/LayerPolygon.py b/cura/LayerPolygon.py index 6e518e984a..f975f9919e 100644 --- a/cura/LayerPolygon.py +++ b/cura/LayerPolygon.py @@ -55,6 +55,14 @@ class LayerPolygon: self._jump_mask = self.__jump_map[self._types] self._jump_count = numpy.sum(self._jump_mask) + self._cumulative_type_change_counts = numpy.zeros(len(self._types)) + last_type = self.types[0] + current_type_count = 0 + for i in range(0, len(self._cumulative_type_change_counts)): + if last_type != self.types[i]: + current_type_count += 1 + last_type = self.types[i] + self._cumulative_type_change_counts[i] = current_type_count self._mesh_line_count = len(self._types) - self._jump_count self._vertex_count = self._mesh_line_count + numpy.sum(self._types[1:] == self._types[:-1]) @@ -208,6 +216,10 @@ class LayerPolygon: def jumpCount(self): return self._jump_count + @property + def cumulativeTypeChangeCounts(self): + return self._cumulative_type_change_counts + def getNormals(self) -> numpy.ndarray: """Calculate normals for the entire polygon using numpy. |