Orientation Matrix Bugged?

Hey. While I was making an example file for someone, I stumbled upon an orientation matrix bug. It seems like it operates in the opposite direction to the way it should. For example, +Y (localOrientation[1]) is correct, but +X becomes -X - the object’s matrix points in the opposite direction.

Here’s a blend file to ensure I’m not insane. It starts off okay, but rotate the object in Blender (where you can see where local +Y should be), and the local orientation is flipped in the BGE (seen by the red line).

ReflectTest.blend (441 KB)

I noticed the same bug whilst working on multiplayer stuff. Interestingly, rotating the object 180* along the local Y solves this. I wonder if this could have come about from the 2.63a bugfix. Perhaps I shall report it and see.

Okay, I’ll bite. I have had enough problems in the past with the BGE, linear algebra and matrix transformations, so I want to subscribe to this thread.

I played with it systematically and there is something that is not quite right, though I am not sure what it is. Putting the model into top view and rotating in the global Z-axis

Rotation…screen direction of local Y-axis vector…direction of Y-axis, (or forward,) vector
0 degrees :…(0,1,0)…(0,1,0)
45 degrees :…(-0.7,0.7,0)…(0.7,0.7,0)
90 degrees :…(-1,0,0)…(1,0,0)
135 degrees :…(-0.7,-0.7,0)…(0.7,-0.7,0)
180 degrees :…(0,-1,0)…(0,-1,0)
225 degrees :…(0.7,-0.7,0)…(-0.7,-0.7,0)
270 degrees :…(1,0,0)…(-1,0,0)
315 degrees :…(0.7,0.7,0))…(-0.7,0.7,0)
360 degrees :…(0,1,0)…(0,1,0)

Noting that where the thing appears to be correct, the x coordinate is zero, I would hazard a guess and say that x coordinate of the forward vector is always negative of what it should be?

The real question is why?

Edit:
@agoose77 when you look in the top view, rotating 180 degrees in the local Y-axis, is effectively multiplying the X coordinate of the local Y-axis vector by -1.

I should have mentioned that this seems to appear for all orientations - both local and world, and probably along all three axes (I didn’t check localOrientation[2]). Glad it’s not just me who’s experiencing this problem.

is changed from 2.62 or something .

what first was
obj.orientation[1]
now is in
obj.orientation.col[1]

before:
[x][x][x]
[y][y][y]
[z][z][z]

now:
[x][y][z]
[x][y][z]
[x][y][z]

now you have to add “.col”

bit too logorreich!

Ah, thanks for that, Marco - that totally solved the issue!

I found this changes:

This means Matrix is not incorrect, but the access was changed.

For unique access following enhancement was added (as MacoIT mentioned)

This is included in the current Blender API

I didn’t notified this as well. I got the comments from the subversion history of “mathutils_Matrix.c”