diff --git a/cura/Scene/SliceableObjectDecorator.py b/cura/Scene/SliceableObjectDecorator.py index cc611b17af..7ee77795e7 100644 --- a/cura/Scene/SliceableObjectDecorator.py +++ b/cura/Scene/SliceableObjectDecorator.py @@ -12,10 +12,6 @@ from UM.View.GL.OpenGL import OpenGL from UM.View.GL.Texture import Texture -# FIXME: When the texture UV-unwrapping is done, these two values will need to be set to a proper value (suggest 4096 for both). -TEXTURE_WIDTH = 512 -TEXTURE_HEIGHT = 512 - class SliceableObjectDecorator(SceneNodeDecorator): def __init__(self) -> None: super().__init__() @@ -25,15 +21,10 @@ class SliceableObjectDecorator(SceneNodeDecorator): def isSliceable(self) -> bool: return True - def getPaintTexture(self, create_if_required: bool = True) -> Optional[UM.View.GL.Texture.Texture]: - if self._paint_texture is None and create_if_required: - self._paint_texture = OpenGL.getInstance().createTexture(TEXTURE_WIDTH, TEXTURE_HEIGHT) - image = QImage(TEXTURE_WIDTH, TEXTURE_HEIGHT, QImage.Format.Format_RGB32) - image.fill(0) - self._paint_texture.setImage(image) + def getPaintTexture(self) -> Optional[Texture]: return self._paint_texture - def setPaintTexture(self, texture: UM.View.GL.Texture) -> None: + def setPaintTexture(self, texture: Texture) -> None: self._paint_texture = texture def getTextureDataMapping(self) -> Dict[str, tuple[int, int]]: @@ -42,6 +33,13 @@ class SliceableObjectDecorator(SceneNodeDecorator): def setTextureDataMapping(self, mapping: Dict[str, tuple[int, int]]) -> None: self._texture_data_mapping = mapping + def prepareTexture(self, width: int, height: int) -> None: + if self._paint_texture is None: + self._paint_texture = OpenGL.getInstance().createTexture(width, height) + image = QImage(width, height, QImage.Format.Format_RGB32) + image.fill(0) + self._paint_texture.setImage(image) + def packTexture(self) -> Optional[bytearray]: if self._paint_texture is None: return None @@ -60,6 +58,6 @@ class SliceableObjectDecorator(SceneNodeDecorator): def __deepcopy__(self, memo) -> "SliceableObjectDecorator": copied_decorator = SliceableObjectDecorator() - copied_decorator.setPaintTexture(copy.deepcopy(self.getPaintTexture(create_if_required = False))) + copied_decorator.setPaintTexture(copy.deepcopy(self.getPaintTexture())) copied_decorator.setTextureDataMapping(copy.deepcopy(self.getTextureDataMapping())) return copied_decorator diff --git a/plugins/3MFReader/ThreeMFReader.py b/plugins/3MFReader/ThreeMFReader.py index 730acf4af6..09143dde64 100755 --- a/plugins/3MFReader/ThreeMFReader.py +++ b/plugins/3MFReader/ThreeMFReader.py @@ -153,8 +153,6 @@ class ThreeMFReader(MeshReader): # It is only set for the root node of the 3mf file mesh_builder.setFileName(file_name) - mesh_builder.unwrapNewUvs() - mesh_data = mesh_builder.build() if len(mesh_data.getVertices()): diff --git a/plugins/PaintTool/PaintTool.qml b/plugins/PaintTool/PaintTool.qml index 4cbe9d4ade..ef1ac35628 100644 --- a/plugins/PaintTool/PaintTool.qml +++ b/plugins/PaintTool/PaintTool.qml @@ -164,17 +164,22 @@ Item width: parent.width indicatorVisible: false - from: 1 - to: 40 - value: 10 + from: 10 + to: 1000 + value: 200 onPressedChanged: function(pressed) { if(! pressed) { - UM.Controller.triggerActionWithData("setBrushSize", shapeSizeSlider.value) + setBrushSize() } } + + function setBrushSize() + { + UM.Controller.triggerActionWithData("setBrushSize", shapeSizeSlider.value) + } } //Line between the sections. @@ -233,5 +238,6 @@ Item rowPaintMode.children[0].setMode() rowBrushColor.children[1].setColor() rowBrushShape.children[1].setShape() + shapeSizeSlider.setBrushSize() } } diff --git a/plugins/PaintTool/PaintView.py b/plugins/PaintTool/PaintView.py index 22eb8c55f6..2b0181be70 100644 --- a/plugins/PaintTool/PaintView.py +++ b/plugins/PaintTool/PaintView.py @@ -147,6 +147,14 @@ class PaintView(View): paint_data_mapping[paint_type] = new_mapping node.callDecoration("setTextureDataMapping", paint_data_mapping) + mesh = node.getMeshData() + if not mesh.hasUVCoordinates(): + texture_width, texture_height = mesh.calculateUnwrappedUVCoordinates(4096) + node.callDecoration("prepareTexture", texture_width, texture_height) + if hasattr(mesh, OpenGL.VertexBufferProperty): + # Force clear OpenGL buffer so that new UV coordinates will be sent + delattr(mesh, OpenGL.VertexBufferProperty) + self._current_paint_type = paint_type self._current_bits_ranges = paint_data_mapping[paint_type]