Skip to content

Commit

Permalink
Redesigned selection box point methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Mar 3, 2020
1 parent 9331866 commit f9417f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,23 @@ def move_camera(self, forward, up, right, pitch, yaw):

location = self._collision_location_distance(10)
if self._selection_box.select_state == 0:
self._selection_box.min = self._selection_box.max = location
self._selection_box.max += 1
self._selection_box.point1 = self._selection_box.point2 = location
self._selection_box.point2 += 1
self._selection_box.create_geometry()
elif self._selection_box.select_state == 1:
self._selection_box.max = location + 1
self._selection_box.point2 = location + 1
self._selection_box.create_geometry()
elif self._selection_box.select_state == 2:
self._selection_box2.min = self._selection_box2.max = location
self._selection_box2.max += 1
self._selection_box2.point1 = self._selection_box2.point2 = location
self._selection_box2.point2 += 1
self._selection_box2.create_geometry()

def left_click(self):
if self._selection_box.select_state <= 1:
self._selection_box.select_state += 1
self._selection_box.create_geometry()
elif self._selection_box.select_state == 2:
self._selection_box.min = self._selection_box.max = self._selection_box2.min
self._selection_box.point1, self._selection_box.point2 = self._selection_box2.point1, self._selection_box2.point2
self._selection_box.create_geometry()
self._selection_box.select_state = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,31 @@ def select_state(self, value: int):
self._select_state = value

@property
def min(self) -> numpy.ndarray:
def point1(self) -> numpy.ndarray:
return self._loc[:3]

@min.setter
def min(self, val):
@point1.setter
def point1(self, val):
self._loc[:3] = val

@property
def max(self) -> numpy.ndarray:
def point2(self) -> numpy.ndarray:
return self._loc[3:]

@max.setter
def max(self, val):
@point2.setter
def point2(self, val):
self._loc[3:] = val

def _create_box(self, box_min, box_max) -> Tuple[numpy.ndarray, numpy.ndarray]:
@property
def min(self) -> numpy.ndarray:
return numpy.min(self._loc.reshape((2, 3)), 0)

@property
def max(self) -> numpy.ndarray:
return numpy.max(self._loc.reshape((2, 3)), 0)

@staticmethod
def _create_box(box_min, box_max) -> Tuple[numpy.ndarray, numpy.ndarray]:
box = numpy.array([box_min, box_max])
_box_coordinates = numpy.array(
list(
Expand Down Expand Up @@ -82,9 +91,8 @@ def _create_box(self, box_min, box_max) -> Tuple[numpy.ndarray, numpy.ndarray]:

def create_geometry(self):
self._setup()
box = self._loc.reshape((2, 3))
box_min = numpy.min(box, 0)
box_max = numpy.max(box, 0)
box_min = self.min
box_max = self.max

if self.select_state >= 0:
self._verts[:36, :3], self._verts[:36, 3:5] = self._create_box(box_min-0.005, box_max+0.005)
Expand Down

0 comments on commit f9417f9

Please sign in to comment.