// Return delta (P to N) vectors across coupled patch
Foam::tmp<Foam::vectorField> Foam::cyclicGgiFvPatch::delta() const
{
    if (cyclicGgiPolyPatch_.master())
    {
        tmp<vectorField> tDelta =
            cyclicGgiPolyPatch_.reconFaceCellCentres() - Cn();

        if (bridgeOverlap())
        {
            vectorField bridgeDeltas = Cf() - Cn();

            bridge(bridgeDeltas, tDelta());
        }

        return tDelta;
    }
    else
    {
        tmp<vectorField> tDelta = interpolate
        (
            shadow().Cn() - cyclicGgiPolyPatch_.shadow().reconFaceCellCentres()
        );

        if (bridgeOverlap())
        {
            vectorField bridgeDeltas = Cf() - Cn();

            bridge(bridgeDeltas, tDelta());
        }

        return tDelta;
    }
}
// Return delta (P to N) vectors across coupled patch
Foam::tmp<Foam::vectorField> Foam::regionCoupleFvPatch::delta() const
{
    if (rcPolyPatch_.coupled())
    {
        if (rcPolyPatch_.master())
        {
            tmp<vectorField> tDelta =
                rcPolyPatch_.reconFaceCellCentres() - Cn();

            if (bridgeOverlap())
            {
                vectorField bridgeDeltas = Cf() - Cn();

                bridge(bridgeDeltas, tDelta());
            }

            return tDelta;
        }
        else
        {
            tmp<vectorField> tDelta = interpolate
            (
                shadow().Cn() - rcPolyPatch_.shadow().reconFaceCellCentres()
            );

            if (bridgeOverlap())
            {
                vectorField bridgeDeltas = Cf() - Cn();

                bridge(bridgeDeltas, tDelta());
            }

            return tDelta;
        }
    }
    else
    {
        return fvPatch::delta();
    }
}
Esempio n. 3
0
void Player::traceView() {
    World* w = (World*)getGame()->getObjectByName("world");
    float tMax = 10; //View radius
    vec3f   cpos(cam->getWorldPos()),
            dir(cam->getForward()),
            vox(floor(cpos.x), floor(cpos.y), floor(cpos.z)),
            step(0,0,0),
            next(0,0,0),
            tMaxc(tMax,tMax,tMax),
            tDelta(tMax,tMax,tMax);

    if (!w->outOfBounds(cpos.x,cpos.y,cpos.z) &&
        w->getCube(cpos.x,cpos.y,cpos.z) != 0) {
        targetsBlock = true;
        targetedBlock = vec3f(floor(cpos.x),floor(cpos.y),floor(cpos.z));
        return;
    }

    if (dir.x < 0) step.x = -1;
    else step.x = 1;
    if (dir.y < 0) step.y = -1;
    else step.y = 1;
    if (dir.z < 0) step.z = -1;
    else step.z = 1;

    next.x = vox.x + (step.x > 0 ? 1 : 0);
    next.y = vox.y + (step.y > 0 ? 1 : 0);
    next.z = vox.z + (step.z > 0 ? 1 : 0);

    if (dir.x != 0) {
        tDelta.x = step.x/dir.x;
        tMaxc.x = (next.x - cpos.x)/dir.x;
    }
    if (dir.y != 0) {
        tDelta.y = step.y/dir.y;
        tMaxc.y = (next.y - cpos.y)/dir.y;
    }
    if (dir.z != 0) {
        tDelta.z = step.z/dir.z;
        tMaxc.z = (next.z - cpos.z)/dir.z;
    }

    float tCurr = 0;
    while (tCurr < tMax) {
        targetedBlockEnter = vox;
        if(tMaxc.x < tMaxc.y) {
            if(tMaxc.x < tMaxc.z) {
                tCurr = tMaxc.x;
                tMaxc.x = tMaxc.x + tDelta.x;
                vox.x = vox.x + step.x;
            }
            else {
                tCurr = tMaxc.z;
                vox.z = vox.z + step.z;
                tMaxc.z = tMaxc.z + tDelta.z;
            }
        }
        else {
            if(tMaxc.y < tMaxc.z) {
                tCurr = tMaxc.y;
                vox.y = vox.y + step.y;
                tMaxc.y = tMaxc.y + tDelta.y;
            }
            else {
                tCurr = tMaxc.z;
                vox.z = vox.z + step.z;
                tMaxc.z= tMaxc.z + tDelta.z;
            }
        }
        if(!w->outOfBounds(vox.x,vox.y,vox.z) && w->getCube(vox.x,vox.y,vox.z) != 0) {
            targetsBlock = true;
            targetedBlock = vox;
            return;
        }
    }
    targetsBlock = false;
}