Example #1
0
void FluidSDF::reinitialize(int numSwepIterations)
{
    LOG_OUTPUT("Reinitializing fluid SDF with " << numSwepIterations <<
               " sweep iterations");
    for (int i = 0; i < numSwepIterations; ++i) {
        _sweep(1,_phi.nx(), 1,_phi.ny());
        _sweep(_phi.nx() - 2, -1,_phi.ny() - 2, -1);
        _sweep(1, _phi.nx(), _phi.ny() - 2, -1);
        _sweep(_phi.nx()-2, -1, 1, _phi.ny());
    }
}
Example #2
0
void _recover_chunk(struct mempage_heap * _heap, struct chunk * _chunk){
	boost::upgrade_lock<boost::shared_mutex> lock(_heap->_recover_mu);

	unsigned int slide = _heap->_recover_slide++;
	if (slide >= _heap->_recover_max){
		boost::unique_lock<boost::shared_mutex> uniquelock(boost::move(lock));

		unsigned int newslide = _heap->_recover_slide.load();
		if (newslide >= _heap->_recover_max){
			_resize_recvlist(_heap);
		}
	} 
	_heap->_recover[slide] = _chunk;

	slide = _heap->_recover_slide.load();
	if (slide >= _heap->_recover_max){
		_sweep(_heap);
	}
}
Example #3
0
Point3F BtPlayer::move( const VectorF &disp, CollisionList &outCol )
{
   AssertFatal( mGhostObject, "BtPlayer::move - The controller is null!" );

   // First recover from any penetrations from the previous tick.
   U32 numPenetrationLoops = 0;
   bool touchingContact = false;
   while ( _recoverFromPenetration() )
   {
      numPenetrationLoops++;
      touchingContact = true;
      if ( numPenetrationLoops > 4 )
         break;
   }

   btTransform newTrans = mGhostObject->getWorldTransform();
   btVector3 newPos = newTrans.getOrigin();

   // The move consists of 3 steps... the up step, the forward 
   // step, and the down step.

   btVector3 forwardSweep( disp.x, disp.y, 0.0f );
   const bool hasForwardSweep = forwardSweep.length2() > 0.0f;
   F32 upSweep = 0.0f;
   F32 downSweep = 0.0f;
	if ( disp[2] < 0.0f )
      downSweep = disp[2];
	else								
      upSweep = disp[2];

	// Only do auto stepping if the character is moving forward.
   F32 stepOffset = mStepHeight;
	if ( hasForwardSweep )
		upSweep += stepOffset;

   // First we do the up step which includes the passed in
   // upward displacement as well as the auto stepping.
   if (  upSweep > 0.0f &&
         _sweep( &newPos, btVector3( 0.0f, 0.0f, upSweep ), NULL ) )
   {
      // Keep track of how far we actually swept to make sure
      // we do not remove too much in the down sweep.
		F32 delta = newPos[2] - newTrans.getOrigin()[2];
		if ( delta < stepOffset )
			stepOffset = delta;
   }

   // Now do the forward step.
   _stepForward( &newPos, forwardSweep, &outCol );

   // Now remove what remains of our auto step 
   // from the down sweep.
	if ( hasForwardSweep )
		downSweep -= stepOffset;

   // Do the downward sweep.
   if ( downSweep < 0.0f )
      _sweep( &newPos, btVector3( 0.0f, 0.0f, downSweep ), &outCol );

   // Finally update the ghost with its new position.
	newTrans.setOrigin( newPos );
	mGhostObject->setWorldTransform( newTrans );

   // Return the current position of the ghost.
   newPos[2] -= mOriginOffset;
   return btCast<Point3F>( newPos );
}