Skip to content

Commit

Permalink
bugfix: native assertion failures at DMat44.h:115
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jan 24, 2025
1 parent ad940dd commit 69a783d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
23 changes: 20 additions & 3 deletions src/main/native/glue/r/RMat44.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2024 Stephen Gold
Copyright (c) 2024-2025 Stephen Gold
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -174,7 +174,16 @@ JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_RMat44_free
JNIEXPORT jdouble JNICALL Java_com_github_stephengold_joltjni_RMat44_getElement
(JNIEnv *, jclass, jlong matrixVa, jint row, jint column) {
const RMat44 * const pMatrix = reinterpret_cast<RMat44 *> (matrixVa);
const Real result = pMatrix->GetColumn4(column)[row];
Real result;
if (column == 3) {
if (row == 3) {
result = 1;
} else {
result = pMatrix->GetTranslation()[row];
}
} else {
result = pMatrix->GetColumn4(column)[row];
}
return result;
}

Expand Down Expand Up @@ -345,7 +354,15 @@ JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_RMat44_multiply3x4r
JNIEXPORT void JNICALL Java_com_github_stephengold_joltjni_RMat44_setElement
(JNIEnv *, jclass, jlong matrixVa, jint row, jint column, jdouble value) {
RMat44 * const pMatrix = reinterpret_cast<RMat44 *> (matrixVa);
pMatrix->GetColumn4(column)[row] = value;
if (column == 3) {
if (row < 3) {
RVec3 copy = pMatrix->GetTranslation();
copy.SetComponent(row, value);
pMatrix->SetTranslation(copy);
}
} else {
pMatrix->GetColumn4(column)[row] = value;
}
}

/*
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/testjoltjni/junit/Test008.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2024 Stephen Gold
Copyright (c) 2024-2025 Stephen Gold
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -163,7 +163,7 @@ private void testRMat44() {
TestUtils.assertEquals(0f, 0f, 0f, 0f,
0f, 0f, 0f, 0f,
0f, 0f, 0f, 0f,
0f, 0f, 0f, 0f,
0f, 0f, 0f, 1f,
zero, 0f);

TestUtils.testClose(zero, trans, rotTrans, rot, identity, uninit);
Expand Down

0 comments on commit 69a783d

Please sign in to comment.