Example #1
0
void ShareManager::updateIndices(Directory& dir) {
	bloom.add(Text::toLower(dir.getName()));

	for(auto& i: dir.directories) {
		updateIndices(*i.second);
	}

	dir.size = 0;

	for(auto i = dir.files.begin(); i != dir.files.end(); ) {
		updateIndices(dir, i++);
	}
}
Example #2
0
void EFXEditor::addFixtureItem(EFXFixture* ef)
{
    QTreeWidgetItem* item;
    Fixture* fxi;

    Q_ASSERT(ef != NULL);

    fxi = m_doc->fixture(ef->fixture());
    if (fxi == NULL)
        return;

    item = new QTreeWidgetItem(m_tree);
    item->setText(KColumnName, fxi->name());
    item->setData(0, Qt::UserRole, QVariant(reinterpret_cast<qulonglong> (ef)));
    item->setFlags(item->flags() | Qt::ItemIsUserCheckable);

    if (ef->direction() == Function::Backward)
        item->setCheckState(KColumnReverse, Qt::Checked);
    else
        item->setCheckState(KColumnReverse, Qt::Unchecked);

    updateIntensityColumn(item, ef);
    updateStartOffsetColumn(item, ef);

    updateIndices(m_tree->indexOfTopLevelItem(item),
                  m_tree->topLevelItemCount() - 1);

    /* Select newly-added fixtures so that they can be moved quickly */
    m_tree->setCurrentItem(item);
    redrawPreview();
}
Example #3
0
void EFXEditor::addFixtureItem(Fixture* fixture)
{
	QTreeWidgetItem* item;

	Q_ASSERT(fixture != NULL);

	item = new QTreeWidgetItem(m_tree);
	item->setText(KColumnName, fixture->name());
	item->setText(KColumnID, QString("%1").arg(fixture->id()));

	if (fixture->fixtureDef() == NULL)
	{
		item->setText(KColumnManufacturer, tr("Generic"));
		item->setText(KColumnModel, tr("Generic"));
	}
	else
	{
		item->setText(KColumnManufacturer,
			      fixture->fixtureDef()->manufacturer());
		item->setText(KColumnModel, fixture->fixtureDef()->model());
	}

	updateIndices(m_tree->indexOfTopLevelItem(item),
		      m_tree->topLevelItemCount() - 1);

	/* Select newly-added fixtures so that they can be moved quickly */
	m_tree->setCurrentItem(item);
}
Example #4
0
void ShareManager::rebuildIndices() {
	tthIndex.clear();
	bloom.clear();

	for(auto& i: directories) {
		updateIndices(*i.second);
	}
}
        void EntityDefinitionManager::setDefinitions(const EntityDefinitionList& newDefinitions) {
            clear();

            m_definitions = newDefinitions;

            updateIndices();
            updateGroups();
            updateCache();
            bindObservers();
        }
