当前位置: 首页>>代码示例>>C++>>正文


C++ btClock类代码示例

本文整理汇总了C++中btClock的典型用法代码示例。如果您正苦于以下问题:C++ btClock类的具体用法?C++ btClock怎么用?C++ btClock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了btClock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OutputTime

	static void OutputTime(const char* name, btClock& c, unsigned count = 0)
	{
		const unsigned long us = c.getTimeMicroseconds();
		const unsigned long ms = (us + 500) / 1000;
		const btScalar sec = us / (btScalar)(1000 * 1000);
		if (count > 0)
			printf("%s : %u us (%u ms), %.2f/s\r\n", name, us, ms, count / sec);
		else
			printf("%s : %u us (%u ms)\r\n", name, us, ms);
	}
开发者ID:stolk,项目名称:bullet3,代码行数:10,代码来源:btDbvtBroadphase.cpp

示例2: physics_simulate

void physics_simulate()
{
	//run the simulation

	static btClock clock;
	static bool first = true;
	if (first)
	{
		first=false;
		clock.reset();
	}
	btScalar dt = (btScalar)clock.getTimeMicroseconds();
	clock.reset();


	
	m_dynamicsWorld->stepSimulation(dt/1000000.f);

	int i;
	for (i=0;i<m_dynamicsWorld->getNumCollisionObjects();i++)
	{
		btRigidBody* body = btRigidBody::upcast(m_dynamicsWorld->getCollisionObjectArray()[i]);
		if (body)
		{
			
			PfxRigidState* state = (PfxRigidState*) body->getUserPointer();

			PfxVector3 pe_pos = getVmVector3(body->getWorldTransform().getOrigin());
			PfxQuat pe_orn = getVmQuat(body->getWorldTransform().getRotation());
			PfxVector3 pe_lvel = getVmVector3(body->getLinearVelocity());
			PfxVector3 pe_avel = getVmVector3(body->getAngularVelocity());

			state->setPosition(pe_pos);
			state->setOrientation(pe_orn);
			state->setLinearVelocity(pe_lvel);
			state->setAngularVelocity(pe_avel);
		}
	}
	
	
}
开发者ID:Lunavast,项目名称:bullet-physics,代码行数:41,代码来源:bullet_physics_func.cpp

示例3: ProfileScope

	__forceinline ProfileScope(btClock& clock, unsigned long& value) : m_clock(&clock), m_value(&value), m_base(clock.getTimeMicroseconds())
	{
	}
开发者ID:stolk,项目名称:bullet3,代码行数:3,代码来源:btDbvtBroadphase.cpp

示例4: doFlags

void doFlags()
{
	//float ms = getDeltaTimeMicroseconds();
	btScalar dt = (btScalar)m_clock.getTimeMicroseconds();
	m_clock.reset();

	///step the simulation
	if( m_dynamicsWorld )
	{
		m_dynamicsWorld->stepSimulation(dt/1000000.);

		static int frameCount = 0;
		frameCount++;
		if (frameCount==100)
		{
 			m_dynamicsWorld->stepSimulation(1./60.,0);
			CProfileManager::dumpAll();
		}
		updatePhysicsWorld();

		//m_dynamicsWorld->setDebugDrawer(&debugDraw);
		//debugDraw.setDebugMode(btIDebugDraw::DBG_DrawWireframe);
		//g_solver->copyBackToSoftBodies();

		//m_dynamicsWorld->debugDrawWorld();
		
	}
	

	for( int flagIndex = 0; flagIndex < m_flags.size(); ++flagIndex )
	{
		g_softBodyOutput->copySoftBodyToVertexBuffer( m_flags[flagIndex], cloths[flagIndex].m_vertexBufferDescriptor );
		cloths[flagIndex].draw();
	}
}
开发者ID:svn2github,项目名称:bullet,代码行数:35,代码来源:cl_cloth_demo.cpp

示例5: cast

	void cast (btCollisionWorld* cw)
	{
#ifdef USE_BT_CLOCK
		frame_timer.reset ();
#endif //USE_BT_CLOCK

#ifdef BATCH_RAYCASTER
		if (!gBatchRaycaster)
			return;

		gBatchRaycaster->clearRays ();
		for (int i = 0; i < NUMRAYS_IN_BAR; i++)
		{
			gBatchRaycaster->addRay (source[i], dest[i]);
		}
		gBatchRaycaster->performBatchRaycast ();
		for (int i = 0; i < gBatchRaycaster->getNumRays (); i++)
		{
				const SpuRaycastTaskWorkUnitOut& out = (*gBatchRaycaster)[i];
				hit[i].setInterpolate3(source[i],dest[i],out.hitFraction);
				normal[i] = out.hitNormal;
				normal[i].normalize ();
		}
#else
		for (int i = 0; i < NUMRAYS_IN_BAR; i++)
		{
			btCollisionWorld::ClosestRayResultCallback cb(source[i], dest[i]);
			
			cw->rayTest (source[i], dest[i], cb);
			if (cb.hasHit ())
			{
				hit[i] = cb.m_hitPointWorld;
				normal[i] = cb.m_hitNormalWorld;
				normal[i].normalize ();
			} else {
				hit[i] = dest[i];
				normal[i] = btVector3(1.0, 0.0, 0.0);
			}

		}
#ifdef USE_BT_CLOCK
		ms += frame_timer.getTimeMilliseconds ();
#endif //USE_BT_CLOCK
		frame_counter++;
		if (frame_counter > 50)
		{
			min_ms = ms < min_ms ? ms : min_ms;
			max_ms = ms > max_ms ? ms : max_ms;
			sum_ms += ms;
			sum_ms_samples++;
			btScalar mean_ms = (btScalar)sum_ms/(btScalar)sum_ms_samples;
			printf("%d rays in %d ms %d %d %f\n", NUMRAYS_IN_BAR * frame_counter, ms, min_ms, max_ms, mean_ms);
			ms = 0;
			frame_counter = 0;
		}
#endif
	}
