• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ btClock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: bt_begin_gim02_tri_time

void bt_begin_gim02_tri_time()
{
	g_triangle_clock.reset();
}
开发者ID:0u812,项目名称:emscripten,代码行数:4,代码来源:btGImpactCollisionAlgorithm.cpp


示例17: RenderText

//--------------------------------------------------------------------------------------
// Render the scene using the D3D11 device
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D11FrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, double fTime,
                                  float fElapsedTime, void* pUserContext )
{




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

	///step the simulation
	if (m_dynamicsWorld && !paused)
	{

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

		updatePhysicsWorld();
	}

	//paused = 1;
	


	///////////////////////////////////////////////////////

    HRESULT hr;

    // If the settings dialog is being shown, then render it instead of rendering the app's scene
    if( g_D3DSettingsDlg.IsActive() )
    {
        g_D3DSettingsDlg.OnRender( fElapsedTime );
        return;
    }

    // Clear the render target and depth stencil
    float ClearColor[4] = { 0.0f, 0.25f, 0.25f, 0.55f };
    ID3D11RenderTargetView* pRTV = DXUTGetD3D11RenderTargetView();
    pd3dImmediateContext->ClearRenderTargetView( pRTV, ClearColor );
    ID3D11DepthStencilView* pDSV = DXUTGetD3D11DepthStencilView();
    pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );


	for( int flagIndex = 0; flagIndex < m_flags.size(); ++flagIndex )
	{	
		g_softBodyOutput->copySoftBodyToVertexBuffer( m_flags[flagIndex], cloths[flagIndex].m_vertexBufferDescriptor );
		cloths[flagIndex].draw();
	}

	my_capsule.draw();

	
    DXUT_BeginPerfEvent( DXUT_PERFEVENTCOLOR, L"HUD / Stats" );
    g_HUD.OnRender( fElapsedTime );
    g_SampleUI.OnRender( fElapsedTime );
    RenderText();
    DXUT_EndPerfEvent();


/*
	 SAFE_RELEASE(pRTV);
     SAFE_RELEASE(pDSV);
*/

 
}
开发者ID:AndreAhmed,项目名称:directxgameengine,代码行数:69,代码来源:cloth_renderer.cpp


示例18: kSetupContact

void kSetupContact(btParallelConstraintSolver* pSolver, 
				  btParallelConstraintSolverSetupTaskParams* pParams, 
				  btContactSolverInfo* pInfoGlobal, int threadId)
{
	int numConstraints = pParams[threadId].m_numContactConstraints;
	unsigned long int timeStamp;
	int startIndex = pParams[threadId].m_startIndex;
	btContactSolverInfo& infoGlobal = *pInfoGlobal;
	for(int i = 0; i < numConstraints; i++)
	{
		timeStamp = sClock.getTimeMicroseconds();
		btSolverConstraint& solverConstraint = pSolver->m_tmpSolverContactConstraintPool[startIndex + i];
		solverConstraint.m_numConsecutiveRowsPerKernel = timeStamp;
		btCollisionObject* colObj0 = (btCollisionObject*)solverConstraint.m_solverBodyA;
		btCollisionObject* colObj1 = (btCollisionObject*)solverConstraint.m_solverBodyB;
		btRigidBody* solverBodyA = btRigidBody::upcast(colObj0);
		btRigidBody* solverBodyB = btRigidBody::upcast(colObj1);
		btManifoldPoint& cp = *((btManifoldPoint*)(solverConstraint.m_originalContactPoint));
		btVector3 rel_pos1;
		btVector3 rel_pos2;
		btScalar relaxation;
		btScalar rel_vel;
		btVector3 vel;
		pSolver->setupContactConstraint(solverConstraint, colObj0, colObj1, cp, infoGlobal, vel, rel_vel, relaxation, rel_pos1, rel_pos2);
		int currFrictIndex = solverConstraint.m_frictionIndex;
		if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized)
		{
			cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel;
			btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2();
			if(!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON)
			{
				cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel);
				if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
				{
					cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
					cp.m_lateralFrictionDir2.normalize();//??
					applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2);
					applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2);
					btSolverConstraint& frictionConstraint = pSolver->m_tmpSolverContactFrictionConstraintPool[currFrictIndex];
					currFrictIndex++;
					pSolver->setupFrictionConstraint(frictionConstraint, cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
				}
				applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
				applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
				btSolverConstraint& frictionConstraint = pSolver->m_tmpSolverContactFrictionConstraintPool[currFrictIndex];
				currFrictIndex++;
				pSolver->setupFrictionConstraint(frictionConstraint, cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
				cp.m_lateralFrictionInitialized = true;
			} 
			else
			{
				//re-calculate friction direction every frame, todo: check if this is really needed
				btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2);
				if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
				{
					applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2);
					applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2);
					btSolverConstraint& frictionConstraint = pSolver->m_tmpSolverContactFrictionConstraintPool[currFrictIndex];
					currFrictIndex++;
					pSolver->setupFrictionConstraint(frictionConstraint, cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
				}
				applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1);
				applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1);
				btSolverConstraint& frictionConstraint = pSolver->m_tmpSolverContactFrictionConstraintPool[currFrictIndex];
				currFrictIndex++;
				pSolver->setupFrictionConstraint(frictionConstraint, cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation);
				cp.m_lateralFrictionInitialized = true;
			}
		} 
		else
		{
			btSolverConstraint& frictionConstraint = pSolver->m_tmpSolverContactFrictionConstraintPool[currFrictIndex];
			currFrictIndex++;
			pSolver->setupFrictionConstraint(frictionConstraint, cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation,cp.m_contactMotion1, cp.m_contactCFM1);
			if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS))
			{
				btSolverConstraint& frictionConstraint = pSolver->m_tmpSolverContactFrictionConstraintPool[currFrictIndex];
				currFrictIndex++;
				pSolver->setupFrictionConstraint(frictionConstraint, cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation, cp.m_contactMotion2, cp.m_contactCFM2);
			}
		}
		pSolver->setFrictionConstraintImpulse( solverConstraint, solverBodyA, solverBodyB, cp, infoGlobal);
	}
}
开发者ID:svn2github,项目名称:bullet,代码行数:84,代码来源:btParallelConstraintSolver.cpp


