Skip to content

Commit

Permalink
Implementation of YoYoGames/GameMaker-Bugs#2960
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Rennie committed Oct 31, 2024
1 parent 8f3dd2e commit ab51a70
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/Matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,15 @@ Matrix.prototype.Invert = function(that)

this.m = b;
}

if (det != 0)
{
return true;
}
else
{
return false; // indicate that we couldn't invert the matrix
}
};

Matrix.prototype.TransformVec3 = function(_vec)
Expand Down
22 changes: 22 additions & 0 deletions scripts/functions/Function_D3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ function gpu_set_state(){}
var matrix_build = WebGL_Matrix_Build;
var matrix_multiply = WebGL_Matrix_Multiply;
var matrix_transform_vertex = WebGL_Matrix_Transform_Vertex;
var matrix_inverse = WebGL_Matrix_Inverse;

var matrix_stack_push = WebGL_matrix_stack_push;
var matrix_stack_pop = WebGL_matrix_stack_pop;
Expand Down Expand Up @@ -911,6 +912,27 @@ function WebGL_Matrix_Transform_Vertex(_mat, _x, _y, _z)
return res;
}

function WebGL_Matrix_Inverse(_s1) {

var s1 = new Matrix();
var inv_s1 = new Matrix();

for (var i = 0; i < 16; i++) {
s1.m[i] = yyGetReal(_s1[i]);
}
var success = inv_s1.Invert(s1);
if (!success)
{
return undefined;
}

var mat = [];
for (var i = 0; i < 16; i++) {
mat[i] = inv_s1.m[i];
}
return mat;
}

function WebGL_matrix_stack_push(_matrix)
{
if (g_matstacktop >= g_maxmatstack)
Expand Down

0 comments on commit ab51a70

Please sign in to comment.