/* 
 * 
 * Confidential Information of Telekinesys Research Limited (t/a Havok).  Not for disclosure or distribution without Havok's
 * prior written consent.This software contains code, techniques and know-how which is confidential and proprietary to Havok.
 * Level 2 and Level 3 source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2008 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
 * 
 */


#ifndef HK_PhysicsInSeparateThreadDemo_H
#define HK_PhysicsInSeparateThreadDemo_H

#include <Demos/DemoCommon/DemoFramework/hkDefaultPhysicsDemo.h>

	/// This demo shows how to run the graphics and the physics in separate threads.
	/// What do we get:
	///   - Higher performance on multiple processors
	///   - Very simple to implement
	///   - We can decide to draw the graphics even if the physics isn't finished
	/// Downsides (if you do no wait for the physics to finish before rendering):
	///   - The output of the physics will feed into the graphics one frame later if you perform rendering while the physics is still running.
	///   - In the graphics engine you cannot call the physics engine (which you shouldn't do anyway)
	/// How it works:
	///   - We use hkpMultithreadingUtil to coordinate physics threads
class PhysicsInSeparateThreadDemo : public hkDefaultPhysicsDemo
{
	public:

		HK_DECLARE_CLASS_ALLOCATOR(HK_MEMORY_CLASS_DEMO);

		PhysicsInSeparateThreadDemo(hkDemoEnvironment* environment);

		~PhysicsInSeparateThreadDemo();

		Result stepDemo(); 

	private:

		void createHollowSphereMopp(hkpMotion::MotionType motionType);

		void createAndAddRagdoll();

		void createAndAddDebris();

			// Time period for adding ragdolls
		hkReal m_timeToSpawnNewRagdoll;

			// Time period for adding box debris
		hkReal m_timeToSpawnDebris;

			// Ragdol count
		int	   m_numCurrentRagdolls;


		hkpGroupFilter* m_filter;

			// Manually added sphere shape for the enclosing sphere
		class hkDisplaySphere*		m_sphereDisp;
};

#endif

/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20080529)
*
* Confidential Information of Havok.  (C) Copyright 1999-2008 
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok.  Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates 
* acceptance of the End User licence Agreement for this product. A copy of 
* the license is included with this software and is also available at
* www.havok.com/tryhavok
*
*/
