Skip to content

Commit

Permalink
Merge pull request #113 from maniek2332/ft/effective_z_index
Browse files Browse the repository at this point in the history
Node properties: root_distance, effective_z_index and effective_views
  • Loading branch information
labuzm committed Feb 20, 2021
2 parents 8652677 + a91d419 commit ccf00fa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/kaa/kaacore/nodes.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from libc.stdint cimport int16_t, uint32_t
from libc.stdint cimport uint16_t, int16_t, uint32_t
from libcpp cimport bool
from libcpp.vector cimport vector
from libcpp.memory cimport unique_ptr
Expand Down Expand Up @@ -82,6 +82,7 @@ cdef extern from "kaacore/nodes.h" namespace "kaacore" nogil:

optional[int16_t] z_index() except +raise_py_error
void z_index(const optional[int16_t]& z_index) except +raise_py_error
int16_t effective_z_index() except +raise_py_error

CShape shape() except +raise_py_error
void shape(const CShape& shape) except +raise_py_error
Expand Down Expand Up @@ -111,13 +112,16 @@ cdef extern from "kaacore/nodes.h" namespace "kaacore" nogil:

void views(const optional[unordered_set[int16_t]]& z_indices) except +raise_py_error
const optional[vector[int16_t]] views() except +raise_py_error
const vector[int16_t] effective_views() except +raise_py_error

void setup_wrapper(unique_ptr[CForeignNodeWrapper]&& wrapper)
CForeignNodeWrapper* wrapper_ptr() except +raise_py_error

bool indexable() except +raise_py_error
void indexable(const bool indexable) except +raise_py_error

uint16_t root_distance() except +raise_py_error

CBoundingBox bounding_box() except +raise_py_error

CNodeOwnerPtr c_make_node "kaacore::make_node" (CNodeType) except +raise_py_error
19 changes: 19 additions & 0 deletions src/kaa/nodes.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ cdef class NodeBase:
else:
self._get_c_node().views(optional[unordered_set[int16_t]](nullopt))

@property
def effective_views(self):
cdef:
int16_t c_index
set result = set()
vector[int16_t] c_indices = self._get_c_node().effective_views()

for c_index in range(c_indices.size()):
result.add(c_indices[c_index])
return result

@property
def position(self):
return Vector.from_c_vector(self._get_c_node().position())
Expand Down Expand Up @@ -250,6 +261,10 @@ cdef class NodeBase:
else:
self._get_c_node().z_index(optional[int16_t](nullopt))

@property
def effective_z_index(self):
return self._get_c_node().effective_z_index()

@property
def rotation(self):
return self._get_c_node().rotation()
Expand Down Expand Up @@ -391,6 +406,10 @@ cdef class NodeBase:
def indexable(self, bool value):
self._get_c_node().indexable(value)

@property
def root_distance(self):
return self._get_c_node().root_distance()

@property
def bounding_box(self):
return BoundingBox.create(self._get_c_node().bounding_box())
Expand Down

0 comments on commit ccf00fa

Please sign in to comment.