Brush's "Hover" option is now implemented.

TODO: Button to switch hover to half of object height, or half of object size along axis given by face under cursor
This commit is contained in:
David Vierra 2015-06-02 20:27:16 -10:00
parent 4e284e64c6
commit 814a40b993
2 changed files with 17 additions and 9 deletions

View File

@ -17,6 +17,7 @@ from mcedit2.util.load_ui import load_ui, registerCustomWidget
from mcedit2.util.settings import Settings
from mcedit2.util.showprogress import showProgress
from mcedit2.util.worldloader import WorldLoader
from mceditlib.geometry import Vector
from mceditlib.util import exhaust
@ -121,6 +122,10 @@ class BrushTool(EditorTool):
self.toolWidget.ySpinSlider.setValue(self.brushSize[1])
self.toolWidget.zSpinSlider.setValue(self.brushSize[2])
@property
def hoverDistance(self):
return self.toolWidget.hoverSpinSlider.value()
_brushSize = (0, 0, 0)
@property
@ -157,13 +162,15 @@ class BrushTool(EditorTool):
def mousePress(self, event):
pos = event.blockPosition
pos += event.blockFace.vector
command = BrushCommand(self.editorSession, [pos], self.options)
vector = (event.blockFace.vector * self.hoverDistance)
command = BrushCommand(self.editorSession, [pos + vector], self.options)
self.editorSession.pushCommand(command)
def mouseMove(self, event):
if event.blockPosition:
self.cursorNode.translateOffset = event.blockPosition + event.blockFace.vector
vector = (event.blockFace.vector * self.hoverDistance)
assert isinstance(vector, Vector), "vector isa %s" % type(vector)
self.cursorNode.translateOffset = event.blockPosition + vector
@property
def options(self):

View File

@ -1,4 +1,5 @@
from __future__ import absolute_import
from mceditlib.geometry import Vector
class Face(int):
@ -42,12 +43,12 @@ FaceZDecreasing = FaceNorth = Face(5)
MaxDirections = 6
faceDirections = (
(FaceXIncreasing, (1, 0, 0)),
(FaceXDecreasing, (-1, 0, 0)),
(FaceYIncreasing, (0, 1, 0)),
(FaceYDecreasing, (0, -1, 0)),
(FaceZIncreasing, (0, 0, 1)),
(FaceZDecreasing, (0, 0, -1))
(FaceXIncreasing, Vector(1, 0, 0)),
(FaceXDecreasing, Vector(-1, 0, 0)),
(FaceYIncreasing, Vector(0, 1, 0)),
(FaceYDecreasing, Vector(0, -1, 0)),
(FaceZIncreasing, Vector(0, 0, 1)),
(FaceZDecreasing, Vector(0, 0, -1))
)
_directions = {k: v for (k, v) in faceDirections}