mirror of
https://github.com/Relintai/gdnative_python.git
synced 2024-11-14 10:27:22 +01:00
135 lines
5.3 KiB
Cython
135 lines
5.3 KiB
Cython
{%- block pxd_header %}
|
|
{% endblock -%}
|
|
{%- block pyx_header %}
|
|
|
|
# TODO
|
|
|
|
{{ force_mark_rendered("pandemonium_vector3i_abs") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_clamp") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_get_x") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_get_y") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_get_z") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_length") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_length_squared") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_linear_interpolate") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_max_axis") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_min_axis") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_operator_divide_scalar") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_operator_divide_vector") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_operator_index") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_operator_index_const") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_operator_multiply_scalar") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_operator_multiply_vector") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_set_all") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_set_x") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_set_y") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_set_z") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_sign") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_to_vector3") }}
|
|
{{ force_mark_rendered("pandemonium_vector3i_zero") }}
|
|
|
|
# END TODO
|
|
|
|
from pandemonium._hazmat.gdnative_api_struct cimport pandemonium_vector3i_axis
|
|
{% endblock -%}
|
|
|
|
|
|
@cython.final
|
|
cdef class Vector3i:
|
|
{% block cdef_attributes %}
|
|
cdef pandemonium_vector3i _gd_data
|
|
{% endblock %}
|
|
|
|
{% block python_defs %}
|
|
def __init__(self, pandemonium_int x=0, pandemonium_int y=0, pandemonium_int z=0):
|
|
{{ force_mark_rendered("pandemonium_vector3i_new") }}
|
|
gdapi10.pandemonium_vector3i_new(&self._gd_data, x, y, z)
|
|
|
|
def __repr__(self):
|
|
return f"<Vector3i(x={self.x}, y={self.y}, z={self.z})>"
|
|
|
|
@property
|
|
def x(self) -> pandemonium_int:
|
|
{{ force_mark_rendered("pandemonium_vector3i_get_axis") }}
|
|
return gdapi10.pandemonium_vector3i_get_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_X)
|
|
|
|
@x.setter
|
|
def x(self, pandemonium_int val) -> None:
|
|
{{ force_mark_rendered("pandemonium_vector3i_set_axis") }}
|
|
gdapi10.pandemonium_vector3i_set_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_X, val)
|
|
|
|
@property
|
|
def y(self) -> pandemonium_int:
|
|
{{ force_mark_rendered("pandemonium_vector3i_get_axis") }}
|
|
return gdapi10.pandemonium_vector3i_get_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Y)
|
|
|
|
@y.setter
|
|
def y(self, pandemonium_int val) -> None:
|
|
{{ force_mark_rendered("pandemonium_vector3i_set_axis") }}
|
|
gdapi10.pandemonium_vector3i_set_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Y, val)
|
|
|
|
@property
|
|
def z(self) -> pandemonium_int:
|
|
{{ force_mark_rendered("pandemonium_vector3i_get_axis") }}
|
|
return gdapi10.pandemonium_vector3i_get_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Z)
|
|
|
|
@z.setter
|
|
def z(self, pandemonium_int val) -> None:
|
|
{{ force_mark_rendered("pandemonium_vector3i_set_axis") }}
|
|
gdapi10.pandemonium_vector3i_set_axis(&self._gd_data, pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Z, val)
|
|
|
|
{{ render_operator_eq() | indent }}
|
|
{{ render_operator_ne() | indent }}
|
|
{{ render_operator_lt() | indent }}
|
|
|
|
{{ render_method("operator_neg", py_name="__neg__") | indent }}
|
|
|
|
def __pos__(Vector3i self):
|
|
return self
|
|
|
|
{{ render_method("operator_add", py_name="__add__") | indent }}
|
|
{{ render_method("operator_subtract", py_name="__sub__") | indent }}
|
|
|
|
def __mul__(Vector3i self, val):
|
|
cdef Vector3i _val
|
|
try:
|
|
_val = <Vector3i?>val
|
|
except TypeError:
|
|
return Vector3i_multiply_scalar(self, val)
|
|
else:
|
|
return Vector3i_multiply_vector(self, _val)
|
|
|
|
def __truediv__(Vector3i self, val):
|
|
cdef Vector3i _val
|
|
try:
|
|
_val = <Vector3i?>val
|
|
except TypeError:
|
|
if val is 0:
|
|
raise ZeroDivisionError()
|
|
return Vector3i_divide_scalar(self, val)
|
|
else:
|
|
if _val.x == 0 or _val.y == 0 or _val.z == 0:
|
|
raise ZeroDivisionError()
|
|
return Vector3i_divide_vector(self, _val)
|
|
|
|
{{ render_method("as_string") | indent }}
|
|
{% endblock %}
|
|
|
|
{%- block python_consts %}
|
|
AXIS = IntEnum("AXIS", {
|
|
"X": pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_X,
|
|
"Y": pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Y,
|
|
"Z": pandemonium_vector3i_axis.PANDEMONIUM_VECTOR3I_AXIS_Z,
|
|
})
|
|
|
|
ZERO = Vector3i(0, 0, 0) # Zero vector.
|
|
ONE = Vector3i(1, 1, 1) # One vector.
|
|
INF = Vector3i(math.inf, math.inf, math.inf) # Infinite vector.
|
|
LEFT = Vector3i(-1, 0, 0) # Left unit vector.
|
|
RIGHT = Vector3i(1, 0, 0) # Right unit vector.
|
|
UP = Vector3i(0, 1, 0) # Up unit vector.
|
|
DOWN = Vector3i(0, -1, 0) # Down unit vector.
|
|
FORWARD = Vector3i(0, 0, -1) # Forward unit vector.
|
|
BACK = Vector3i(0, 0, 1) # Back unit vector.
|
|
{% endblock %}
|