View Issue Details

IDProjectCategoryView StatusLast Update
0002257NoesisGUIC++ SDKpublic2022-02-03 10:43
Reportersteveh Assigned Tosfernandez  
PrioritynormalSeveritymajor 
Status resolvedResolutionduplicate 
Product Version3.2.0 
Fixed in Version3.1.3 
Summary0002257: VIsual::PointFromScreen called from a button click - zero determinent, invalid matrix inverse
Description

Hi guys, we're getting an assert when trying to invert a matrix with a zero determinent from seemingly valid inputs when we click a button:

Noesis::Inverse(const Noesis::Matrix4 & m, float determinant) Line 860  C++ Symbols loaded.
Noesis::Inverse(const Noesis::Matrix4 & m) Line 854 C++ Symbols loaded.

Noesis::Visual::PointFromScreen(const Noesis::Point & point) Line 204 C++ Symbols loaded.
Noesis::BaseButton::OnMouseMove(const Noesis::MouseEventArgs & e) Line 359 C++ Symbols loaded.

To get the view projection we're using the default calculated one (i.e. NOT a user projection matrix). My view resolution is 1920 x 1011 (a maximized window on a 1080p monitor, so the actual render target height is only 1011 pixels instead of 1080, so this is not perfectly 16:9 aspect ratio).

t (InternalTransformToRoot()) is the following:

  • t {mVal=0x0000000003dce9a8 {{x=0.468055546 y=0.000000000 z=0.000000000 }, {x=0.000000000 y=0.468055546 ...}, ...} } Noesis::Transform3
  • mVal 0x0000000003dce9a8 {{x=0.468055546 y=0.000000000 z=0.000000000 }, {x=0.000000000 y=0.468055546 z=0.000000000 }, ...} Noesis::Vector3[4]
  • [0] {x=0.468055546 y=0.000000000 z=0.000000000 } Noesis::Vector3
  • [1] {x=0.000000000 y=0.468055546 z=0.000000000 } Noesis::Vector3
  • [2] {x=0.000000000 y=0.000000000 z=1.00000000 } Noesis::Vector3
  • [3] {x=93.6111069 y=210.625000 z=0.000000000 } Noesis::Vector3

Projection Matrix is as follows:

  • proj {mVal=0x0000000003dcea20 {{x=1.00000000 y=0.000000000 z=0.000000000 ...}, {x=-0.000000000 y=1.00000000 ...}, ...} } Noesis::Matrix4
  • mVal 0x0000000003dcea20 {{x=1.00000000 y=0.000000000 z=0.000000000 ...}, {x=-0.000000000 y=1.00000000 z=-0.000000000 ...}, ...} Noesis::Vector4[4]
  • [0] {x=1.00000000 y=0.000000000 z=0.000000000 ...} Noesis::Vector4
    x 1.00000000 float
    y 0.000000000 float
    z 0.000000000 float
    w 0.000000000 float
  • [1] {x=-0.000000000 y=1.00000000 z=-0.000000000 ...} Noesis::Vector4
    x -0.000000000 float
    y 1.00000000 float
    z -0.000000000 float
    w -0.000000000 float
  • [2] {x=0.960000038 y=0.505500019 z=0.00100000005 ...} Noesis::Vector4
    x 0.960000038 float
    y 0.505500019 float
    z 0.00100000005 float
    w 0.00100000005 float
  • [3] {x=0.000000000 y=0.000000000 z=0.999499977 ...} Noesis::Vector4
    x 0.000000000 float
    y 0.000000000 float
    z 0.999499977 float
    w 1.00000000 float

mtx (t * proj) is as follows

  • mtx {mVal=0x0000000003dcea60 {{x=0.468055546 y=0.000000000 z=0.000000000 ...}, {x=0.000000000 y=0.468055546 ...}, ...} } Noesis::Matrix4
  • mVal 0x0000000003dcea60 {{x=0.468055546 y=0.000000000 z=0.000000000 ...}, {x=0.000000000 y=0.468055546 z=...}, ...} Noesis::Vector4[4]
  • [0] {x=0.468055546 y=0.000000000 z=0.000000000 ...} Noesis::Vector4
    x 0.468055546 float
    y 0.000000000 float
    z 0.000000000 float
    w 0.000000000 float
  • [1] {x=0.000000000 y=0.468055546 z=0.000000000 ...} Noesis::Vector4
    x 0.000000000 float
    y 0.468055546 float
    z 0.000000000 float
    w 0.000000000 float
  • [2] {x=0.960000038 y=0.505500019 z=0.00100000005 ...} Noesis::Vector4
    x 0.960000038 float
    y 0.505500019 float
    z 0.00100000005 float
    w 0.00100000005 float
  • [3] {x=93.6111069 y=210.625000 z=0.999499977 ...} Noesis::Vector4
    x 93.6111069 float
    y 210.625000 float
    z 0.999499977 float
    w 1.00000000 float

