john-chapman / im3d

Immediate mode rendering and 3d gizmos.
MIT License
1.18k stars 63 forks source link

Snapping is broken for non-xyz translation #32

Closed KenzieMac130 closed 6 years ago

KenzieMac130 commented 6 years ago

Sometimes when the snapping value is set above 0.0f any translation on (XY, YZ, XZ, or View) results in the position to be set to NAN.

john-chapman commented 6 years ago

(Sorry I closed this issue by mistake).

I don't think I saw this before, is it just an issue when using snapping or does it happen under normal use of the gizmos?

KenzieMac130 commented 6 years ago

It only happens with snapping enabled. my program is a bit different than the demos (most relevant probably being it uses Z up). Its a little hard to describe the behavior, I'll just quickly demonstrate it in a video here: https://www.youtube.com/watch?v=Poi5M1W_YfM&feature=youtu.be (apologies for the audio issues, I'm not sure what is causing this) It sometimes doesn't behave like this but I'm not quite sure why.

(Edit:) (I was able to capture it working somewhat earlier but as soon as I grab the middle it Nans) https://www.youtube.com/watch?v=okKOX6h8e54&feature=youtu.be

john-chapman commented 6 years ago

Ok, thanks for the info - video is very useful for repro on this kind of issue, so thanks for that. I'll take a look at this during the weekend and get back to you asap.

john-chapman commented 6 years ago

This should now be fixed. The issue was happening only when the position of the gizmo was 0,0,0 (there was a divide-by-zero in the code).

KenzieMac130 commented 6 years ago

Alright, I'll test it out as soon as I can and get back to you.

KenzieMac130 commented 6 years ago

Yep, that fixed it thank you!