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

@ -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.