开发者ID:382309009,项目名称:Core3D,代码行数:57,代码来源:ConcaveRaycastDemo.cpp

示例6: cast

	void cast (btCollisionWorld* cw)
	{
#ifdef USE_BT_CLOCK
		frame_timer.reset ();
#endif //USE_BT_CLOCK
		for (int i = 0; i < NUMRAYS_IN_BAR; i++)
		{
			btCollisionWorld::ClosestConvexResultCallback cb(source[i], dest[i]);
			btQuaternion qFrom;
			btQuaternion qTo;
			qFrom.setRotation (btVector3(1.0, 0.0, 0.0), 0.0);
			qTo.setRotation (btVector3(1.0, 0.0, 0.0), 0.7);
			btTransform from(qFrom, source[i]);
			btTransform to(qTo, dest[i]);
			cw->convexSweepTest (&boxShape, from, to, cb);
			if (cb.hasHit ())
			{
				hit_surface[i] = cb.m_hitPointWorld;
				hit_com[i].setInterpolate3(source[i], dest[i], cb.m_closestHitFraction);
				hit_fraction[i] = cb.m_closestHitFraction;
				normal[i] = cb.m_hitNormalWorld;
				normal[i].normalize ();
			} else {
				hit_com[i] = dest[i];
				hit_surface[i] = dest[i];
				hit_fraction[i] = 1.0f;
				normal[i] = btVector3(1.0, 0.0, 0.0);
			}

		}
#ifdef USE_BT_CLOCK
		ms += frame_timer.getTimeMilliseconds ();
#endif //USE_BT_CLOCK
		frame_counter++;
		if (frame_counter > 50)
		{
			min_ms = ms < min_ms ? ms : min_ms;
			max_ms = ms > max_ms ? ms : max_ms;
			sum_ms += ms;
			sum_ms_samples++;
			btScalar mean_ms = (btScalar)sum_ms/(btScalar)sum_ms_samples;
			printf("%d rays in %d ms %d %d %f\n", NUMRAYS_IN_BAR * frame_counter, ms, min_ms, max_ms, mean_ms);
			ms = 0;
			frame_counter = 0;
		}
	}
开发者ID:andemi02,项目名称:orkid,代码行数:46,代码来源:ConcaveConvexcastDemo.cpp

示例7:

/***********************************************************************************************
 * CProfileManager::Reset -- Reset the contents of the profiling system                       *
 *                                                                                             *
 *    This resets everything except for the tree structure.  All of the timing data is reset.  *
 *=============================================================================================*/
void	CProfileManager::Reset( void )
{
	gProfileClock.reset();
	Root.Reset();
    Root.Call();
	FrameCounter = 0;
	Profile_Get_Ticks(&ResetTime);
}
开发者ID:03050903,项目名称:libgdx,代码行数:13,代码来源:btQuickprof.cpp

示例8:

/***********************************************************************************************
 * CProfileManager::Reset -- Reset the contents of the profiling system                       *
 *                                                                                             *
 *    This resets everything except for the tree structure.  All of the timing data is reset.  *
 *=============================================================================================*/
void	CProfileManager::Reset( void )
{ 
	if(!m_profilerEnabled) return;
	gProfileClock.reset();
	Root.Reset();
    Root.Call();
	FrameCounter = 0;
	Profile_Get_Ticks(&ResetTime);
}
开发者ID:svn2github,项目名称:bullet,代码行数:14,代码来源:btQuickprof.cpp

示例9: doFlags

void doFlags()
{
	//float ms = getDeltaTimeMicroseconds();
	btScalar dt = (btScalar)m_clock.getTimeMicroseconds();
	m_clock.reset();

	///step the simulation
	if( m_dynamicsWorld )
	{
		m_dynamicsWorld->stepSimulation(dt/1000000.);

		static int frameCount = 0;
		frameCount++;
		if (frameCount==100)
		{
 			m_dynamicsWorld->stepSimulation(1./60.,0);
			
		// Option to save a .bullet file
		//	btDefaultSerializer*	serializer = new btDefaultSerializer();
		//	m_dynamicsWorld->serialize(serializer);
		//	FILE* file = fopen("testFile.bullet","wb");
		//	fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
		//	fclose(file);

			CProfileManager::dumpAll();
		}
		updatePhysicsWorld();

		//m_dynamicsWorld->setDebugDrawer(&debugDraw);
		//debugDraw.setDebugMode(btIDebugDraw::DBG_DrawWireframe);
		//g_solver->copyBackToSoftBodies();

		m_dynamicsWorld->debugDrawWorld();
		
	}
	

	for( int flagIndex = 0; flagIndex < m_flags.size(); ++flagIndex )
	{
        if (g_softBodyOutput)
            g_softBodyOutput->copySoftBodyToVertexBuffer( m_flags[flagIndex], cloths[flagIndex].m_vertexBufferDescriptor );
		cloths[flagIndex].draw();
	}
}
开发者ID:AJ92,项目名称:Engine,代码行数:44,代码来源:cl_cloth_demo.cpp