示例19: Profile_Get_Ticks

inline void Profile_Get_Ticks(unsigned long int * ticks)
{
	*ticks = gProfileClock.getTimeMicroseconds();
}
开发者ID:03050903,项目名称:libgdx,代码行数:4,代码来源:btQuickprof.cpp


示例20: renderScene

void PhysicsServerExample::renderScene()
{
	B3_PROFILE("PhysicsServerExample::RenderScene");
	static char line0[1024];
		static char line1[1024];

	if (gEnableRealTimeSimVR)
	{
		
		static int frameCount=0;
		static btScalar prevTime = m_clock.getTimeSeconds();
		frameCount++;
		
		static btScalar worseFps = 1000000;
		int numFrames = 200;
		static int count = 0;
		count++;

		if (0 == (count & 1))
		{
			btScalar curTime = m_clock.getTimeSeconds();
			btScalar fps = 1. / (curTime - prevTime);
			prevTime = curTime;
			if (fps < worseFps)
			{
				worseFps = fps;
			}

			if (count > numFrames)
			{
				count = 0;
				sprintf(line0, "fps:%f frame:%d", worseFps, frameCount / 2);
				sprintf(line1, "drop:%d tscale:%f dt:%f, substep %f)", gDroppedSimulationSteps, simTimeScalingFactor,gDtInSec, gSubStep);
				gDroppedSimulationSteps = 0;

				worseFps = 1000000;
			}
		}

#ifdef BT_ENABLE_VR
		if ((gInternalSimFlags&2 ) && m_tinyVrGui==0)
		{
			ComboBoxParams comboParams;
        comboParams.m_comboboxId = 0;
        comboParams.m_numItems = 0;
        comboParams.m_startItem = 0;
        comboParams.m_callback = 0;//MyComboBoxCallback;
        comboParams.m_userPointer = 0;//this;
        
			m_tinyVrGui = new TinyVRGui(comboParams,this->m_multiThreadedHelper->m_childGuiHelper->getRenderInterface());
			m_tinyVrGui->init();
		}

		if (m_tinyVrGui)
		{

			b3Transform tr;tr.setIdentity();
			tr.setOrigin(b3MakeVector3(gVRController2Pos[0],gVRController2Pos[1],gVRController2Pos[2]));
			tr.setRotation(b3Quaternion(gVRController2Orn[0],gVRController2Orn[1],gVRController2Orn[2],gVRController2Orn[3]));
			tr = tr*b3Transform(b3Quaternion(0,0,-SIMD_HALF_PI),b3MakeVector3(0,0,0));
			b3Scalar dt = 0.01;
			m_tinyVrGui->clearTextArea();
			
			m_tinyVrGui->grapicalPrintf(line0,0,0,0,0,0,255);
			m_tinyVrGui->grapicalPrintf(line1,0,16,255,255,255,255);

			m_tinyVrGui->tick(dt,tr);
		}
#endif//BT_ENABLE_VR
	}
	///debug rendering
	//m_args[0].m_cs->lock();
	
	//gVRTeleportPos[0] += 0.01;
	vrOffset[12]=-gVRTeleportPos[0];
	vrOffset[13]=-gVRTeleportPos[1];
	vrOffset[14]=-gVRTeleportPos[2];

	this->m_multiThreadedHelper->m_childGuiHelper->getRenderInterface()->
		getActiveCamera()->setVRCameraOffsetTransform(vrOffset);

	m_physicsServer.renderScene();
	
	for (int i=0;i<MAX_VR_CONTROLLERS;i++)
	{
		if (m_args[0].m_isVrControllerPicking[i] || m_args[0].m_isVrControllerDragging[i])
		{
			btVector3 from = m_args[0].m_vrControllerPos[i];
			btMatrix3x3 mat(m_args[0].m_vrControllerOrn[i]);
	
			btVector3 toX = from+mat.getColumn(0);
			btVector3 toY = from+mat.getColumn(1);
			btVector3 toZ = from+mat.getColumn(2);
	
			int width = 2;

	
			btVector4 color;
			color=btVector4(1,0,0,1);
			m_guiHelper->getAppInterface()->m_renderer->drawLine(from,toX,color,width);
//.........这里部分代码省略.........
开发者ID:WhitestormJS,项目名称:ammo.js,代码行数:101,代码来源:PhysicsServerExample.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ btCollisionDispatcher类代码示例发布时间:2022-05-31
下一篇:
C++ btAlignedObjectArray类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap