mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
add vec3.with_xy
This commit is contained in:
parent
7a7f91f1cf
commit
4aab227b53
@ -131,6 +131,7 @@ class vec3(_vecD['vec3']):
|
|||||||
def with_x(self, x: float) -> vec3: ...
|
def with_x(self, x: float) -> vec3: ...
|
||||||
def with_y(self, y: float) -> vec3: ...
|
def with_y(self, y: float) -> vec3: ...
|
||||||
def with_z(self, z: float) -> vec3: ...
|
def with_z(self, z: float) -> vec3: ...
|
||||||
|
def with_xy(self, xy: vec2) -> vec3: ...
|
||||||
|
|
||||||
def __init__(self, x: float, y: float, z: float) -> None: ...
|
def __init__(self, x: float, y: float, z: float) -> None: ...
|
||||||
|
|
||||||
|
@ -777,6 +777,17 @@ static bool vec3__xy(int argc, py_Ref argv) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool vec3__with_xy(int argc, py_Ref argv) {
|
||||||
|
PY_CHECK_ARGC(2);
|
||||||
|
PY_CHECK_ARG_TYPE(1, tp_vec2);
|
||||||
|
c11_vec2 xy = py_tovec2(&argv[1]);
|
||||||
|
c11_vec3 res = {
|
||||||
|
{xy.x, xy.y, py_tovec3(argv).z}
|
||||||
|
};
|
||||||
|
py_newvec3(py_retval(), res);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void pk__add_module_linalg() {
|
void pk__add_module_linalg() {
|
||||||
py_Ref mod = py_newmodule("linalg");
|
py_Ref mod = py_newmodule("linalg");
|
||||||
|
|
||||||
@ -898,6 +909,7 @@ void pk__add_module_linalg() {
|
|||||||
py_bindmethod(vec3, "with_x", vec3__with_x);
|
py_bindmethod(vec3, "with_x", vec3__with_x);
|
||||||
py_bindmethod(vec3, "with_y", vec3__with_y);
|
py_bindmethod(vec3, "with_y", vec3__with_y);
|
||||||
py_bindmethod(vec3, "with_z", vec3__with_z);
|
py_bindmethod(vec3, "with_z", vec3__with_z);
|
||||||
|
py_bindmethod(vec3, "with_xy", vec3__with_xy);
|
||||||
|
|
||||||
py_newvec3(py_emplacedict(py_tpobject(vec3), py_name("ZERO")),
|
py_newvec3(py_emplacedict(py_tpobject(vec3), py_name("ZERO")),
|
||||||
(c11_vec3){
|
(c11_vec3){
|
||||||
|
@ -369,3 +369,5 @@ assert vec3(1, 2, 3).xy == vec2(1, 2)
|
|||||||
assert vec3.ONE == vec3(1, 1, 1)
|
assert vec3.ONE == vec3(1, 1, 1)
|
||||||
# test vec3.ZERO
|
# test vec3.ZERO
|
||||||
assert vec3.ZERO == vec3(0, 0, 0)
|
assert vec3.ZERO == vec3(0, 0, 0)
|
||||||
|
# test vec3.with_xy
|
||||||
|
assert vec3(1, 2, 3).with_xy(vec2(4, 5)) == vec3(4, 5, 3)
|
Loading…
x
Reference in New Issue
Block a user