A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by pHySiQuE » Sat Sep 07, 2013 6:03 pm
This small tweak will allow you to create a slider joint with a NULL parent...perfect for sliding doors!
Around line 105 of customSlider.cpp, replace this:
- Code: Select all
// calculate position and speed
dVector veloc0;
dVector veloc1;
NewtonBodyGetVelocity(m_body0, &veloc0[0]);
NewtonBodyGetVelocity(m_body1, &veloc1[0]);
m_posit = (matrix0.m_posit - matrix1.m_posit) % matrix1.m_front;
m_speed = (veloc0 - veloc1) % matrix1.m_front;
With this:
- Code: Select all
// calculate position and speed
dVector veloc0;
dVector veloc1;
NewtonBodyGetVelocity(m_body0, &veloc0[0]);
if (m_body1)
{
NewtonBodyGetVelocity(m_body1, &veloc1[0]);
}
else
{
veloc1=dVector(0,0,0,1);
}
m_posit = (matrix0.m_posit - matrix1.m_posit) % matrix1.m_front;
m_speed = (veloc0 - veloc1) % matrix1.m_front;
-
pHySiQuE
-
- Posts: 608
- Joined: Fri Sep 02, 2011 9:54 pm
by Julio Jerez » Mon Oct 21, 2013 1:54 pm
I missed thsi post, and I now see thak to a Spammer.
Maybe the slider joint slepied trought the crack, by all joint are desgine to suport NULL parent.
Thank for that note.
I should mention that having joint conncetd to NULL parent is not alway the best thing to do.
It is a feature yes, but a a better way to do it in my optnion is as followe
-Make your static world a scene collision, so teh you cna add all gemetrie that you wnat.
-when adding joint attache to teh world, us ethe sicne collsion body as parent.
why this does is that is automatically let disable contacts calculation with the static world,
you do not need to have contact filtering, and also translate fo beter performance and joint behavior.
You can alway enable the collision if you want.
when adding a NULL Parent, the engine attach it you a fix Body called the sentinel body.
This man that in the Door example, your dor will alwya collide with the frame even when it has limits
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 2 guests