A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Shaderman » Fri Apr 08, 2016 2:25 pm
Hi,
once again, here's a call for help. I'm still working on a ShiVa engine plugin and spent too many hours trying to figure out what could be wrong with mouse picking.
Mouse picking is kind of working, but only if I comment out at least one of these
two lines in CalculatePickForceAndTorque to reset velocity:
- Code: Select all
// restore body velocity and angular velocity
NewtonBodySetOmega (body, &omega0[0]);
NewtonBodySetVelocity(body, &veloc0[0]);
With both lines commented out, a picked object is just swinging around the mouse cursor but doesn't receive any extra noticeable damping (which I want like in the sdk demos). If I don't comment out at least one of these lines, I can't even pick up objects from the ground, they just don't move.
I have no idea why this is happens. omega0 and veloc0 are read from the body and set again without being changed.
Mouse picking works very well in the sdk demos, there's no doubt it's broken on my side. Any ideas?
Thanks
Shaderman
-
Shaderman
-
- Posts: 66
- Joined: Tue Mar 08, 2016 2:51 am
by JoeJ » Sat Apr 09, 2016 1:55 am
I assume it is necessary to call that function from inside the force torque callback, do you?
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Shaderman » Sun Apr 10, 2016 1:29 am
Hi Joej,
I don't see a classic force + torque callback in the mouse picking code i'm trying to use.
Basically I'm using the code from
DemoCameraListener::UpdatePickBody.
I don't use Newtons ScreenToWorld function to get the relevant points in the world, instead I do that on engine side and store the required values.
Then on every engine frame, Newton's CalculatePickForceAndTorque function is called with these stored values to update the picked body.
I'm not sure if engine and newton are somehow out of sync which might probably cause this behaviour. It would probably be better to use some sort of kinematic voodoo to make things work, but I'd like to understand what's going wrong.
I also thought about having trouble now due to the matrix modification I'm doing to match engine and Newton...
I just don't get it

-
Shaderman
-
- Posts: 66
- Joined: Tue Mar 08, 2016 2:51 am
by JoeJ » Sun Apr 10, 2016 2:35 am
Shaderman wrote:I'm not sure if engine and newton are somehow out of sync which might probably cause this behaviour.
Probably, You would need to see what calls DemoCameraListener::UpdatePickBody to see how it should be done.
I'm not familiar with Listeners and Managers yet, i always use the force torque callback to modify body forces. Doing it somewhere else might have no effect.
I assume you already use this callback to apply gravity?
What happens if you call CalculatePickForceAndTorque from there? It should work.
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Shaderman » Sun Apr 10, 2016 3:52 am
JoeJ wrote:I assume you already use this callback to apply gravity?
What happens if you call CalculatePickForceAndTorque from there? It should work.
Yes I do use this callback and yes it works from there - awesome
Now I only run into this
template vector assert after some time. To be honest I have no idea if I have to fix something on my side (creating too many instances), or if it's something which needs to be done in Newton.
Thanks again JoeJ, I appreciate your help!
-
Shaderman
-
- Posts: 66
- Joined: Tue Mar 08, 2016 2:51 am
by JoeJ » Sun Apr 10, 2016 4:06 am
Julio seems to use the assert to debug double prec. issues, you can simply remove it until he's done.
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Shaderman » Sun Apr 10, 2016 4:44 am
Tanks for clarification, problem solved

-
Shaderman
-
- Posts: 66
- Joined: Tue Mar 08, 2016 2:51 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 2 guests