//------------------------------------------------
void ofxBox2dRect::draw() {
	
	if(body == NULL) {
		return;	
	}
    
    // update the polyline
    getRectangleShape();
    
    ofPath path;
    for (int i=0; i<shape.size(); i++) {
        if(i==0)path.moveTo(shape[i]);
        else path.lineTo(shape[i]);
    }
    
    // draw the path
    path.setColor(ofGetStyle().color);
    path.setFilled(ofGetStyle().bFill);
    path.draw();
    
    // are we sleeping
    if(isSleeping()) {
        ofPushStyle();
        ofEnableAlphaBlending();
        path.setColor(ofColor(255, 100));
        path.setFilled(true);
        path.draw();
        ofPopStyle();
    }
	
}
Beispiel #2
0
void NpArticulation::wakeUpInternal(bool forceWakeUp, bool autowake)
{
	NpScene* scene = getAPIScene();
	PX_ASSERT(scene);
	PxReal wakeCounterResetValue = scene->getWakeCounterResetValueInteral();

	Scb::Articulation& a = getArticulation();
	PxReal wakeCounter = a.getWakeCounter();

	bool needsWakingUp = isSleeping() && (autowake || forceWakeUp);
	if (autowake && (wakeCounter < wakeCounterResetValue))
	{
		wakeCounter = wakeCounterResetValue;
		needsWakingUp = true;
	}

	if (needsWakingUp)
	{
		for(PxU32 i=0; i < mArticulationLinks.size(); i++)
		{
			mArticulationLinks[i]->getScbBodyFast().wakeUpInternal(wakeCounter);
		}

		a.wakeUpInternal(wakeCounter);
	}
}
Beispiel #3
0
	void awake()
	{
		if(isSleeping())
		{
			if(--framecount_ < 0) status_ = TaskStatus::run;
		}
	}
