Skip to content

Commit

Permalink
(draft) Added abs for matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuzu-Typ committed Feb 4, 2024
1 parent 68f1243 commit bf6b20f
Show file tree
Hide file tree
Showing 45 changed files with 71 additions and 117 deletions.
6 changes: 5 additions & 1 deletion PyGLM/type_methods/mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,11 @@ template<int C, int R, typename T>
static PyObject *
mat_abs(mat<C, R, T> *obj)
{
return pack_mat<C, R, T>(glm::abs(obj->super_type));
glm::mat<C, R, T> m = obj->super_type;
for (int c = 0; c < C; c++) {
m[c] = glm::abs(m[c]);
}
return pack_mat<C, R, T>(m);
}

// binaryfunc
Expand Down
4 changes: 2 additions & 2 deletions PyGLM/types/mat/double/mat2x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ static PyNumberMethods hdmat2x2NumMethods = {
(binaryfunc)mat_mul<2, 2, double>, //nb_multiply
0, //nb_remainder
0, //nb_divmod
0, //nb_power
0, //nb_poweri
(unaryfunc)mat_neg<2, 2, double>, //nb_negative
(unaryfunc)mat_pos<2, 2, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 2, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat2x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat2x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 3, double>, //nb_negative
(unaryfunc)mat_pos<2, 3, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 3, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat2x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat2x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 4, double>, //nb_negative
(unaryfunc)mat_pos<2, 4, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 4, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat3x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat3x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 2, double>, //nb_negative
(unaryfunc)mat_pos<3, 2, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 2, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat3x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat3x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 3, double>, //nb_negative
(unaryfunc)mat_pos<3, 3, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 3, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat3x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat3x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 4, double>, //nb_negative
(unaryfunc)mat_pos<3, 4, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 4, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat4x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat4x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 2, double>, //nb_negative
(unaryfunc)mat_pos<4, 2, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 2, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat4x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat4x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 3, double>, //nb_negative
(unaryfunc)mat_pos<4, 3, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 3, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/double/mat4x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hdmat4x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 4, double>, //nb_negative
(unaryfunc)mat_pos<4, 4, double>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 4, double>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat2x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat2x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 2, float>, //nb_negative
(unaryfunc)mat_pos<2, 2, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 2, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat2x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat2x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 3, float>, //nb_negative
(unaryfunc)mat_pos<2, 3, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 3, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat2x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat2x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 4, float>, //nb_negative
(unaryfunc)mat_pos<2, 4, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 4, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat3x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat3x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 2, float>, //nb_negative
(unaryfunc)mat_pos<3, 2, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 2, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat3x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat3x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 3, float>, //nb_negative
(unaryfunc)mat_pos<3, 3, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 3, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat3x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat3x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 4, float>, //nb_negative
(unaryfunc)mat_pos<3, 4, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 4, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat4x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat4x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 2, float>, //nb_negative
(unaryfunc)mat_pos<4, 2, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 2, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat4x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat4x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 3, float>, //nb_negative
(unaryfunc)mat_pos<4, 3, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 3, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/float/mat4x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods hfmat4x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 4, float>, //nb_negative
(unaryfunc)mat_pos<4, 4, float>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 4, float>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat2x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat2x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 2, glm::i32>, //nb_negative
(unaryfunc)mat_pos<2, 2, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 2, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat2x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat2x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 3, glm::i32>, //nb_negative
(unaryfunc)mat_pos<2, 3, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 3, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat2x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat2x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<2, 4, glm::i32>, //nb_negative
(unaryfunc)mat_pos<2, 4, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<2, 4, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat3x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat3x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 2, glm::i32>, //nb_negative
(unaryfunc)mat_pos<3, 2, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 2, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat3x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat3x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 3, glm::i32>, //nb_negative
(unaryfunc)mat_pos<3, 3, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 3, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat3x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat3x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<3, 4, glm::i32>, //nb_negative
(unaryfunc)mat_pos<3, 4, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<3, 4, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat4x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat4x2NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 2, glm::i32>, //nb_negative
(unaryfunc)mat_pos<4, 2, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 2, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat4x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat4x3NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 3, glm::i32>, //nb_negative
(unaryfunc)mat_pos<4, 3, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 3, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/int/mat4x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods himat4x4NumMethods = {
0, //nb_power
(unaryfunc)mat_neg<4, 4, glm::i32>, //nb_negative
(unaryfunc)mat_pos<4, 4, glm::i32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_abs<4, 4, int32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat2x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat2x2NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<2, 2, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<2, 2, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat2x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat2x3NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<2, 3, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<2, 3, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat2x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat2x4NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<2, 4, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<2, 4, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat3x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat3x2NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<3, 2, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<3, 2, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat3x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat3x3NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<3, 3, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<3, 3, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat3x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat3x4NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<3, 4, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<3, 4, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat4x2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat4x2NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<4, 2, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<4, 2, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat4x3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat4x3NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<4, 3, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<4, 3, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
2 changes: 1 addition & 1 deletion PyGLM/types/mat/uint/mat4x4.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static PyNumberMethods humat4x4NumMethods = {
0, //nb_power
0, //nb_negative
(unaryfunc)mat_pos<4, 4, glm::u32>, //nb_positive
0, //nb_absolute
(unaryfunc)mat_pos<4, 4, uint32>, //nb_absolute
0, //nb_bool
0, //nb_invert
0, //nb_lshift
Expand Down
Loading

0 comments on commit bf6b20f

Please sign in to comment.