Upbge: Matrix Transforms don't work correctly.

Created on 20 Jun 2020  路  14Comments  路  Source: UPBGE/upbge

In UPBGE version 2.5 & 2.5a, attempting to assign a matrix transform to a game object fails to assign the correct scale.

Instead it appears to assign the adjugated() Matrix to the scale of the object.

Test the attached *.blend file to see the error:

https://www.dropbox.com/s/315ucajbabss2px/Test.blend?dl=0

On a personal note. Thank you.
UPBGE is wonderful!
image

0.2.5 0.3 bug

Most helpful comment

Fixed in 0.2.5 branch.
image

Here you have a build including the fix: https://mega.nz/file/F4d3QC7K#s5h4qzBsMucvN3ttsHrz97mNepPWYLzBV7Lirq4ODSg

Thanks for reporting.

All 14 comments

you can try:

if sensor.status == 1: #instead of if sensor.positive

Else, I think it is a bit weird to assign a scale matrix to the WorldTransform directly.
I'd do: own.worldTransform = own.worldTransform * scaleMatrix

@youle31 thank you for the interesting input!
1)
sensor.positive == 1. Is this somehow more efficient?
2)
The Matrix that is being applied in this test is not a "scale matrix', it is a 4x4 transform matrix.
Your suggestion own.worldTransform = own.worldTransfrom*scaleMatrix still results in the same incorrect result.
3)
Being able to directly input Transfoms directly is weird? I felt that this is the best way to store an objects location,rotation and scale? Is there more sensible way to do this?

in upbge 0.3.0 it's working correctly @youle31 I am not sure what changed

This is because 0.2.5 uses another math library. I will check it

@lordloki :pray: If it is of any help:
When I try to set the transform to a specific matrix, the object's transform matrix is set to the adjugated() matrix rather than the matrix itself.

To get the original matrix back:
Fixed_matrix = Matrix.adjugated ()* matrix.inverse ()

My suspicion is that the matrix is being applied to both local and global Transforms at the same time.
This is resulting in a matrix*matrix like problem?

@Feral3d : I advised to use:

if sensor.status == 1: #instead of if sensor.positive

sensor.status == 1, not sensor.positive == 1.

ok, i saw the bug...

Some more info:
This is caused by some commit between 0.2.2 and 0.2.3. I think the most probably one is the moto to mathfu replacement.
The issue is not in the matrix creation is in the matrix asignning.
image

Yes @lordloki you are 100% correct. Everything seems fine until I assign the Matrix directly to the world or local transform.

The issue is in KX_GameObject::pyattr_set_worldTransform
exactly in the rotation matrix as it should be:
1.0, 0.0, 0.0
0.0, 1.0, 0.0
0.0, 0.0, 1.0
and it is
0.75, 0.0, 0.0
0.0, 0.75, 0.0
0.0, 0.0, 0.75

I will fix tomorrow or tomorrow after.
localTransform has the same issue

Thank you @lordloki x (10, 10, 10)

Fixed in 0.2.5 branch.
image

Here you have a build including the fix: https://mega.nz/file/F4d3QC7K#s5h4qzBsMucvN3ttsHrz97mNepPWYLzBV7Lirq4ODSg

Thanks for reporting.

Great! Thanks very much lordloki!

Thank you so much @lordloki !! You are a life-saver!
0,.....,o

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marechal-p picture marechal-p  路  6Comments

NatGazer picture NatGazer  路  7Comments

cederom picture cederom  路  7Comments

joelgomes1994 picture joelgomes1994  路  7Comments

BlenderDoc picture BlenderDoc  路  4Comments