Beispiel #4
0
void ScriptData::RunVM( bool reset )
{
   if ( reset )
   {
      // restart from beginning of the program
      if ( m_vm->mainModule()->module()->findGlobalSymbol( "__main__" ) == 0 )
      {
         Falcon::AutoCString name( m_module->name() );
         xchat_printf( the_plugin, PNAME ": the module %s has no main routine and cannot be launched\n",
            name.c_str() );
         return;
      }
      
      m_vm->launch();
   }
   else
      m_vm->run();

   // in case of error, the callers must catch us.

   if ( ! isSleeping() )
   {
      // if had not a sleep request...
      // ...and If the modue has not registered any hook, unload it.
      if( m_hooks->length() == 0 )
      {
         UnloadModule( this );
      }
   }

   // else everything went fine.
}
Beispiel #5
0
void BalloonGoo::update(){
    if (isSleeping()) emit checkForNeighbors(getPPosition());
    this->moveToTarget();
    if (active){
        //apply the force to fly
        body->ApplyForceToCenter(force);
        body->SetAngularVelocity(0.0);
        body->SetTransform(body->GetPosition(),0.0);
    }
}
Beispiel #6
0
void NounShip::simulate( dword nTick )
{
	PROFILE_FUNCTION();

	// update the ship
	if ( !isSleeping() && m_bShipEnabled )
	{
		updateShip( nTick );			// update ship systems
		updateDynamics( nTick );		// update movement, roll, etc..
		updateCombat( nTick );			// update out of combat timer
	}

	NounBody::simulate( nTick );
}
Beispiel #7
0
void DynamicGoo::update(){
    if (isSelected() && !isFalling()) {
        body->SetLinearVelocity(b2Vec2(0,0));
        return;
    }
    if (!isSleeping()){
        if (hasJoint()){
            body->SetAngularVelocity(0.0);
        }
        moveToTarget();
    }
    else
        emit this->checkForNeighbors(getPPosition());
}
Beispiel #8
0
int Scheduler::futexUnlock(bool bitmask, bool pi_wake, uint32_t pid, uint32_t tid, FutexInfo fi) {
    DEBUG_FUTEX("Scheduler: FUTEX UNLOCK called with bitmask %d pi %d pid %u tid %u", bitmask, pi_wake, pid, tid);
    //We are responsible for removing the owner. Then we go back to wake.
    if(futexTable[fi.uaddr].size() > 0 && futexTable[fi.uaddr].front().pi_waiter
        && futexTable[fi.uaddr].front().tid == tid  && futexTable[fi.uaddr].front().pid == pid )
    {
        futexTable[fi.uaddr].pop_front(); //We were already awake
        assert(!isSleeping(pid, tid));
        return futexWake(bitmask, pi_wake, pid, tid, fi);
    }
    else {
      warn("something is screwy in unlock");
    }
    return 0;
}
Beispiel #9
0
void Peg::draw(){
    
    if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
	//ofCircle(0, 0, getRadius());
    
    ofNoFill();
    ofEnableSmoothing();
    ofSetLineWidth(2);
    ofCircle(0, 0, getRadius());
    ofDisableSmoothing();
    ofFill();
	
    ofPushStyle();
    ofEnableAlphaBlending();
    
    
    
    if(hl_alpha > 0){
        ofSetColor(highlight_color, hl_alpha);
        ofCircle(0, 0, getRadius());
        
        ofNoFill();
        ofEnableSmoothing();
        ofCircle(0, 0, getRadius()+(255-hl_alpha)/2);
        ofDisableSmoothing();
        ofFill();
        hl_alpha-=5;
    }

    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, getRadius());
    }
    ofPopStyle();
    

    ofPopMatrix();

}
Beispiel #10
0
void Mitosis::draw(){
    if(!isBody()) return;
    if(picked) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(rot, 0, 0, 1);
    
    ofSetCircleResolution(10);
    
    ofSetColor(120);
    ofCircle(-10, -5, 5);
    ofCircle(10, -5, 5);
    ofCircle(0, 10, 5);
    
    
    ofNoFill();
    ofEnableSmoothing();
    ofSetLineWidth(2);
    ofCircle(-10, -5, 5);
    ofCircle(10, -5, 5);
    ofCircle(0, 10, 5);
    ofSetColor(200);
    ofSetCircleResolution(30);
    ofCircle(0, 0, getRadius());
    ofDisableSmoothing();
    ofFill();
    
    ofPushStyle();
    ofEnableAlphaBlending();
    
    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, getRadius());
    }
    
    ofPopStyle();
    
    ofPopMatrix();
    rot+=0.5;
    if((ofGetElapsedTimeMillis() - created) > lifespan ) dead = true;
}
Beispiel #11
0
void DynamicGoo::contactGround() {
    //Away to trapass body
    if (isDragging()) {
        //Change flag and reset normal status
        dragging=false;
        fallDown();
        //Emit a signal for the level class
        emit stopDragging();
        return;
    }
    else {

        if (!isSleeping() && qAbs(body->GetAngularVelocity())<body->GetLinearVelocity().Length() && prevTarget==NULL&&  (target==NULL ||(target!=NULL && (target->getVPosition()-body->GetPosition()).Length()<radius/10 ))) {

            ALbyte name[100]="resources/sounds/boing2.wav";
            QPair<unsigned int,unsigned int> source =sSystem->createSource(name);
            sSystem->setPitch(source.first,24.0/float(radius)*60.0/body->GetLinearVelocity().Length());
            sSystem->setVolume(source.first,2.0*body->GetLinearVelocity().Length()/80.0*radius/24.0);
            sSystem->setPosition(source.first,getPPosition());
            sSystem->playSource(source.first);
            sources.push_back(source);
        }
        onGround=true;
        groundPoint=this->getPPosition();

        //if has joint return;
        if (hasJoint()) {

            return;
        }
        if (sleeping) {
            body->SetGravityScale(1.0);
            return;
        }
        if(!hasJoint() && target==NULL) {
            emit this->nextTargetPlease(NULL);
        }
    }
}
Beispiel #12
0
//------------------------------------------------
void ofxBox2dCircle::draw() {
	
	if(!isBody()) return;
	
	ofPushMatrix();
	ofTranslate(getPosition().x, getPosition().y, 0);
	ofRotate(getRotation(), 0, 0, 1);
	ofCircle(0, 0, radius);
	
    ofPushStyle();
    ofEnableAlphaBlending();
    ofSetColor(0);
	ofLine(0, 0, radius, 0);
    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, radius);
    }
    ofPopStyle();
    
	ofPopMatrix();
	
}
Beispiel #13
0
void Star::draw() {
    if(!isBody()) return;
    if(picked) return;

    ofPushMatrix();
    ofTranslate(getPosition().x, getPosition().y, 0);
    ofRotate(getRotation(), 0, 0, 1);

    ofSetColor(241,241,5);
    ofCircle(0, 0, getRadius());

    ofPushStyle();
    ofEnableAlphaBlending();

    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, getRadius());
    }
    ofPopStyle();


    ofPopMatrix();
}
Beispiel #14
0
void DynamicGoo::update() {
    QList <int > toRemove;
    for (int i=0; i<sources.length(); i++) {
        if (!sSystem->sourceStatus(sources[i].first)) {
            sSystem->deleteSource(sources[i]);
            toRemove.push_back(i);
        }
    }

    for (int i=0; i<toRemove.length(); i++)
        sources.removeAt(toRemove[i]);
    if (isSelected() && !isFalling()) {
        body->SetLinearVelocity(b2Vec2(0,0));
        return;
    }
    if (!isSleeping()) {
        if (hasJoint()) {
            body->SetAngularVelocity(0.0);
        }
        moveToTarget();
    }
    else
        emit this->checkForNeighbors(getPPosition());
}
Beispiel #15
0
void NpArticulation::applyImpulse(PxArticulationLink* link,
								  const PxArticulationDriveCache& driveCache,
								  const PxVec3& force,
								  const PxVec3& torque)
{
	PX_CHECK_AND_RETURN(getAPIScene(), "PxArticulation::applyImpulse: object must be in a scene");
	PX_CHECK_AND_RETURN(force.isFinite() && torque.isFinite(), "PxArticulation::applyImpulse: invalid force/torque");
	const Sc::ArticulationDriveCache& c = reinterpret_cast<const Sc::ArticulationDriveCache&>(driveCache);
	PX_CHECK_AND_RETURN(mArticulation.getScArticulation().getCacheLinkCount(c) == mArticulationLinks.size(), "PxArticulation::applyImpulse: Articulation size has changed; drive cache is invalid");

	NP_WRITE_CHECK(getOwnerScene());

	if(isSleeping())
		wakeUp();

	mArticulation.getScArticulation().applyImpulse(static_cast<NpArticulationLink*>(link)->getScbBodyFast().getScBody(), c,force, torque);
	for(PxU32 i=0;i<mArticulationLinks.size();i++)
	{
		PxVec3 lv = mArticulationLinks[i]->getScbBodyFast().getScBody().getLinearVelocity(),
			   av = mArticulationLinks[i]->getScbBodyFast().getScBody().getAngularVelocity();
		mArticulationLinks[i]->setLinearVelocity(lv);
		mArticulationLinks[i]->setAngularVelocity(av);
	}
}
Beispiel #16
0
void DynamicGoo::contactGround(){
    //Away to trapass body
    if (isDragging()) {
        //Change flag and reset normal status
        dragging=false;
        fallDown();
        //Emit a signal for the level class
        emit stopDragging();
        return;
    }
    else {

        if (!isSleeping() && qAbs(body->GetAngularVelocity())<body->GetLinearVelocity().Length() && prevTarget==NULL&&  (target==NULL ||(target!=NULL && (target->getVPosition()-body->GetPosition()).Length()<radius/10 )))
        {
            Goo::sSystem->SetPitch(boingSound, 24.0/float(radius)*60.0/body->GetLinearVelocity().Length());
            Goo::sSystem->SetVolume(boingSound, 2.0*body->GetLinearVelocity().Length()/80.0*radius/24.0);
            Goo::sSystem->SetPosition(boingSound, getPPosition());
            Goo::sSystem->Play(boingSound);
        }
        onGround=true;
        groundPoint=this->getPPosition();

        //if has joint return;
        if (hasJoint()){

            return;
        }
        if (sleeping) {
            body->SetGravityScale(1.0);
            return;
        }
        if(!hasJoint() && target==NULL){
            emit this->nextTargetPlease(NULL);
        }
    }
}
Beispiel #17
0
//----------------------------------------
void ofxBox2dBody::_drawCircle(b2Vec2 center, float radius) {
	
    if(!isBody()) {return;}
    
    center *= OFX_BOX2D_SCALE;
    radius *= OFX_BOX2D_SCALE;
    
    ofPushMatrix();
    ofTranslate(center.x, center.y);
    ofCircle(0, 0, radius);
    
    ofPushStyle();
    ofEnableAlphaBlending();
    ofSetColor(0);
    ofLine(0, 0, radius, 0);
    if(isSleeping()) {
        ofSetColor(255, 100);
        ofCircle(0, 0, radius);
    }
    ofPopStyle();
    
    ofPopMatrix();
    
}
Beispiel #18
0
void BvhTetrahedronSystem::updateBvhImpulseBased()
{
    if(isSleeping()) return;
    formTetrahedronAabbsImpulsed();
    CudaLinearBvh::update();
}