mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Fix code-style and type hinting
This commit is contained in:
parent
7e4cb1c36e
commit
e4a416258b
1 changed files with 3 additions and 4 deletions
|
@ -24,7 +24,6 @@ class PickingPass(RenderPass):
|
||||||
self._shader = None
|
self._shader = None
|
||||||
self._scene = Application.getInstance().getController().getScene()
|
self._scene = Application.getInstance().getController().getScene()
|
||||||
|
|
||||||
|
|
||||||
def render(self) -> None:
|
def render(self) -> None:
|
||||||
if not self._shader:
|
if not self._shader:
|
||||||
self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "camera_distance.shader"))
|
self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "camera_distance.shader"))
|
||||||
|
@ -47,7 +46,7 @@ class PickingPass(RenderPass):
|
||||||
self.release()
|
self.release()
|
||||||
|
|
||||||
## Get the distance in mm from the camera to at a certain pixel coordinate.
|
## Get the distance in mm from the camera to at a certain pixel coordinate.
|
||||||
def getPickedDepth(self, x, y) -> float:
|
def getPickedDepth(self, x: int, y: int) -> float:
|
||||||
output = self.getOutput()
|
output = self.getOutput()
|
||||||
|
|
||||||
window_size = self._renderer.getWindowSize()
|
window_size = self._renderer.getWindowSize()
|
||||||
|
@ -56,14 +55,14 @@ class PickingPass(RenderPass):
|
||||||
py = (0.5 + y / 2.0) * window_size[1]
|
py = (0.5 + y / 2.0) * window_size[1]
|
||||||
|
|
||||||
if px < 0 or px > (output.width() - 1) or py < 0 or py > (output.height() - 1):
|
if px < 0 or px > (output.width() - 1) or py < 0 or py > (output.height() - 1):
|
||||||
return None
|
return -1
|
||||||
|
|
||||||
distance = output.pixel(px, py) # distance in micron, from in r, g & b channels
|
distance = output.pixel(px, py) # distance in micron, from in r, g & b channels
|
||||||
distance = (distance & 0x00ffffff) / 1000. # drop the alpha channel and covert to mm
|
distance = (distance & 0x00ffffff) / 1000. # drop the alpha channel and covert to mm
|
||||||
return distance
|
return distance
|
||||||
|
|
||||||
## Get the world coordinates of a picked point
|
## Get the world coordinates of a picked point
|
||||||
def getPickedPosition(self, x, y) -> Vector:
|
def getPickedPosition(self, x: int, y: int) -> Vector:
|
||||||
distance = self.getPickedDepth(x, y)
|
distance = self.getPickedDepth(x, y)
|
||||||
ray = self._scene.getActiveCamera().getRay(x, y)
|
ray = self._scene.getActiveCamera().getRay(x, y)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue