Newton Dynamics  4.00
ndBodyParticleSet.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_BODY_PARTICLE_SET_H__
23 #define __ND_BODY_PARTICLE_SET_H__
24 
25 #include "ndNewtonStdafx.h"
26 
27 D_MSV_NEWTON_ALIGN_32
29 {
30  public:
31  D_NEWTON_API ndBodyParticleSet();
32  D_NEWTON_API ndBodyParticleSet(const ndLoadSaveBase::ndLoadDescriptor& desc);
33  D_NEWTON_API virtual ~ndBodyParticleSet ();
34  D_NEWTON_API virtual void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
35 
36  const ndVector GetGravity() const;
37  void SetGravity(const ndVector& gravity);
38 
39  ndArray<ndVector>& GetVelocity();
40  ndArray<ndVector>& GetPositions();
41  const ndArray<ndVector>& GetVelocity() const;
42  const ndArray<ndVector>& GetPositions() const;
43  virtual ndBodyParticleSet* GetAsBodyParticleSet();
44 
45  bool GetAsynUpdate() const;
46  void SetAsynUpdate(bool update);
47  ndFloat32 GetParticleRadius() const;
48  void SetParticleRadius(ndFloat32 radius);
49 
50  D_NEWTON_API virtual void Update(const ndWorld* const workd, ndFloat32 timestep) = 0;
51 
52  protected:
53  ndVector m_box0;
54  ndVector m_box1;
55  ndVector m_gravity;
56  ndArray<ndVector> m_posit;
57  ndArray<ndVector> m_veloc;
58  ndBodyList::ndNode* m_listNode;
59  ndFloat32 m_radius;
60  bool m_updateInBackground;
61  friend class ndWorld;
62 } D_GCC_NEWTON_ALIGN_32 ;
63 
64 inline ndBodyParticleSet* ndBodyParticleSet::GetAsBodyParticleSet()
65 {
66  return this;
67 }
68 
69 inline ndFloat32 ndBodyParticleSet::GetParticleRadius() const
70 {
71  return m_radius;
72 }
73 
74 inline void ndBodyParticleSet::SetParticleRadius(ndFloat32 raidus)
75 {
76  m_radius = raidus;
77 }
78 
79 inline ndArray<ndVector>& ndBodyParticleSet::GetPositions()
80 {
81  return m_posit;
82 }
83 
84 inline const ndArray<ndVector>& ndBodyParticleSet::GetPositions() const
85 {
86  return m_posit;
87 }
88 
89 inline ndArray<ndVector>& ndBodyParticleSet::GetVelocity()
90 {
91  return m_veloc;
92 }
93 
94 inline const ndArray<ndVector>& ndBodyParticleSet::GetVelocity() const
95 {
96  return m_veloc;
97 }
98 
99 inline const ndVector ndBodyParticleSet::GetGravity() const
100 {
101  return m_gravity;
102 }
103 
104 inline void ndBodyParticleSet::SetGravity(const ndVector& gravity)
105 {
106  m_gravity = gravity & ndVector::m_triplexMask;
107 }
108 
109 inline bool ndBodyParticleSet::GetAsynUpdate() const
110 {
111  return m_updateInBackground;
112 }
113 
114 inline void ndBodyParticleSet::SetAsynUpdate(bool updatType)
115 {
116  m_updateInBackground = updatType;
117 }
118 
119 
120 #endif
121 
122 
ndArray< ndVector >
ndBody
Definition: ndBody.h:43
ndBackgroundTask
Definition: ndThreadBackgroundWorker.h:35
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndBodyParticleSet
Definition: ndBodyParticleSet.h:29
ndVector
Definition: ndVectorArmNeon.h:41
ndWorld
Definition: ndWorld.h:47