示例#1
0
void DotSpreaderTool::mainButtonReleased(const ToolBox::ButtonReleaseEvent & buttonReleaseEvent)
{
   if (experiment == NULL || locked)
   {
      return;
   }

   master::filter(std::cout)() << "DotSpreader::releasing " << data.numPoints << " particles... "
         << std::endl;

   // get current locator position
   pos=toolBox()->deviceTransformationInModel().getOrigin();

   // compute radius of release sphere
   float radius=Math::sqrt((pos[0] - org[0]) * (pos[0] - org[0]) + (pos[1]
         - org[1]) * (pos[1] - org[1]) + (pos[2] - org[2]) * (pos[2] - org[2]));

   releaseParticles(pos, radius);
}
示例#2
0
void DownGroup::updateVisuals()
{
    ParticleGroup::updateVisuals();

    PxParticleReadData * readData = m_particleSystem->lockParticleReadData();
    assert(readData);

    m_particleDrawable->updateParticles(readData);

    // Get drained Particles
    std::vector<uint32_t> particlesToDelete;
    PxStrideIterator<const PxParticleFlags> flagsIt(readData->flagsBuffer);
    PxStrideIterator<const PxVec3> positionIt = readData->positionBuffer;


    TerrainInteraction terrain("water");
    std::vector<unsigned int> lavaToSteam;
    glowutils::AxisAlignedBoundingBox steamBbox;
    std::vector<glm::vec3> steamPositions;

    const TerrainSettings & terrainSettings = terrain.terrain().settings;

    for (unsigned i = 0; i < readData->validParticleRange; ++i, ++flagsIt, ++positionIt) {
        // check range
        if (!(*flagsIt & PxParticleFlag::eVALID)) {
            continue;
        }

        if (positionIt->y > terrainSettings.maxHeight * 0.75f) {
            particlesToDelete.push_back(i);
            continue;
        }

        if (*flagsIt & PxParticleFlag::eCOLLISION_WITH_STATIC) {
            if (positionIt->y < m_particleSize + 0.1)   // collision with water plane
            {
                if (m_elementName == "lava")
                {
                    lavaToSteam.push_back(i);
                    steamBbox.extend(reinterpret_cast<const glm::vec3&>(*positionIt));
                    steamPositions.push_back(reinterpret_cast<const glm::vec3&>(*positionIt));
                    continue;
                } else {
                    particlesToDelete.push_back(i);
                    continue;
                }
            }
            if (terrain.topmostElementAt(positionIt->x, positionIt->z) == m_elementName)
            {
                particlesToDelete.push_back(i);
            }
        }
    }

    assert(m_numParticles == readData->nbValidParticles);
    readData->unlock();

    if (!particlesToDelete.empty())
        releaseParticles(particlesToDelete);

    if (!lavaToSteam.empty())
    {
        DownGroup * steamGroup = ParticleGroupTycoon::instance().getNearestGroup("steam", steamBbox.center());
        steamGroup->createParticles(steamPositions);
        releaseParticles(lavaToSteam);
    }
}