All pastes #561799 Raw Edit

Something

public text v1 · immutable
·published 2007-06-12 15:54 UTC
rendered paste body
static Bool
cubeCheckFTB (CompScreen              *s,
              const ScreenPaintAttrib *sAttrib,
              const CompTransform     *transform,
              CompOutput              *outputPtr)
{
    Bool answer = FALSE;

    float mvp[16];
    CompTransform sTransform = *transform;

    (*s->applyScreenTransform) (s, sAttrib, outputPtr, &sTransform);
    transformToScreenSpace (s, outputPtr, -sAttrib->zTranslate, &sTransform);

    MULTM(s->projection, sTransform.m, mvp);

    float pntA[4] = { outputPtr->region.extents.x1,
                      outputPtr->region.extents.y1 + outputPtr->height / 2.0f,
                      0, 1};
    float pntB[4] = { outputPtr->region.extents.x2  + outputPtr->width,
                      outputPtr->region.extents.y1 + outputPtr->height / 2.0f,
                      0, 1};


    float pntC[4] = { outputPtr->region.extents.x1 + outputPtr->width / 2.0f,
                      outputPtr->region.extents.y1,
                      0, 1};
    float pntD[4] = { outputPtr->region.extents.x1 + outputPtr->width / 2.0f,
                      outputPtr->region.extents.y1 + outputPtr->height,
                      0, 1};

    MULTMV(mvp, pntA);
    DIVV(pntA);

    MULTMV(mvp, pntB);
    DIVV(pntB);

    MULTMV(mvp, pntC);
    DIVV(pntC);

    MULTMV(mvp, pntD);
    DIVV(pntD);

    if (pntA[0] > pntB[0])
	answer = ~answer;
    if (pntC[1] > pntD[1])
	answer = ~answer;

    return answer;
}