mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 13:49:39 +08:00
Fetch count from simple property instead of recalculation.
Polygons don't change when in layer-view. There's already an analogous elementCount property anyway, so a vertexCount property can't do much harm. Just keep in mind that when the polygons are altered, it should be either done via build, or the lineMeshXXXCount methods should be used instead.
This commit is contained in:
parent
818438a8d6
commit
e119c46944
@ -15,6 +15,7 @@ class Layer:
|
||||
self._height = 0.0
|
||||
self._thickness = 0.0
|
||||
self._polygons = [] # type: List[LayerPolygon]
|
||||
self._vertex_count = 0
|
||||
self._element_count = 0
|
||||
|
||||
@property
|
||||
@ -29,6 +30,10 @@ class Layer:
|
||||
def polygons(self) -> List[LayerPolygon]:
|
||||
return self._polygons
|
||||
|
||||
@property
|
||||
def vertexCount(self):
|
||||
return self._vertex_count
|
||||
|
||||
@property
|
||||
def elementCount(self):
|
||||
return self._element_count
|
||||
@ -64,11 +69,13 @@ class Layer:
|
||||
def build(self, vertex_offset, index_offset, vertices, colors, line_dimensions, feedrates, extruders, line_types, indices):
|
||||
result_vertex_offset = vertex_offset
|
||||
result_index_offset = index_offset
|
||||
self._vertex_count = 0
|
||||
self._element_count = 0
|
||||
for polygon in self._polygons:
|
||||
polygon.build(result_vertex_offset, result_index_offset, vertices, colors, line_dimensions, feedrates, extruders, line_types, indices)
|
||||
result_vertex_offset += polygon.lineMeshVertexCount()
|
||||
result_index_offset += polygon.lineMeshElementCount()
|
||||
self._vertex_count += polygon.vertexCount
|
||||
self._element_count += polygon.elementCount
|
||||
|
||||
return result_vertex_offset, result_index_offset
|
||||
|
@ -187,6 +187,10 @@ class LayerPolygon:
|
||||
def data(self):
|
||||
return self._data
|
||||
|
||||
@property
|
||||
def vertexCount(self):
|
||||
return self._vertex_end - self._vertex_begin
|
||||
|
||||
@property
|
||||
def elementCount(self):
|
||||
return (self._index_end - self._index_begin) * 2 # The range of vertices multiplied by 2 since each vertex is used twice
|
||||
|
@ -162,7 +162,7 @@ class SimulationPass(RenderPass):
|
||||
head_position = Vector(polygon.data[index+offset][0], polygon.data[index+offset][1], polygon.data[index+offset][2]) + node.getWorldPosition()
|
||||
break
|
||||
break
|
||||
end += layer_data.getLayer(layer).lineMeshVertexCount()
|
||||
end += layer_data.getLayer(layer).vertexCount
|
||||
if layer < self._layer_view._minimum_layer_num:
|
||||
start = end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user