示例10:

/***********************************************************************************************
 * CProfileManager::Reset -- Reset the contents of the profiling system                       *
 *                                                                                             *
 *    This resets everything except for the tree structure.  All of the timing data is reset.  *
 *=============================================================================================*/
void	CProfileManager::Reset( void )
{
	gProfileClock.reset();
	int threadIndex = btQuickprofGetCurrentThreadIndex2();
	if (threadIndex<0)
		return;
	gRoots[threadIndex].Reset();
	gRoots[threadIndex].Call();
	FrameCounter = 0;
	Profile_Get_Ticks(&ResetTime);
}
开发者ID:1vanK,项目名称:Urho3D,代码行数:16,代码来源:btQuickprof.cpp

示例11:

/***********************************************************************************************
 * CProfileManager::Reset -- Reset the contents of the profiling system                       *
 *                                                                                             *
 *    This resets everything except for the tree structure.  All of the timing data is reset.  *
 *=============================================================================================*/
void	CProfileManager::Reset( void )
{
	gProfileClock.reset();
	int threadIndex = btQuickprofGetCurrentThreadIndex2();
	if ((threadIndex<0) || threadIndex >= BT_QUICKPROF_MAX_THREAD_COUNT)
		return;
	gRoots[threadIndex].Reset();
	gRoots[threadIndex].Call();
	FrameCounter = 0;
	Profile_Get_Ticks(&ResetTime);
}
开发者ID:93i,项目名称:godot,代码行数:16,代码来源:btQuickprof.cpp

示例12:

void	CProfileNode::Reset( void )
{
	TotalCalls = 0;
	TotalTime = 0.0f;
	gProfileClock.reset();

	if ( Child ) {
		Child->Reset();
	}
	if ( Sibling ) {
		Sibling->Reset();
	}
}
开发者ID:dividio,项目名称:projectfootball,代码行数:13,代码来源:btQuickprof.cpp

示例13: MyLeaveProfileZoneFunc

void MyLeaveProfileZoneFunc()
{
	if (gProfileDisabled)
		return;
#ifndef BT_NO_PROFILE
	int threadId = btQuickprofGetCurrentThreadIndex2();
	if (threadId < 0 || threadId >= BT_QUICKPROF_MAX_THREAD_COUNT)
		return;

	if (gStackDepths[threadId] <= 0)
	{
		return;
	}

	gStackDepths[threadId]--;

	const char* name = gFuncNames[threadId][gStackDepths[threadId]];
	unsigned long long int startTime = gStartTimes[threadId][gStackDepths[threadId]];

	unsigned long long int endTime = clk.getTimeNanoseconds();
	gTimings[threadId].addTiming(name, threadId, startTime, endTime);
#endif  //BT_NO_PROFILE
}
开发者ID:sunwaylive,项目名称:bullet3,代码行数:23,代码来源:ChromeTraceUtil.cpp

示例14: MyEnterProfileZoneFunc

void MyEnterProfileZoneFunc(const char* msg)
{
	if (gProfileDisabled)
		return;
#ifndef BT_NO_PROFILE
	int threadId = btQuickprofGetCurrentThreadIndex2();
	if (threadId < 0 || threadId >= BT_QUICKPROF_MAX_THREAD_COUNT)
		return;

	if (gStackDepths[threadId] >= MAX_NESTING)
	{
		btAssert(0);
		return;
	}
	gFuncNames[threadId][gStackDepths[threadId]] = msg;
	gStartTimes[threadId][gStackDepths[threadId]] = clk.getTimeNanoseconds();
	if (gStartTimes[threadId][gStackDepths[threadId]] <= gStartTimes[threadId][gStackDepths[threadId] - 1])
	{
		gStartTimes[threadId][gStackDepths[threadId]] = 1 + gStartTimes[threadId][gStackDepths[threadId] - 1];
	}
	gStackDepths[threadId]++;
#endif
}
开发者ID:sunwaylive,项目名称:bullet3,代码行数:23,代码来源:ChromeTraceUtil.cpp

示例15: bt_end_gim02_tri_time

void bt_end_gim02_tri_time()
{
	g_accum_triangle_collision_time += g_triangle_clock.getTimeMicroseconds();
	g_count_triangle_collision++;
}
开发者ID:0u812,项目名称:emscripten,代码行数:5,代码来源:btGImpactCollisionAlgorithm.cpp


注:本文中的btClock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。