Newton Dynamics  4.00
ndWorldScene Class Reference
Inheritance diagram for ndWorldScene:
ndScene ndThreadPool ndSyncMutex ndThread ndClassAlloc ndThreadName ndSemaphore ndAtomic< bool > ndWorldSceneCuda

Public Member Functions

D_NEWTON_API ndWorldScene (ndWorld *const world)
 
D_NEWTON_API ndWorldScene (const ndWorldScene &src)
 
- Public Member Functions inherited from ndScene
virtual D_COLLISION_API bool AddBody (ndSharedPtr< ndBody > &body)
 
virtual D_COLLISION_API bool RemoveBody (ndBodyKinematic *const body)
 
virtual D_COLLISION_API void Begin ()
 
virtual D_COLLISION_API void End ()
 
virtual D_COLLISION_API void Sync ()
 
virtual D_COLLISION_API bool IsGPU () const
 
virtual D_COLLISION_API bool IsValid () const
 
virtual D_COLLISION_API double GetGPUTime () const
 
virtual D_COLLISION_API void Cleanup ()
 
D_COLLISION_API ndContactNotifyGetContactNotify () const
 
D_COLLISION_API void SetContactNotify (ndContactNotify *const notify)
 
virtual D_COLLISION_API void DebugScene (ndSceneTreeNotiFy *const notify)
 
virtual D_COLLISION_API void BodiesInAabb (ndBodiesInAabbNotify &callback, const ndVector &minBox, const ndVector &maxBox) const
 
virtual D_COLLISION_API bool RayCast (ndRayCastNotify &callback, const ndVector &globalOrigin, const ndVector &globalDest) const
 
virtual D_COLLISION_API bool ConvexCast (ndConvexCastNotify &callback, const ndShapeInstance &convexShape, const ndMatrix &globalOrigin, const ndVector &globalDest) const
 
D_COLLISION_API void SendBackgroundTask (ndBackgroundTask *const job)
 
ndInt32 GetThreadCount () const
 
const ndBodyListViewGetBodyList () const
 
ndArray< ndBodyKinematic * > & GetActiveBodyArray ()
 
const ndArray< ndBodyKinematic * > & GetActiveBodyArray () const
 
ndArray< ndConstraint * > & GetActiveContactArray ()
 
const ndArray< ndConstraint * > & GetActiveContactArray () const
 
ndArray< ndUnsigned8 > & GetScratchBuffer ()
 
ndFloat32 GetTimestep () const
 
void SetTimestep (ndFloat32 timestep)
 
ndBodyKinematicGetSentinelBody () const
 
- Public Member Functions inherited from ndThreadPool
D_CORE_API ndThreadPool (const char *const baseName)
 
ndInt32 GetThreadCount () const
 
D_CORE_API void SetThreadCount (ndInt32 count)
 
D_CORE_API void TickOne ()
 
D_CORE_API void Begin ()
 
D_CORE_API void End ()
 
template<typename Function >
void ParallelExecute (const Function &ndFunction)
 
- Public Member Functions inherited from ndSyncMutex
D_CORE_API ndSyncMutex ()
 Create and initialize counter to zero.
 
D_CORE_API ~ndSyncMutex ()
 Destroy mutex.
 
D_CORE_API void Sync ()
 Synchronize with another worker threads. More...
 
D_CORE_API void Tick ()
 Increment internal variable m_count by one.
 
D_CORE_API void Release ()
 Decrement internal variable m_count by one and signal the thread to wakeup.
 
- Public Member Functions inherited from ndThread
D_CORE_API ndThread ()
 Empty default constructor after creation all threads go to a wait state.
 
virtual D_CORE_API ~ndThread ()
 Empty, does not terminate the thread loop. More...
 
D_CORE_API void SetName (const char *const name)
 Set thread name. More...
 
D_CORE_API void Signal ()
 Set the thread, to execute one call to and go back to a wait state

 
D_CORE_API void Finish ()
 Force the thread loop to terminate. More...
 
- Public Member Functions inherited from ndClassAlloc
 ndClassAlloc ()
 Empty default constructor.
 
 ~ndClassAlloc ()
 Empty.
 
- Public Member Functions inherited from ndSemaphore
D_CORE_API ndSemaphore ()
 Create and initialize counter to zero.
 
D_CORE_API ~ndSemaphore ()
 Destroy semaphore.
 
D_CORE_API ndInt32 GetCount () const
 Returns counter counter value.
 
D_CORE_API bool Wait ()
 Synchronize with another threads. More...
 
D_CORE_API void Signal ()
 Notify a thread blocked by member function Wait to wake and test m_counter again. More...
 
D_CORE_API void Terminate ()
 Notify a waiting thread on member function Wait that is time to exit the thread loop.
 
- Public Member Functions inherited from ndAtomic< bool >
 ndAtomic (bool val)
 
 ndAtomic (const ndAtomic< bool > &copy)
 
bool operator= (bool value)
 

Protected Member Functions

virtual void ThreadFunction ()
 Thread function to execute in a perpetual loop until the thread is terminated. More...
 
