Newton Dynamics  4.00
ndIkSolver.h
1 /* Copyright (c) <2003-2022> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __ND_SKELETON_IMMEDIATE_SOLVER_H__
23 #define __ND_SKELETON_IMMEDIATE_SOLVER_H__
24 
25 #include "ndNewtonStdafx.h"
26 
27 class ndWorld;
28 class ndConstraint;
30 
31 class ndIkSolver: public ndClassAlloc
32 {
33  public:
34  D_NEWTON_API ndIkSolver();
35  D_NEWTON_API ~ndIkSolver();
36 
37  D_NEWTON_API void SetMaxAccel(ndFloat32 maxAccel, ndFloat32 maxAlpha);
38  D_NEWTON_API bool IsSleeping(ndSkeletonContainer* const skeleton) const;
39 
40  D_NEWTON_API void SolverBegin(ndSkeletonContainer* const skeleton, ndJointBilateralConstraint* const* joint, ndInt32 jointCount, ndWorld* const world, ndFloat32 timestep);
41  D_NEWTON_API void Solve();
42  D_NEWTON_API void SolverEnd();
43 
44  D_NEWTON_API ndVector GetBodyForce(const ndBodyKinematic* const body) const;
45  D_NEWTON_API ndVector GetBodyTorque(const ndBodyKinematic* const body) const;
46 
47  private:
48  void BuildMassMatrix();
49  void GetJacobianDerivatives(ndConstraint* const joint);
50  void BuildJacobianMatrix(ndConstraint* const joint);
51 
52  ndBodyKinematic m_sentinelBody;
53  ndArray<ndInt32> m_savedBodiesIndex;
55  ndArray<ndJacobian> m_internalForces;
56  ndArray<ndLeftHandSide> m_leftHandSide;
57  ndArray<ndRightHandSide> m_rightHandSide;
58  ndWorld* m_world;
59  ndSkeletonContainer* m_skeleton;
60  ndFloat32 m_timestep;
61  ndFloat32 m_invTimestep;
62  ndFloat32 m_maxAccel;
63  ndFloat32 m_maxAlpha;
64 
65  friend class ndSkeletonContainer;
66 };
67 
68 
69 #endif
70 
71 
ndClassAlloc
Base class for providing memory allocation for all other engine classes.
Definition: ndClassAlloc.h:30
ndSkeletonContainer
Definition: ndSkeletonContainer.h:31
ndArray< ndInt32 >
ndJointBilateralConstraint
Definition: ndJointBilateralConstraint.h:53
ndBodyKinematic
Definition: ndBodyKinematic.h:40
ndConstraint
Definition: ndConstraint.h:229
ndVector
Definition: ndVectorArmNeon.h:41
ndIkSolver
Definition: ndIkSolver.h:32
ndWorld
Definition: ndWorld.h:47