Suggested convenience function

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Suggested convenience function

Postby aitzolmuelas » Wed Jul 15, 2015 9:51 am

I have recently needed to use the method CalcAverageOmega from dgQuaternion to solve part of my custom character controller (worked quite fine by the way). The thing is I didn't want to have any more access to the internal c++ libraries, only Newton.h, so I added a function to Newton.h/cpp which I think is quite convenient (to avoid having to expose dg math library). I don't mind keeping this as a local change, but maybe it would be a good idea to add it to the official releases

Code: Select all
NEWTON_API void NewtonBodySetAverageOmega (const NewtonBody* const bodyPtr, const dFloat* const q0, const dFloat* const q1, dFloat inv_dt)
{
   TRACE_FUNCTION(__FUNCTION__);
   dgBody* const body = (dgBody *)bodyPtr;

  dgQuaternion quat0( q0[0], q0[1], q0[2], q0[3] );
  dgQuaternion quat1( q1[0], q1[1], q1[2], q1[3] );
   dgVector vector ( quat0.CalcAverageOmega( quat1, inv_dt ) );
   body->SetOmega (vector);
}


Also a function to set omega as a quaternion instead of euler angles would be convenient: I don't know about everyone else, but in the engine I'm currently working on almost everything is kept as quaternions.
aitzolmuelas
 
Posts: 78
Joined: Wed Mar 25, 2015 1:10 pm

Re: Suggested convenience function

Postby Julio Jerez » Wed Jul 15, 2015 10:11 am

CalcAverageOmega is in the dMath library.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Suggested convenience function

Postby aitzolmuelas » Wed Jul 15, 2015 11:39 am

Yeah, I know, I was suggesting exposing it in the pure C newton interface
aitzolmuelas
 
Posts: 78
Joined: Wed Mar 25, 2015 1:10 pm

Re: Suggested convenience function

Postby Julio Jerez » Wed Jul 15, 2015 1:48 pm

they are in the dMath class: ..newton-dynamics\packages\dMath\dQuaternion.h
you can just use the small library for you own persona usages.

The reason I do not like to add special function for resetting velocity, because there are many different permutations, to me SetOmega and GetOmega, let the use do what ever it need
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Suggested convenience function

Postby aitzolmuelas » Thu Jul 16, 2015 3:55 am

Fair enough. It was just a suggestion, but I can see your point that it would over-complicate the API.
aitzolmuelas
 
Posts: 78
Joined: Wed Mar 25, 2015 1:10 pm

Re: Suggested convenience function

Postby lperkins2 » Thu Jul 16, 2015 1:56 pm

How about creating a second, separate pure C header to hold the C wrappers for various utility functions? Something like <NewtonUtils.h>, which would leave the engine API as simple as possible, while not needing everyone to write their own C wrapper functions to use the utility packages.
lperkins2
 
Posts: 39
Joined: Fri Jul 03, 2015 4:16 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests