Trenchbroom: Scaling textures in UV editor getting harder when scale less then 1

Created on 28 Aug 2019  路  6Comments  路  Source: TrenchBroom/TrenchBroom

System Information

TrenchBroom V2019.6 on Windows 10

Expected Behavior

Scaling textures in UV editor using gray texture grid lines should be an identically simple procedure for both big texture scale (2) and for small scale (0.1)

Actual Behavior

For small scale (0.4 and less) texture scaling with grid lines becomes harder, and instead of scaling, texture just moving around (like with simple dragging texture with left mouse button outside of grid lines).

Steps to Reproduce

  1. Create a brush with a texture
  2. Select face of the brush to use UV editor
  3. Try scaling texture with gray grid lines (it will work fine)
  4. Manually change texture scale to 0.3 / 0.3 or less
  5. Try scaling again in UV editor using gray grid lines

Additional info

I found out that the real issue is - when scaling texture with big initial scale factor (1 and more) - when you moving mouse cursor towards gray grid line and it becomes active (red) - you can immediately drag it and it works fine. But with scale less then 1 it becomes gradually more difficult, because you should be very precise, to the point when scaling with scaling factor 0.3 and less becomes almost impossible.
Take notice, then with big scale factor (4 for example) - "active" space around grid line becomes really big (even more then necessary). And with scale 0.5 - you should be very precise, and even when grid line getting active (red) - it doesn't mean it is really active unless your cursor is right on the grid line.

Sorry for long explanation - gif will probably be more descriptive.

  1. Small scale (0.2):
    1
  1. Big scale (4):
    2

  2. Notice that for big scale - if you start dragging from the "edge" of "active" zone (when grid gets red) - it's won't really be "active" (so "red" - doesn't always mean "active")
    3

1 Bug

Most helpful comment

Upgraded priority because it can almost make scaling in UV view unusable.

All 6 comments

I ran into this today. It becomes more relevant when you make the jump to big (2K, 4K, etc) textures, since you'll be operating at very small scale levels (0.05 and below for 2K) a lot of the time.

Upgraded priority because it can almost make scaling in UV view unusable.

I can have a look

Fix in progress, I tracked it down to two interacting problems:

  1. UVViewHelper::pickTextureGrid seems to be wrong. This is the "allowed mouse distance from a grid line" to grab it. With texture scale 5 and max zoom, you have a threshold of about 32 pixels, but with scale 0.2 and max zoom you have about 1 pixel max error to get the grid line turns red. This one should be easy to fix.

  2. More of a design problem: we don't generate DragStart's until the mouse has moved 2px (InputEvent.cpp), but picking is being constantly updated, so the picking that the DragStart event sees may not hit the same handle that was under the mouse when it was clicked.

    I'm trying a hack in ToolBoxConnector::processDragStart that moves the mouse back to where it was when clicked, which fixes the problem, though there are other ways we could tackle it I guess.

Re 2., there already is code to compensate for the drag start having the wrong mouse position, see `InputEvent::recordEvent' line 164 (probably), where it records a drag start event:

m_queue.enqueueEvent(std::make_unique<MouseEvent>(MouseEvent::Type::DragStart, button, wheelAxis, m_lastClickX, m_lastClickY, scrollDistance));

See that it uses the last click position to set the X/Y coordinates, so ToolBoxConnector::processDragStart will have the correct coordinates to work with. It doesn't update the pick result there, which looks like the culprit to me. I think you should just call updatePickResult() before forwarding the event to the tool chain, that should fix it.

looks like I broke picking the scale gridlines when the texture is rotated, will investigate

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dumptruckDS picture dumptruckDS  路  5Comments

totalnewbie picture totalnewbie  路  3Comments

kduske picture kduske  路  4Comments

AlpacaNox picture AlpacaNox  路  5Comments

ericwa picture ericwa  路  4Comments