Exemple #1
0
void RUser::applyForceUser(RUser* u) {

    if(u==this) return;

    vec2f u_pos = u->getPos();

    vec2f dir = u_pos - pos;

    float dist = dir.length();

    //different repelling force depending on how busy the user is
    float desired_dist = getActionCount() == 0 ?
        gGourcePersonalSpaceDist : (actions.size()>0 && activeActions.size()==0) ?
            gGourcePersonalSpaceDist * 0.1 : gGourcePersonalSpaceDist * 0.5;

    //resolve overlap
    if(dist < 0.001) {

        accel += 1.0f * vec2f( (rand() % 100) - 50, (rand() % 100) - 50).normal();

        return;
    }

    //repelling force
    if(dist < desired_dist) {
        accel -= (desired_dist-dist) * dir.normal();
    }
}
Exemple #2
0
BACIComponent::~BACIComponent()
{
  ACS_TRACE("baci::BACIComponent::~BACIComponent");

  // set destruction flag
  inDestructionState_m = true;

  if (threadManager_mp!=0)
      {
      threadManager_mp->terminateAll();
      }

  // the threads are no more alive, so I can ...

  // remove all left actions (in case it was canceled)
  BACIAction *action_p;
  ThreadSyncGuard guard(&actionQueueMutex_m);
  while (getActionCount() > 0)
    {
      action_p = popAction();
      if (action_p)
	  {
	  delete action_p;
	  }
    }
  guard.release();

  // remove all left callbacks
  BACICallback* callback_p;
  ThreadSyncGuard guard1(&callbackTableMutex_m);
  int h = callbackTable_m.first();
  while (h != 0)
    {
      int nh = callbackTable_m.next(h);
      callback_p = callbackTable_m[h];
      callbackTable_m.deallocate(h);
      delete callback_p;
      h = nh;
    }
  guard1.release();

  ACS_DEBUG_PARAM("baci::BACIComponent::~BACIComponent", "Component '%s' destroyed.", name_m.c_str());
}//~BACIComponent
	/// Get the probability of the action at \c actionIdx
	double getActionProbability(const size_t& actionIdx) {
		double actionCount = static_cast<double>(getActionCount(actionIdx));
		double totalCount = static_cast<double>(getTotalCount());

		return (actionCount / totalCount);
	}