Esempio n. 1
0
void Dispatcher::DispatchImmediate(EventType eventID, const WorkArguments eventData) {
    // std::cout << "DispatchImmediate " << eventID << "\t" << eventData << std::endl;
    CheckKey(eventID);

    // If there's nothing to deliver this event to just drop it
    if (mapped_events->at(eventID)->size() == 0) {
        return;
    }

    for (auto it = mapped_events->at(eventID)->begin(); it != mapped_events->at(eventID)->end(); it++) {

        // Remove nullptr Subscriber* from the processing
        if (*it == nullptr) {
            // everything else is read-only so we only REALLY need to get the mutex when we edit it
            std::lock_guard<std::recursive_mutex> lock(mapped_event_mutex);
            it = mapped_events->at(eventID)->erase(it);
            continue;
        }

        if ((*it)->_serialized) {
            std::lock_guard<std::recursive_mutex> lock(thread_queue_mutex);
            thread_queue->push_back(WorkPair(*it, eventData));
        } else {
            std::lock_guard<std::recursive_mutex> lock2(nonserial_queue_mutex);
            nonserial_queue->push_back(WorkPair(*it, eventData));
        }
    }

    thread_signal.notify_one();
}
Esempio n. 2
0
void
TrackFileReaderWorker::read(const QString &path, QList<Track*> *tracks) {
    QMutexLocker locker(&_inMutex);
    _cancelRequested = false;
    if (_input.length() == 0)
        _workCount = 0;
    _input.append(WorkPair(path, tracks));
    _workCount++;
    start();
};
Esempio n. 3
0
void kit::Skeleton::updateSkin()
{
  // Create a workload and fill it with the rootnodes
  std::queue<WorkPair> workload;
  for (auto & currBone : this->m_rootBones)
  {
    workload.push(WorkPair(glm::mat4(1.0), currBone));
  }

  // Work it off until empty
  while (!workload.empty())
  {
    // Fetch the workpair at the front of the line
    WorkPair currPair = workload.front();
    workload.pop();

    glm::mat4 parentTransform = currPair.first;
    Bone::Ptr currBone = currPair.second;

    //std::cout << "Updating bone " << currBone->m_name << ", son of " << (currBone->m_parent ? currBone->m_parent->m_name : "nobody") << ", has " << currBone->m_children.size() << " children" << std::endl;

    // Animate the current bones local transformation
    if (this->m_currentAnimation)
    {
      currBone->m_localTransform = this->m_currentAnimation->getBoneTransform(currBone->m_id, this->m_currentFrame);
    }

    // Inherit the global transformation
    currBone->m_globalTransform = parentTransform * currBone->m_localTransform;

    // Update the skin for this bone
    this->m_skin[currBone->m_id] = this->m_globalInverseTransform * currBone->m_globalTransform * this->m_inverseBindPose[currBone->m_id];

    // Add the children of this bone to the workload
    for (auto & currChild : currBone->m_children)
    {
      workload.push(WorkPair(currBone->m_globalTransform, currChild));
    }
  }
}