From 2e64d36382db8b0f9444659fd019c67740d47c5b Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 10 Apr 2025 08:13:10 +0100 Subject: [PATCH] Update mathTypes.cpp fix matrix types, should of been using columns not the rows --- Engine/source/math/mathTypes.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Engine/source/math/mathTypes.cpp b/Engine/source/math/mathTypes.cpp index c1292ec7d..6558786d6 100644 --- a/Engine/source/math/mathTypes.cpp +++ b/Engine/source/math/mathTypes.cpp @@ -390,15 +390,20 @@ ImplementConsoleTypeCasters( TypeMatrixF, MatrixF ) ConsoleGetType( TypeMatrixF ) { + MatrixF* mat = (MatrixF*)dptr; + + Point3F col0, col1, col2; + mat->getColumn(0, &col0); + mat->getColumn(1, &col1); + mat->getColumn(2, &col2); static const U32 bufSize = 256; char* buffer = Con::getReturnBuffer(bufSize); - F32* mat = (F32*)dptr; - buffer = PropertyInfo::FormatPropertyBuffer(mat + 0, buffer, bufSize); + buffer = PropertyInfo::FormatPropertyBuffer(col0, buffer, bufSize); *buffer++ = ' '; - buffer = PropertyInfo::FormatPropertyBuffer(mat + 4, buffer, bufSize); + buffer = PropertyInfo::FormatPropertyBuffer(col1, buffer, bufSize); *buffer++ = ' '; - buffer = PropertyInfo::FormatPropertyBuffer(mat + 8, buffer, bufSize); + buffer = PropertyInfo::FormatPropertyBuffer(col2, buffer, bufSize); *buffer = '\0'; // null-terminate just in case return buffer; @@ -433,16 +438,24 @@ ConsoleMappedType(MatrixPosition, TypeMatrixPosition, Point3F, MatrixF, "") ConsoleGetType( TypeMatrixPosition ) { - F32* mat = (F32*)dptr; - const char* buff = PropertyInfo::FormatProperty(mat + 8); - return buff; + F32* col = (F32*)dptr + 3; + static const U32 bufSize = 256; + char* returnBuffer = Con::getReturnBuffer(bufSize); + Point4F pos(col[0], col[4], col[8], col[12]); + + if (col[12] == 1.0f) + returnBuffer = PropertyInfo::FormatPropertyBuffer(&pos, returnBuffer, bufSize); + else + returnBuffer = PropertyInfo::FormatPropertyBuffer(&pos, returnBuffer, bufSize); + + return returnBuffer; } ConsoleSetType( TypeMatrixPosition ) { if (argc >= 1) { - F32 parsed[4] = { 1.0f }; // default all to 1.0f + F32 parsed[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; // Combine argv into a single space-separated string if argc > 1 char buffer[256] = { 0 }; dStrncpy(buffer, *argv, sizeof(buffer));