Exemplo n.º 1
0
//////////////////////////////////////////////////////////////////////////
//	update
//////////////////////////////////////////////////////////////////////////
void ZClothEmblem::update()
{
	if( !isInViewFrustum( &mAABB, RGetViewFrustum() )  || 
		!m_pWorld->GetBsp()->IsVisible(mAABB) ) {
			mbIsInFrustrum = false;
			return;
		}

	DWORD currTime = timeGetTime();
	
	if ( currTime - mMyTime < 17 ) return;	// 초당 60번으로 제한

	mMyTime = timeGetTime();

 	accumulateForces();
	varlet();
	memset( m_pForce, 0, sizeof(rvector)*m_nCntP );
	//memset( mpWind, 0, sizeof(rvector) );
	if(mpWind!=NULL) 
	{
		mpWind->x = 0.f;
		mpWind->y = 0.f;
		mpWind->z = 0.f;
	}
	satisfyConstraints();
	mWndGenerator.Update( timeGetTime() );
	mbIsInFrustrum = true; // 다음 루프에서 시뮬레이션 대상에 추가한다
}
Exemplo n.º 2
0
//////////////////////////////////////////////////////////////////////////
//	update
//////////////////////////////////////////////////////////////////////////
void RCharCloth::update( bool bGame,rmatrix* pWorldMat_, float fDist_ )
{
	updateCO();
	updatePosition( pWorldMat_ );

	DWORD currTime = timeGetTime();
	if( currTime - mTime < 10 )
	{
		return;
	}
	mTime	= currTime;

	if( mUpdateStatus == CHARACTER_DIE_STATE )
	{
		mUpdateStatus |= NOT_COLLISION;
	}
	else
	{
		mUpdateStatus	= ALL;
		if( fDist_ >  COLLISION_DISTANCE )
			mUpdateStatus	|= NOT_COLLISION;
		if( fDist_ > VALET_DISTANCE )
			mUpdateStatus |= NOT_VALET;
		if( fDist_ > CAL_LENGTH_DISTANCE )
			mUpdateStatus	|= NOT_CAL_LENGTH;
	}

	accumulateForces(bGame);
	valet();
	satisfyConstraints();
}
void PhysicsObjectf::eulerIntegration(float dt) {
  Vec3f force = Vec3f();
  if(!noForce) {
    force = accumulateForces(dt);
  }
  Vec3f acc = Vec3f(force[0]/mass,force[1]/mass,force[2]/mass);
  position[0] = position[0] + velocity[0] * dt;
  position[1] = position[1] + velocity[1] * dt;
  position[2] = position[2] + velocity[2] * dt;
  velocity[0] = velocity[0] + acc[0] * dt;
  velocity[1] = velocity[1] + acc[1] * dt;
  velocity[2] = velocity[2] + acc[2] * dt;
}
void ParticleSystemSolver2::onAdvanceTimeStep(double timeStepInSeconds) {
    beginAdvanceTimeStep(timeStepInSeconds);

    Timer timer;
    accumulateForces(timeStepInSeconds);
    JET_INFO << "Accumulating forces took "
             << timer.durationInSeconds() << " seconds";

    timer.reset();
    timeIntegration(timeStepInSeconds);
    JET_INFO << "Time integration took "
             << timer.durationInSeconds() << " seconds";

    timer.reset();
    resolveCollision();
    JET_INFO << "Resolving collision took "
             << timer.durationInSeconds() << " seconds";

    endAdvanceTimeStep(timeStepInSeconds);
}