A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by PJani » Mon Sep 17, 2012 1:58 pm
Hey i am having a little bit of problem with NewtonBodyAddTorque and NewtonBodyAddForce. For some reason only the last "added" torque or force is set. Is this as it should be or i am missing something?

| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
-

PJani
-
- Posts: 448
- Joined: Mon Feb 02, 2009 7:18 pm
- Location: Slovenia
by Julio Jerez » Mon Sep 17, 2012 2:26 pm
This is what Add force and add torque do. set a break point and see if it is hit
- Code: Select all
inline void dgDynamicBody::AddForce (const dgVector& force)
{
SetForce (m_accel + force);
}
inline void dgDynamicBody::AddTorque (const dgVector& torque)
{
SetTorque (torque + m_alpha);
}
you need to call it form a force and torque callback of from other callback because the m_accel is cleared at the beginning of each frame.
as you can see by the call to the force and torque callback
- Code: Select all
inline void dgDynamicBody::ApplyExtenalForces (dgFloat32 timestep, dgInt32 threadIndex)
{
m_accel = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
m_alpha = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
dgBody::ApplyExtenalForces(timestep, threadIndex);
}
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by PJani » Mon Sep 17, 2012 8:28 pm
What if i need to add force/torque in SubmitConstraints in newtoncustomjoint ?
EDIT: eh, nevermind i found one really idiot typo mistake in my 2 year old code...for custom joint, instead of setting local position to local point i set it to local direction...go figures 0_0, i don't know how i did't notice this in all this years...
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
-

PJani
-
- Posts: 448
- Joined: Mon Feb 02, 2009 7:18 pm
- Location: Slovenia
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest