A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Bird » Wed Dec 08, 2021 7:53 am
Hi Julio,
My project allows users to emit bodies into the scene. In older versions of Newton I used NewtonBodyAddImpulse. Could you please tell me how to accomplish the same in Newton 4?
- Code: Select all
void NewtonCallbacks::OnApplyExternalForce (dInt32 threadIndex, dFloat32 timestep)
{
RenderableNode node = weakNode.lock();
ndBodyKinematic* const body = GetBody()->GetAsBodyKinematic();
if (body && body->GetInvMass() > 0.0f)
{
dVector massMatrix (body->GetMassMatrix());
dVector force (GetGravity().Scale (massMatrix.m_w));
body->SetForce (force);
body->SetTorque (dVector::m_zero);
}
if (node->description().emitDuration)
{
Eigen::Vector3f f = node->description().emitDirection * node->description().emitSpeed;
Eigen::Vector3f p = node->getSpaceTime().worldTransform.translation();
dVector impulse = dVector(f.x(), f.y(), f.z(), 0.0f);
dVector pos = dVector (p.x(), p.y(), p.z(), 0.0f);
NewtonBodyAddImpulse (body, &impulse.m_x, &pos.m_x, timestep);
--node->description().emitDuration;
}
}
-
Bird
-
- Posts: 623
- Joined: Tue Nov 22, 2011 1:27 am
by Sweenie » Wed Dec 08, 2021 8:12 am
It was added a few days ago to the ndBodyKinematic class.
- Code: Select all
virtual void AddImpulse(const dVector& pointVeloc, const dVector& pointPosit, dFloat32 timestep);
virtual void ApplyImpulsePair(const dVector& linearImpulse, const dVector& angularImpulse, dFloat32 timestep);
virtual void ApplyImpulsesAtPoint(dInt32 count, const dVector* const impulseArray, const dVector* const pointArray, dFloat32 timestep);
-
Sweenie
-
- Posts: 498
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by Bird » Wed Dec 08, 2021 8:37 am
Thanks. I just saw that. Several of the demos are crashing in the latest version on github. Looks like it's happening on line 532 of ndSkeletonContainer.cpp. Do you know if this version stable enough to hook up to or should I wait ?
- Code: Select all
#ifdef USE_ISLAND_SOLVER
dAssert(0);
m_isResting = equilibrium ? true : false;
#endif
-
Bird
-
- Posts: 623
- Joined: Tue Nov 22, 2011 1:27 am
by Sweenie » Wed Dec 08, 2021 10:45 am
Not sure. There is a lot of experimenting with the island free solver in the latest revisions so i'm not sure which one could be considered to be stable
I guess we have to wait for Julio to answer that.
-
Sweenie
-
- Posts: 498
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by Julio Jerez » Thu Dec 09, 2021 6:32 pm
yes I probable commit a work in progress than I should not, I will fix it this weekend.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- 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 3 guests