-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added highlighting of the selected faces
- Loading branch information
1 parent
d927982
commit 8da7a82
Showing
6 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .render_selection import RenderSelection | ||
from .render_selection_highlightable import RenderSelectionHighlightable | ||
from .render_selection_editable import RenderSelectionEditable | ||
from .render_selection_group import RenderSelectionGroup | ||
from .render_selection_group_editable import RenderSelectionGroupEditable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
amulet_map_editor/opengl/mesh/selection/render_selection_highlightable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from typing import Dict, Any, Tuple | ||
import numpy | ||
|
||
from amulet.api.data_types import BlockCoordinatesAny | ||
from .render_selection import RenderSelection | ||
|
||
|
||
class RenderSelectionHighlightable(RenderSelection): | ||
"""A drawable selection box with edges that can be highlighted""" | ||
def __init__(self, | ||
context_identifier: str, | ||
texture_bounds: Dict[Any, Tuple[float, float, float, float]], | ||
texture: int | ||
): | ||
super().__init__(context_identifier, texture_bounds, texture) | ||
self._highlight_edges = numpy.array([[False, False, False], [False, False, False]], dtype=numpy.bool) # which edges are highlighted | ||
|
||
@property | ||
def highlight_colour(self) -> Tuple[float, float, float]: | ||
return 1.2, 1.2, 1.2 | ||
|
||
def set_active_point(self, position: BlockCoordinatesAny): | ||
if position in self: | ||
self._highlight_edges[:] = position == self._points | ||
self._highlight_edges[1, self._highlight_edges[0]] = False | ||
else: | ||
self._highlight_edges[:] = False | ||
self._mark_recreate() | ||
|
||
def set_highlight_edges(self, highlight_edges): | ||
self._highlight_edges[:] = highlight_edges | ||
self._mark_recreate() | ||
|
||
def _create_geometry_(self): | ||
super()._create_geometry_() | ||
self.verts[:36, 9:12] = self.box_tint | ||
|
||
indexes = numpy.zeros(6, numpy.uint8) | ||
if self.point2[0] > self.point1[0]: | ||
indexes[[1, 3]] = 0, 3 | ||
else: | ||
indexes[[1, 3]] = 3, 0 | ||
|
||
if self.point2[1] > self.point1[1]: | ||
indexes[[0, 5]] = 1, 4 | ||
else: | ||
indexes[[0, 5]] = 4, 1 | ||
|
||
if self.point2[2] > self.point1[2]: | ||
indexes[[2, 4]] = 2, 5 | ||
else: | ||
indexes[[2, 4]] = 5, 2 | ||
|
||
# [1, 0, 2, 3, 5, 4] | ||
|
||
# 0 down 1 | ||
# 1 west 0 | ||
# 2 north 2 | ||
# 3 east 3 | ||
# 4 south 5 | ||
# 5 up 4 | ||
|
||
self.verts[:36][ | ||
numpy.repeat( | ||
self._highlight_edges.ravel()[indexes], 6 | ||
), | ||
9:12 | ||
] = self.highlight_colour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters