This commit is contained in:
blueloveTH 2023-05-12 14:13:57 +08:00
parent 5cf6267f5b
commit 8d9761c6b5
2 changed files with 19 additions and 9 deletions

View File

@ -562,17 +562,22 @@ struct PyMat3x3: Mat3x3{
return VAR_T(PyMat3x3, self / other); return VAR_T(PyMat3x3, self / other);
}); });
vm->bind_method<1>(type, "__matmul__", [](VM* vm, ArgsView args){ auto f_mm = [](VM* vm, ArgsView args){
PyMat3x3& self = _CAST(PyMat3x3&, args[0]); PyMat3x3& self = _CAST(PyMat3x3&, args[0]);
PyMat3x3& other = CAST(PyMat3x3&, args[1]); if(is_non_tagged_type(args[1], PyMat3x3::_type(vm))){
PyMat3x3& other = _CAST(PyMat3x3&, args[1]);
return VAR_T(PyMat3x3, self.matmul(other)); return VAR_T(PyMat3x3, self.matmul(other));
}); }
if(is_non_tagged_type(args[1], PyVec3::_type(vm))){
PyVec3& other = _CAST(PyVec3&, args[1]);
return VAR_T(PyVec3, self.matmul(other));
}
vm->TypeError("unsupported operand type(s) for @");
return vm->None;
};
vm->bind_method<1>(type, "matmul", [](VM* vm, ArgsView args){ vm->bind_method<1>(type, "__matmul__", f_mm);
PyMat3x3& self = _CAST(PyMat3x3&, args[0]); vm->bind_method<1>(type, "matmul", f_mm);
PyMat3x3& other = CAST(PyMat3x3&, args[1]);
return VAR_T(PyMat3x3, self.matmul(other));
});
vm->bind_method<1>(type, "__eq__", [](VM* vm, ArgsView args){ vm->bind_method<1>(type, "__eq__", [](VM* vm, ArgsView args){
PyMat3x3& self = _CAST(PyMat3x3&, args[0]); PyMat3x3& self = _CAST(PyMat3x3&, args[0]);

View File

@ -64,8 +64,13 @@ class mat3x3:
def __sub__(self, other: mat3x3) -> mat3x3: ... def __sub__(self, other: mat3x3) -> mat3x3: ...
def __mul__(self, other: float) -> mat3x3: ... def __mul__(self, other: float) -> mat3x3: ...
def __truediv__(self, other: float) -> mat3x3: ... def __truediv__(self, other: float) -> mat3x3: ...
@overload
def __matmul__(self, other: mat3x3) -> mat3x3: ... def __matmul__(self, other: mat3x3) -> mat3x3: ...
@overload
def __matmul__(self, other: vec3) -> vec3: ...
@overload
def matmul(self, other: mat3x3) -> mat3x3: ... def matmul(self, other: mat3x3) -> mat3x3: ...
@overload
def matmul(self, other: vec3) -> vec3: ... def matmul(self, other: vec3) -> vec3: ...
def determinant(self) -> float: ... def determinant(self) -> float: ...
def transpose(self) -> mat3x3: ... def transpose(self) -> mat3x3: ...