예제 #1
0
void aaCubeFromScriptValue(const QScriptValue &object, AACube& aaCube) {
    glm::vec3 corner;
    corner.x = object.property("x").toVariant().toFloat();
    corner.y = object.property("y").toVariant().toFloat();
    corner.z = object.property("z").toVariant().toFloat();
    float scale = object.property("scale").toVariant().toFloat();

    aaCube.setBox(corner, scale);
}
예제 #2
0
void ParticleTreeElement::getParticles(const AACube& box, QVector<Particle*>& foundParticles) {
    QList<Particle>::iterator particleItr = _particles->begin();
    QList<Particle>::iterator particleEnd = _particles->end();
    AACube particleCube;
    while(particleItr != particleEnd) {
        Particle* particle = &(*particleItr);
        float radius = particle->getRadius();
        // NOTE: we actually do box-box collision queries here, which is sloppy but good enough for now
        // TODO: decide whether to replace particleBox-box query with sphere-box (requires a square root
        // but will be slightly more accurate).
        particleCube.setBox(particle->getPosition() - glm::vec3(radius), 2.f * radius);
        if (particleCube.touches(_cube)) {
            foundParticles.push_back(particle);
        }
        ++particleItr;
    }
}