Example #6
0
void EFXEditor::removeFixtureItem(EFXFixture* ef)
{
	QTreeWidgetItem* item;
	int from;

	Q_ASSERT(ef != NULL);

	item = fixtureItem(ef);
	Q_ASSERT(item != NULL);

	from = m_tree->indexOfTopLevelItem(item);
	delete item;

	updateIndices(from, m_tree->topLevelItemCount() - 1);
}
Example #7
0
void NinePatch::init()
{
  BufferLayout layout;
  layout.add(ET_vec2_f32, UT_position);
  layout.add(ET_vec2_f32, UT_texcoord0);
  this->resetBuffers(layout, ET_u16);

  indexBuffer->drawMode = GL_TRIANGLES;

  u32 numVertices = 16; // draw it on paper and you'll see it's correct
  uint32_t numQuads = 9; // it's a 3x3 matrix of quads
  uint32_t numTris = numQuads*2; // each quad is drawn with two tris
  u32 numIndices = numTris*3; // currently, each tri is drawn with 3 indices

  this->vertexBuffer->reset(numVertices);
  this->indexBuffer->reset(numIndices);

//  updateTexCoords();
  updateIndices();

}
Example #8
0
void EFXEditor::slotLowerFixtureClicked()
{
	QTreeWidgetItem* item;
	int index;

	item = m_tree->currentItem();
	if (item != NULL)
	{
		index = m_tree->indexOfTopLevelItem(item);
		if (index == (m_tree->topLevelItemCount() - 1))
			return;

		m_efx->lowerFixture(item->text(KColumnID).toInt());

		item = m_tree->takeTopLevelItem(index);
		m_tree->insertTopLevelItem(index + 1, item);
		m_tree->setCurrentItem(item);

		updateIndices(index, index + 1);
	}
}
Example #9
0
void EFXEditor::slotLowerFixtureClicked()
{
	QTreeWidgetItem* item = m_tree->currentItem();
	if (item != NULL)
	{
		int index = m_tree->indexOfTopLevelItem(item);
		if (index == (m_tree->topLevelItemCount() - 1))
			return;

		EFXFixture* ef = reinterpret_cast <EFXFixture*>
			(item->data(0, Qt::UserRole).toULongLong());
		Q_ASSERT(ef != NULL);

		if (m_efx->lowerFixture(ef) == true)
		{
			item = m_tree->takeTopLevelItem(index);
			m_tree->insertTopLevelItem(index + 1, item);
			m_tree->setCurrentItem(item);

			updateIndices(index, index + 1);
		}
	}
}
Example #10
0
bool ObjLoader::load(::QIODevice *ioDev, const QString &subMesh)
{
    Q_CHECK_PTR(ioDev);
    if (!ioDev->isOpen()) {
        qCWarning(Render::Io) << "iodevice" << ioDev << "not open for reading";
        return false;
    }

    int faceCount = 0;

    // Parse faces taking into account each vertex in a face can index different indices
    // for the positions, normals and texture coords;
    // Generate unique vertices (in OpenGL parlance) and output to m_points, m_texCoords,
    // m_normals and calculate mapping from faces to unique indices
    QVector<QVector3D> positions;
    QVector<QVector3D> normals;
    QVector<QVector2D> texCoords;
    QHash<FaceIndices, unsigned int> faceIndexMap;
    QVector<FaceIndices> faceIndexVector;

    bool skipping = false;
    int positionsOffset = 0;
    int normalsOffset = 0;
    int texCoordsOffset = 0;

    QRegExp subMeshMatch(subMesh);
    if (!subMeshMatch.isValid())
        subMeshMatch.setPattern(QString(QStringLiteral("^(%1)$")).arg(subMesh));
    Q_ASSERT(subMeshMatch.isValid());

    QTextStream stream(ioDev);
    while (!stream.atEnd()) {
        QString line = stream.readLine();
        line = line.simplified();

        if (line.length() > 0 && line.at(0) != QChar::fromLatin1('#')) {
            const QVector<QStringRef> tokens = line.splitRef(QChar::fromLatin1(' '));

            if (tokens.first() == QStringLiteral("v")) {
                if (tokens.size() < 4) {
                    qCWarning(Render::Io) << "Unsupported number of components in vertex";
                } else {
                    if (!skipping) {
                        float x = tokens.at(1).toFloat();
                        float y = tokens.at(2).toFloat();
                        float z = tokens.at(3).toFloat();
                        positions.append(QVector3D( x, y, z ));
                    } else {
                        positionsOffset++;
                    }
                }
            } else if (tokens.first() == QStringLiteral("vt") && m_loadTextureCoords) {
                if (tokens.size() < 3) {
                    qCWarning(Render::Io) << "Unsupported number of components in texture coordinate";
                } else {
                    if (!skipping) {
                        // Process texture coordinate
                        float s = tokens.at(1).toFloat();
                        float t = tokens.at(2).toFloat();
                        //FlipUVs
                        t = 1.0f - t;
                        texCoords.append(QVector2D( s, t ));
                    } else {
                        texCoordsOffset++;
                    }
                }
            } else if (tokens.first() == QStringLiteral("vn")) {
                if (tokens.size() < 4) {
                    qCWarning(Render::Io) << "Unsupported number of components in vertex normal";
                } else {
                    if (!skipping) {
                        float x = tokens.at(1).toFloat();
                        float y = tokens.at(2).toFloat();
                        float z = tokens.at(3).toFloat();
                        normals.append(QVector3D( x, y, z ));
                    } else {
                        normalsOffset++;
                    }
                }
            } else if (!skipping && tokens.first() == QStringLiteral("f")) {
                // Process face
                ++faceCount;

                int faceVertices = tokens.size() - 1;

                QVector<FaceIndices> face;
                face.reserve(faceVertices);

                for (int i = 0; i < faceVertices; i++) {
                    FaceIndices faceIndices;
                    const QVector<QStringRef> indices = tokens.at(i + 1).split(QChar::fromLatin1('/'));
                    switch (indices.size()) {
                    case 3:
                        faceIndices.normalIndex = indices.at(2).toInt() - 1 - normalsOffset;  // fall through
                    case 2:
                        faceIndices.texCoordIndex = indices.at(1).toInt() - 1 - texCoordsOffset; // fall through
                    case 1:
                        faceIndices.positionIndex = indices.at(0).toInt() - 1 - positionsOffset;
                        break;
                    default:
                        qCWarning(Render::Io) << "Unsupported number of indices in face element";
                    }

                    face.append(faceIndices);
                }

                // If number of edges in face is greater than 3,
                // decompose into triangles as a triangle fan.
                FaceIndices v0 = face[0];
                FaceIndices v1 = face[1];
                FaceIndices v2 = face[2];

                // First face
                addFaceVertex(v0, faceIndexVector, faceIndexMap);
                addFaceVertex(v1, faceIndexVector, faceIndexMap);
                addFaceVertex(v2, faceIndexVector, faceIndexMap);

                for ( int i = 3; i < face.size(); ++i ) {
                    v1 = v2;
                    v2 = face[i];
                    addFaceVertex(v0, faceIndexVector, faceIndexMap);
                    addFaceVertex(v1, faceIndexVector, faceIndexMap);
                    addFaceVertex(v2, faceIndexVector, faceIndexMap);
                }

                // end of face
            } else if (tokens.first() == QStringLiteral("o")) {
                if (tokens.size() < 2) {
                    qCWarning(Render::Io) << "Missing submesh name";
                } else {
                    if (!subMesh.isEmpty() ) {
                        QString objName = tokens.at(1).toString();
                        skipping = subMeshMatch.indexIn(objName) < 0;
                    }
                }
            }
        } // end of input line
    } // while (!stream.atEnd())

    updateIndices(positions, normals, texCoords, faceIndexMap, faceIndexVector);

    if (m_normals.isEmpty())
        generateAveragedNormals(m_points, m_normals, m_indices);

    if (m_generateTangents && !m_texCoords.isEmpty())
        generateTangents(m_points, m_normals, m_indices, m_texCoords, m_tangents);

    if (m_centerMesh)
        center(m_points);

    qCDebug(Render::Io) << "Loaded mesh:";
    qCDebug(Render::Io) << " " << m_points.size() << "points";
    qCDebug(Render::Io) << " " << faceCount << "faces";
    qCDebug(Render::Io) << " " << m_indices.size() / 3 << "triangles.";
    qCDebug(Render::Io) << " " << m_normals.size() << "normals";
    qCDebug(Render::Io) << " " << m_tangents.size() << "tangents ";
    qCDebug(Render::Io) << " " << m_texCoords.size() << "texture coordinates.";

    return true;
}
inline RMSubRouteReplyPacket*
RouteProcessor::processSubRouteRequestPacket(const RMSubRouteRequestPacket*
                                             subRouteRequestPacket)
{
   RMSubRouteReplyPacket* replyPacket = NULL;
   
   if (subRouteRequestPacket != NULL) {
      
      CalcRoute* calc = getCalcRoute(subRouteRequestPacket->getMapID());
      RoutingMap* curMap = calc->getMap();
      
      // Extract data from the packet
      RMDriverPref* driverPref   = new RMDriverPref;
      Head* origin               = new Head;
      Head* dest                 = new Head;
      Head* allDest              = new Head;         
      SubRouteList* incomingList = new SubRouteList;
      bool originalRequest = subRouteRequestPacket->isOriginalRequest();
      
      subRouteRequestPacket->getDriverPreferences(driverPref);
      subRouteRequestPacket->getOrigins(curMap, origin);
      subRouteRequestPacket->getDestinations(curMap, dest);
      subRouteRequestPacket->getAllDestinations(curMap, allDest);

      DisturbanceVector disturbances;
      subRouteRequestPacket->getSubRouteList(incomingList, &disturbances);

      mc2dbg << "Size of disturbancevector " << disturbances.size() << endl;
      
      mc2dbg << "routeID " << incomingList->getRouteID() << endl;
      mc2dbg << "DriverPrefs : " << *driverPref << endl;


      
      SubRouteList* resultList = new SubRouteList;
      resultList->copyListHeader(*incomingList);
      
      uint32 status;               
      if (calc != NULL) {
         // Always update the destination indices          
         if (incomingList->getListType() == SubRouteListTypes::HIGHER_LEVEL) {
            copySubroutes(incomingList, origin, dest, calc->getMap());
         } else {
            updateIndices(calc, allDest);
            updateIndices(calc, dest);
            
            mc2dbg << "nbrDest    " << dest->cardinal() << endl;
            mc2dbg << "nbrAllDest " << allDest->cardinal() << endl;
            
            if (originalRequest) {
               if (driverPref->useUturn()) {
                  updateUturns(driverPref, origin);
               }
               // Only the first time
               updateIndices(calc, origin);
            } else {
               // XXX This is tricky...
               if (incomingList->getListType() ==
                   SubRouteListTypes::HIGHER_LEVEL_BACKWARD) {
                  copySubroutesToOrigin(incomingList,
                                        dest,
                                        calc->getMap());
               } else {
                  copySubroutesToOrigin(incomingList,
                                        origin,
                                        calc->getMap());
               }
            }
         }
         mc2dbg << "nbrOrigins " << origin->cardinal() << endl;
         // Do the actual routing
         status = calc->route(origin,
                              dest,
                              allDest,
                              incomingList,
                              resultList,
                              driverPref,
                              originalRequest,
                              subRouteRequestPacket->getRouteToAll(),
                              &disturbances,
                              subRouteRequestPacket->getCalcSums(),
                              !subRouteRequestPacket->getDontSendSubRoutes());
         
      }
      else {
         char debugString[1024];
         sprintf(debugString,
                 "This module has not loaded map %u (yet)",
                 subRouteRequestPacket->getMapID());
         mc2log << warn << debugString << endl;
         status = StringTable::MAPNOTFOUND;
         handleMapNotFound(subRouteRequestPacket->getMapID(),
                           subRouteRequestPacket);
      }
      
      replyPacket = getSubRouteReplyPacket(subRouteRequestPacket,
                                           resultList,
                                           status);
      
      // Delete all allocated memory.
      incomingList->deleteAllSubRoutes();      
      delete incomingList;
      resultList->deleteAllSubRoutes();
      delete resultList;
      delete origin;
      delete dest;
      delete allDest;
      delete driverPref;

      int nbrDist = disturbances.size();
      for(int i=0; i < nbrDist; ++i ) {
         delete disturbances[i];
      }
   }
   
   return replyPacket;
} // processSubRouteRequestPacket
Example #12
0
void SpotSelectTool::updateIndices(float imageScale) {
    updateIndices(currentPos / imageScale);
}
// Deprecated
bool AccelerometerSensor::updateIndeces(const Model& model)
{
    return updateIndices(model);
}