difficulty targeting a 3D object with release V1.30

Started by jaco robier, December 29, 2015, 08:52:00 PM

Previous topic - Next topic

jaco robier

my menus in 3D does not work with the v1.30 release:
the problem is that if you click on a 3D object, the 3D object is not selected. Sometimes it works after 3 clicks ...

I only use these 2 functions:
SimpleVector dir = Interact2D.reproject2D3DWS (cam, fb, Clickx, clicky) .normalize ();
float res=Cube.calcMinDistance(cam.getPosition (), dir);

In v1.28+v1.29 works fine: It's always return res=25 when i click on the 3D object.
in V1.30: it's return res=9.99999995904E11 when i click on the 3D object ?!?

Have you got any ideas?
Cordialy

EgonOlsen

Only a feeling...are you doing these calculations in the touch event method/thread? If so, don't do this but do it in the render thread instead. jPCT-AE isn't thread safe. If you are doing it in the render thread, I need a test case. I don't have this problem nor do I remember any changes in that part.

jaco robier

these 2 functions are used in the render thread :
SimpleVector dir = Interact2D.reproject2D3DWS (cam, fb, Clickx, clicky) .normalize ();
float res=Cube.calcMinDistance(cam.getPosition (), dir);

and ClickX and ClickY are calculated in the touch event method/thread.

I checked the first function (Interact2D.reproject2D3DWS (cam, fb, Clickx, clicky) .normalize () by projecting a 3D ball from the click : it's seems correct ...(see picture). http://www.jpct.net/forum2/Smileys/default/huh.gif

EgonOlsen

Have you tried the calcMinDistance() version that takes an additional max. distance parameter? Set it to something large like 1000 or 10000 and see, if that changes something. If it doesn't, I need a test case. I can't reproduce this problem, everything works fine in my tests.

EgonOlsen

I checked the code changes regarding ray-polygon stuff and all that happended was that I converted a lot of floats to doubles (but I can't spot any error in those) and that I made a constant smaller (but I don't see, why this should have a negative impact). If you can provide me with a test case, I can revert these changes and see if that chanegs something. But as said: In my tests, all is well.... ???

jaco robier

I  tested the menu 3D on this devices:
Genymotion with android 4.4.2 and JPCT v1.30 : It's works
Samsung S4 Mini with android 4.4.2 and JPCT v1.29: it's works
Samsung S4 Mini with android 4.4.2 and  JPCT v1.30: it's does not works  ???
Samsung J5 with android 5.1.1 and Jpct v1.30 : it's works


I tried  calcMinDistance ( cam.getPosition (), dir , 1000)" and i see no change.


EgonOlsen

#6
I really don't see what should cause this. It's the same calculation. As long as the VM behaves the same (which it has to), the outcome should be deterministic regardless of the device. It's just math, there's no gpu/driver specific code involved.
Just to be sure: Have you double checked that your input parameters are correct in all cases?

EgonOlsen

Here's a version that reverts the change in the constant: http://jpct.de/download/tmp/jpct_ae.jar

Please let me know, if that changes anything or not.


EgonOlsen

#9
I really don't know what it's supposed to be then. Can you please try this: Loop over some x,y coordinates (instead of the ones taken from the touch events), run your code on each set and see what happens...does it fail at all? If it does, does it fail for all values? If not, does it always fail for the same values or is it 'random'?

jaco robier

#10
data for all test:   
ClickX=   864   
ClickY=   164   
Camera.getPosition=(0.0,-30.0,150.0)   
   
      
results:

Interact2D.reproject2D3DWS (cam, fb, Clickx, clicky) .normalize () always return  (-0.4566984,-0.121633224,-0.8812672) in V1.29 & V1.30

      
                 V1.29                                V1.30
N° Click     CalcminDistance=               CalcminDistance=
1               "2.3096227645874023"   "2.3096227645874023" =>  it's always Ok in V1.30 when first click !!
2               "2.3096227645874023"   "9.99999995904E11" :o => Second click and the next click are bad in V1.30
3               "2.3096227645874023"   "9.99999995904E11" :o
4               "2.3096227645874023"   "9.99999995904E11" :o
5               "2.3096227645874023"   "9.99999995904E11" :o
6               "2.3096227645874023"   "9.99999995904E11" :o
7               "2.3096227645874023"   "9.99999995904E11" :o
8               "2.3096227645874023"   "9.99999995904E11" :o

EgonOlsen

Now it's getting really strange...and this happens on Samsung S4 Mini only or on all devices?

EgonOlsen

Ok...I've triple checked all my changes between the versions and this behaviour makes no f!"/("/()'##ing sense. Can you please try this jar (it reverts the float->double changes): http://jpct.de/download/tmp/jpct_ae.jar. If that doesn't help, than I don't know what will. However, even if it does, it's not a proper solution. In addition, please try this one as well: http://jpct.de/download/tmp/2/jpct_ae.jar

jaco robier


I see this problem only on my Samsung S4 Mini. And I see no problem in v1.30 on my second SmartPhone Samsung J5.


I tried your new  Jar V1.31  from http://jpct.de/download/tmp/jpct_ae.jar
and .... it's work fine on all my device  ;D


I tested too your jar from http://jpct.de/download/tmp/2/jpct_ae.jar and it does not work.

thank you for your help!

EgonOlsen

So, it's obviously an issue with the double/float stuff. I really think that this is actually a bug in the VM or, more likely, in the JIT compiler (because it works fine in the first iteration). I'm not sure how to counter this...the version that you are using now reverts back to float, which actually isn't what I want to do. I might make this optional, so that you can revert to the old behaviour (that works for you) by setting a Config switch.
I'll report back later...