Author Topic: UIDraggablePanel positioning bug  (Read 3732 times)

electrodruid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 48
    • View Profile
UIDraggablePanel positioning bug
« on: February 27, 2013, 09:00:48 AM »
Hi,

I've run into a problem with UIDraggablePanel - namely, dragging it around can change the panel's z position as well as its x and y. The z coordinate only changes by a small amount (something like 0.000001), but it can be enough to push the panel behind other elements and stop it being visible, which is how I came to notice the problem in the first place. Dragging the panel made it disappear. Moving it forward a bit stopped the panel disappearing, but it does still move in z, which made me curious.

After a bit of hunting around, it seems that the problem comes from rounding errors to do with the raycast in the Drag method. The problem goes away if I add "offset.z = 0;" somewhere around line 525, but I don't know for sure if this is the best fix for the problem, or if it creates any other problems, so I thought I'd mention it here. I haven't looked to see if it also affects other widgets that rely on raycasting.

Annoyingly, it doesn't seem to happen in Example 7, so I don't know exactly what set of circumstances is required to throw the raycast out enough for it to have an effect.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel positioning bug
« Reply #1 on: February 27, 2013, 09:24:57 AM »
You need to adjust the panel's Z by a notable margin to begin with. Scrollable panel should have Z of -1.

electrodruid

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 48
    • View Profile
Re: UIDraggablePanel positioning bug
« Reply #2 on: February 28, 2013, 08:42:25 AM »
Well that's what I do to avoid any visual issues. My panel is at Z = -5, in fact. But after scrolling, it becomes -5.000001. Obviously that's only a tiny change, and one that shouldn't affect most people. In the grand scheme of things I'm not expecting you to drop everything and make it your top priority  ;) I just thought you might like to know, and that it might be useful for other people who are searching the forums trying to figure out why their panel disappears when they drag it.