virtual ndWorldGetWorld () const
 
- Protected Member Functions inherited from ndScene
D_COLLISION_API ndScene (const ndScene &src)
 
bool ValidateContactCache (ndContact *const contact, const ndVector &timestep) const
 
const ndContactArrayGetContactArray () const
 
void FindCollidingPairs (ndBodyKinematic *const body, ndInt32 threadId)
 
void FindCollidingPairsForward (ndBodyKinematic *const body, ndInt32 threadId)
 
void FindCollidingPairsBackward (ndBodyKinematic *const body, ndInt32 threadId)
 
void AddPair (ndBodyKinematic *const body0, ndBodyKinematic *const body1, ndInt32 threadId)
 
void SubmitPairs (ndBvhLeafNode *const bodyNode, ndBvhNode *const node, bool forward, ndInt32 threadId)
 
void CalculateJointContacts (ndInt32 threadIndex, ndContact *const contact)
 
void ProcessContacts (ndInt32 threadIndex, ndInt32 contactCount, ndContactSolver *const contactSolver)
 
ndJointBilateralConstraintFindBilateralJoint (ndBodyKinematic *const body0, ndBodyKinematic *const body1) const
 
bool RayCast (ndRayCastNotify &callback, const ndBvhNode **stackPool, ndFloat32 *const distance, ndInt32 stack, const ndFastRay &ray) const
 
bool ConvexCast (ndConvexCastNotify &callback, const ndBvhNode **stackPool, ndFloat32 *const distance, ndInt32 stack, const ndFastRay &ray, const ndShapeInstance &convexShape, const ndMatrix &globalOrigin, const ndVector &globalDest) const
 
virtual D_COLLISION_API void ApplyExtForce ()
 
virtual D_COLLISION_API void BalanceScene ()
 
virtual D_COLLISION_API void InitBodyArray ()
 
virtual D_COLLISION_API void UpdateSpecial ()
 
virtual D_COLLISION_API void UpdateBodyList ()
 
virtual D_COLLISION_API void UpdateTransform ()
 
virtual D_COLLISION_API void CreateNewContacts ()
 
virtual D_COLLISION_API void CalculateContacts ()
 
virtual D_COLLISION_API void FindCollidingPairs ()
 
virtual D_COLLISION_API void DeleteDeadContacts ()
 
virtual D_COLLISION_API void CalculateContacts (ndInt32 threadIndex, ndContact *const contact)
 
virtual D_COLLISION_API void UpdateTransformNotify (ndInt32 threadIndex, ndBodyKinematic *const body)
 

Protected Attributes

ndWorldm_world
 
- Protected Attributes inherited from ndScene
ndBodyListView m_bodyList
 
ndContactArray m_contactArray
 
ndBvhSceneManager m_bvhSceneManager
 
ndArray< ndUnsigned8 > m_scratchBuffer
 
ndArray< ndBodyKinematic * > m_sceneBodyArray
 
ndArray< ndConstraint * > m_activeConstraintArray
 
ndSpecialList< ndBodyKinematicm_specialUpdateList
 
ndThreadBackgroundWorker m_backgroundThread
 
ndArray< ndContactPairsm_newPairs
 
ndArray< ndContactPairsm_partialNewPairs [D_MAX_THREADS_COUNT]
 
ndPolygonMeshDesc::ndStaticMeshFaceQuery m_staticMeshQuery [D_MAX_THREADS_COUNT]
 
ndPolygonMeshDesc::ndProceduralStaticMeshFaceQuery m_proceduralStaticMeshQuery [D_MAX_THREADS_COUNT]
 
ndSpinLock m_lock
 
ndBvhNodem_rootNode
 
ndBodyKinematicm_sentinelBody
 
ndContactNotifym_contactNotifyCallback
 
ndFloat32 m_timestep
 
ndUnsigned32 m_lru
 
ndUnsigned32 m_frameNumber
 
ndUnsigned32 m_subStepNumber
 
ndUnsigned32 m_forceBalanceSceneCounter
 

Additional Inherited Members

- Static Public Member Functions inherited from ndThreadPool
static D_CORE_API ndInt32 GetMaxThreads ()
 
- Static Public Member Functions inherited from ndClassAlloc
D_OPERATOR_NEW_AND_DELETE static D_CORE_API void * Malloc (size_t size)
 Generic allocation for any function subclass from ndClassAlloc.
 
static D_CORE_API void Free (void *const ptr)
 Generic destruction for any function subclass from ndClassAlloc.
 
- Public Attributes inherited from ndThreadName
char m_name [32]
 
- Static Protected Attributes inherited from ndScene
static ndVector m_velocTol
 
static ndVector m_linearContactError2
 
static ndVector m_angularContactError2
 

Member Function Documentation

◆ ThreadFunction()

void ndWorldScene::ThreadFunction ( )
protectedvirtual

Thread function to execute in a perpetual loop until the thread is terminated.

Each time the thread owner calls function Signal, the loop execute one call to this function and upon return, the thread goes back to wait for another signal
or to exit the loop.

Implements ndThread.