mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-11 16:00:47 -07:00
Merge branch 'graphics_buffer_update' of https://github.com/bremco/Cura into bremco-graphics_buffer_update
This commit is contained in:
commit
818438a8d6
6 changed files with 66 additions and 8 deletions
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ class LayerDataBuilder(MeshBuilder):
|
|||
feedrates = numpy.empty((vertex_count), numpy.float32)
|
||||
extruders = numpy.empty((vertex_count), numpy.float32)
|
||||
line_types = numpy.empty((vertex_count), numpy.float32)
|
||||
vertex_indices = numpy.arange(0, vertex_count, 1, dtype=numpy.float32)
|
||||
|
||||
vertex_offset = 0
|
||||
index_offset = 0
|
||||
|
|
@ -109,6 +110,12 @@ class LayerDataBuilder(MeshBuilder):
|
|||
"value": feedrates,
|
||||
"opengl_name": "a_feedrate",
|
||||
"opengl_type": "float"
|
||||
},
|
||||
# Can't use glDrawElements to index (due to oversight in (Py)Qt), can't use gl_PrimitiveID (due to legacy support):
|
||||
"vertex_indices": {
|
||||
"value": vertex_indices,
|
||||
"opengl_name": "a_vertex_index",
|
||||
"opengl_type": "float"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
||||
|
|
@ -207,6 +215,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.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue