Bug 581 - gluUnProject multiplies matrices in wrong order
Summary: gluUnProject multiplies matrices in wrong order
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 2
Hardware: All all
: --- normal
Assignee: Sven Gothel
Depends on:
Reported: 2012-05-07 22:00 CEST by Wade Walker
Modified: 2012-05-12 04:13 CEST (History)
1 user (show)

See Also:
Type: ---
SCM Refs:
cbc77718f01a8190e1a8aa0e9afdc2a3a3403358 7f85501bd448afc9ba52f6abbe5f049d673d824d
Workaround: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Wade Walker 2012-05-07 22:00:34 CEST
gluUnProject() and gluUnProject4() in ProjectFloat.java and ProjectDouble.java multiply the model and projection matrices in the wrong order.

This seems to be because calls to gluMultMatricesf() and __gluMultMatricesd() (which multiply in column-row order) were replaced by calls to FloatUtil.multMatrixf() and FloatUtil.multMatrixd() (which multiply in row-column order).

This problem appeared in RC6, and was first reported by user "lukej" on the forum at http://forum.jogamp.org/Problems-with-gluUnProject-td3954975.html.
Comment 1 Sven Gothel 2012-05-11 22:48:14 CEST

Fix regression of commit 
ProjectFloat Matrix Multiplication of gluUnProject(..) impl.

ProjectFloat's previous gluMultMatricesf(..) used row-major order,
but the replacement multMatrixf(..) uses column-major order (like OpenGL, ..).

Note: The replaced 'gluMultMatrixVecf' by multMatrixVecf() already
           used column-major order.

Fix: Reverse the arguments of matrix multiplication
    m1 x m2 -> m2 x m1
Comment 2 Sven Gothel 2012-05-12 04:13:49 CEST

Added further unit test w/ actual gluUnProject(..) usage.

Remark: FloatUtil's multMatrixf(..) does column-major multiplication,
i.e. expect the linear matrix layout to be in column order.

In case the implementation does not follow the above statement (you find a bug),
pls re-open this bug report.