mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
3c64f59fd3
commit
320d2e1f3b
@ -305,6 +305,12 @@ PyObject* py_var(VM*, const PyVec4&);
|
||||
PyObject* py_var(VM*, const Mat3x3&);
|
||||
PyObject* py_var(VM*, const PyMat3x3&);
|
||||
|
||||
#define BIND_VEC_ADDR(D) \
|
||||
vm->bind_method<0>(type, "addr", [](VM* vm, ArgsView args){ \
|
||||
PyVec##D& self = _CAST(PyVec##D&, args[0]); \
|
||||
return VAR_T(VoidP, &self.x); \
|
||||
});
|
||||
|
||||
#define BIND_VEC_VEC_OP(D, name, op) \
|
||||
vm->bind_method<1>(type, #name, [](VM* vm, ArgsView args){ \
|
||||
PyVec##D& self = _CAST(PyVec##D&, args[0]); \
|
||||
@ -385,6 +391,7 @@ struct PyVec2: Vec2 {
|
||||
return VAR(self);
|
||||
});
|
||||
|
||||
BIND_VEC_ADDR(2)
|
||||
BIND_VEC_VEC_OP(2, __add__, +)
|
||||
BIND_VEC_VEC_OP(2, __sub__, -)
|
||||
BIND_VEC_FLOAT_OP(2, __mul__, *)
|
||||
@ -433,6 +440,7 @@ struct PyVec3: Vec3 {
|
||||
return VAR_T(PyVec3, self);
|
||||
});
|
||||
|
||||
BIND_VEC_ADDR(3)
|
||||
BIND_VEC_VEC_OP(3, __add__, +)
|
||||
BIND_VEC_VEC_OP(3, __sub__, -)
|
||||
BIND_VEC_FLOAT_OP(3, __mul__, *)
|
||||
@ -483,6 +491,7 @@ struct PyVec4: Vec4{
|
||||
return VAR_T(PyVec4, self);
|
||||
});
|
||||
|
||||
BIND_VEC_ADDR(4)
|
||||
BIND_VEC_VEC_OP(4, __add__, +)
|
||||
BIND_VEC_VEC_OP(4, __sub__, -)
|
||||
BIND_VEC_FLOAT_OP(4, __mul__, *)
|
||||
|
@ -1,4 +1,5 @@
|
||||
from typing import overload
|
||||
from c import float_p
|
||||
|
||||
class vec2:
|
||||
x: float
|
||||
@ -16,6 +17,7 @@ class vec2:
|
||||
def length_squared(self) -> float: ...
|
||||
def normalize(self) -> vec2: ...
|
||||
def rotate(self, radians: float) -> vec2: ...
|
||||
def addr(self) -> float_p: ...
|
||||
|
||||
class vec3:
|
||||
x: float
|
||||
@ -33,6 +35,7 @@ class vec3:
|
||||
def length(self) -> float: ...
|
||||
def length_squared(self) -> float: ...
|
||||
def normalize(self) -> vec3: ...
|
||||
def addr(self) -> float_p: ...
|
||||
|
||||
class vec4:
|
||||
x: float
|
||||
@ -50,6 +53,7 @@ class vec4:
|
||||
def length(self) -> float: ...
|
||||
def length_squared(self) -> float: ...
|
||||
def normalize(self) -> vec4: ...
|
||||
def addr(self) -> float_p: ...
|
||||
|
||||
class mat3x3:
|
||||
_11: float
|
||||
|
Loading…
x
Reference in New Issue
Block a user