Jump to content

[SOLVED] WidgetManipulatorTranslator on orthographic view


photo

Recommended Posts

In addition to our main 3D application, we have a 2D top-down view, typically running in a separate interface window, where instructors can get a nice overview of the entire simulation. Some simple tasks can be performed directly on the 2D view, like moving objects around (obviously on the XY plane only). When trying to use the WidgetManipulatorTranslator for moving objects around however both the widget and object disappear into oblivion. A very simple repro is to have insert this code into the init() function an empty Unigine 2.12 script-only project:

    WidgetManipulatorTranslator wmt = new WidgetManipulatorTranslator(engine.getGui());
    wmt.setProjection(ortho(-1.f, 1.f, -1.f, 1.f, -500.f, 500.f));
    engine.gui.addChild(wmt, GUI_ALIGN_OVERLAP);

When you drag the widget using the little square it works, but once you drag the arrow for the Y-axis the transform matrix changes to NaN for some reason. Is this something that can be fixed?

Link to comment

Thanks, that looks a lot better. I wasn't able to test it completely since our main code base is still on 2.11 so I had to cherry pick the relevant changes but I did not see a NaN transform anymore after that. I did notice sometimes it selected the wrong axis, e.g. when the cursor was near the X-axis it would pick the Y-axis instead. I'm not sure whether this is another issue or this is caused from our code still being on 2.11, I will retest once we have time to test 2.12 (or 2.13 alpha if that comes in sooner).

Link to comment

More likely that's another bug. Some axes should be hidden in ortho mode, but this feature is not implemented.

We do recommend to create your own manipulators using the WidgetCanvas instead of using default ones. It will give you more control and flexibility.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Yeah, we are thinking of eventually creating new gizmos, but our planning is rather filled up at the moment so for the upcoming releases we will have to use whatever is available now.

Link to comment
  • 2 weeks later...
On 9/24/2020 at 5:10 PM, silent said:

Bemined

Please check the modified sourc e/engine/gui/widgets/WidgetManipulator.cpp in attachment. It should fix this behavior.

 

WidgetManipulator.zip 1.57 kB · 1 download

@silent I'm afraid this fix isn't working after all. I initially tested only with the arrows which worked fine, but just now discovered you cannot select the planes anymore that allow you to move around two axis at once.

Edited by Bemined
Link to comment

It looks this error is caused by the missing parentheses that leads to a different results:

// source/engine/gui/widgets/WidgetManipulator.cpp
// bad results:
return p0 - direction * dot(plane, p0) / Math::sign(dir_plane_proj) * Math::max(Math::abs(dir_plane_proj), Scalar(UNIGINE_EPSILON));

//good results:
return p0 - direction * dot(plane, p0) / (Math::sign(dir_plane_proj) * Math::max(Math::abs(dir_plane_proj), Scalar(UNIGINE_EPSILON)));

Could you please check if it will work?

Thanks!

 

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
  • silent changed the title to [SOLVED] WidgetManipulatorTranslator on orthographic view
×
×
  • Create New...