These are the properties inside the Determinent method:

  • m {mVal=0x0000000003dcea60 {{x=0.468055546 y=0.000000000 z=0.000000000 ...}, {x=0.000000000 y=0.468055546 ...}, ...} } const Noesis::Matrix4 &
  • mVal 0x0000000003dcea60 {{x=0.468055546 y=0.000000000 z=0.000000000 ...}, {x=0.000000000 y=0.468055546 z=...}, ...} Noesis::Vector4[4]
  • [0] {x=0.468055546 y=0.000000000 z=0.000000000 ...} Noesis::Vector4
    x 0.468055546 float
    y 0.000000000 float
    z 0.000000000 float
    w 0.000000000 float
  • [1] {x=0.000000000 y=0.468055546 z=0.000000000 ...} Noesis::Vector4
    x 0.000000000 float
    y 0.468055546 float
    z 0.000000000 float
    w 0.000000000 float
  • [2] {x=0.960000038 y=0.505500019 z=0.00100000005 ...} Noesis::Vector4
    x 0.960000038 float
    y 0.505500019 float
    z 0.00100000005 float
    w 0.00100000005 float
  • [3] {x=93.6111069 y=210.625000 z=0.999499977 ...} Noesis::Vector4
    x 93.6111069 float
    y 210.625000 float
    z 0.999499977 float
    w 1.00000000 float
    v0 154.879593 float
    v1 0.865908921 float
    v2 0.866388917 float
    v3 0.294622242 float
    v4 0.294875026 float
    v5 5.00003807e-07 float
    t00 2.34029557e-07 float
    t10 -0.000000000 float
    t20 -0.405518144 float
    t30 0.405293465 float

The v5 is pretty much zero and when multiplied through the matrix's first column it ends up returning zero for each component:

Steps To Reproduce

Use this function to use the same properties as me and then click a button.

Point PointFromScreenTest(/const Point& point/)
{
Point point(302.0f, 401.0f);
//Transform3 t = InternalTransformToRoot();
Transform3 t(
0.468055546f, 0.0f, 0.0f,
0.0f, 0.468055546f, 0.0f,
0.0f, 0.0f, 1.0f,
93.6111069f, 210.625f, 0.0f);

float det = Determinant(t.Rotation());
if (fabsf(det) < FLT_EPSILON)
{
    return Point(FLT_INF, FLT_INF);
}

//Matrix4 proj = GetViewProjectionMatrix(mView);
Matrix4 proj(
    1.0f,   0.0f,       0.0f,   0.0f,
    0.0f,   1.0f,       0.0f,   0.0f,
    0.96f,  0.5055f,    0.001f, 0.001f,
    0.0f,   0.0f,       1.0f,   1.0f
);
Matrix4 mtx = t * proj;
Matrix4 invMtx = Inverse(mtx);
Vector4 dir = Vector4(point, 1.0f, 1.0f) * invMtx;

Vector4 p = Vector4(0.0f, 0.0f, 0.0f, 1.0f) * invMtx;
p /= p.w;

return IntersectPlane(p, dir, Matrix4::Identity()).first;

}

PlatformAny

Relationships

duplicate of 0002202 resolvedhcpizzi 3D UI interaction broken 

Activities

steveh

steveh

2022-02-03 01:20

reporter   ~0007771

Ah, sorry, I think this is a dupe of 0002202 and have fixed in r11159 and r11170

steveh

steveh

2022-02-03 01:31

reporter   ~0007772

Just to confirm, I've integrated r11159 and r11170 into our version of 3.1.2 (with the Arabic branch merged in as well), and it fixed out reliable repro case.

sfernandez

sfernandez

2022-02-03 10:43

manager   ~0007773

Thanks for the confirmation Steve, marking this as solved.

Issue History

Date Modified Username Field Change
2022-02-03 01:09 steveh New Issue
2022-02-03 01:10 steveh Summary VIsual::PointFromScreen bad maths => VIsual::PointFromScreen called from a button click - zero determinent, invalid matrix inverse
2022-02-03 01:20 steveh Note Added: 0007771
2022-02-03 01:31 steveh Note Added: 0007772
2022-02-03 10:43 sfernandez Assigned To => sfernandez
2022-02-03 10:43 sfernandez Status new => resolved
2022-02-03 10:43 sfernandez Resolution open => duplicate
2022-02-03 10:43 sfernandez Fixed in Version => 3.1.3
2022-02-03 10:43 sfernandez Note Added: 0007773
2022-02-03 10:43 sfernandez Relationship added duplicate of 0002202