Commit 2d4a43a8 authored by maesius's avatar maesius
Browse files

Debugage de la binder grid. Ca marche.

parent b6cccab6
Loading
Loading
Loading
Loading
+42 −34
Original line number Diff line number Diff line
@@ -100,6 +100,14 @@ void LrBinderRegularGrid::initBinder()

    }

    min.x -= EPSILON;
    min.y -= EPSILON;
    min.z -= EPSILON;

    max.x += EPSILON;
    max.y += EPSILON;
    max.z += EPSILON;

    m_lenBinder = LrVector(min,max);

    lenVoxelX = (max.x - min.x) / m_nbVoxelX;
@@ -120,7 +128,6 @@ void LrBinderRegularGrid::initBinder()
            (*itEntity)->getMinMax(minTMP, maxTMP, i, infoVoxel.m_entite, infoVoxel.m_numFragment);


/*
            minVoxelI = (int)(((minTMP.x - min.x) / m_lenBinder.x) * m_nbVoxelX);
            minVoxelJ = (int)(((minTMP.y - min.y) / m_lenBinder.y) * m_nbVoxelY);
            minVoxelK = (int)(((minTMP.z - min.z) / m_lenBinder.z) * m_nbVoxelZ);
@@ -128,11 +135,11 @@ void LrBinderRegularGrid::initBinder()
            maxVoxelI = (int)(((maxTMP.x - min.x) / m_lenBinder.x) * m_nbVoxelX);
            maxVoxelJ = (int)(((maxTMP.y - min.y) / m_lenBinder.y) * m_nbVoxelY);
            maxVoxelK = (int)(((maxTMP.z - min.z) / m_lenBinder.z) * m_nbVoxelZ);
*/

            for (int i = 0; i < m_nbVoxelX; i++) {
                for (int j = 0; j < m_nbVoxelY; j++) {
                    for (int k = 0; k < m_nbVoxelZ; k++) {

            for (int i = minVoxelI; i <= maxVoxelI; i++) {
                for (int j = minVoxelJ; j <= maxVoxelJ; j++) {
                    for (int k = minVoxelK; k <= maxVoxelK; k++) {

                        int numCase = (i + m_nbVoxelX * (j + k * m_nbVoxelY));
                        m_tabVoxel[numCase].push_back(infoVoxel);
@@ -179,7 +186,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
    // ### Debut : Intersection en X
    if (dir.x > EPSILON) {

        int distExitTMP = (int)((max.x - orig.x - EPSILON)/dir.x);
        Real distExitTMP = (max.x - orig.x - EPSILON)/dir.x;

        if (distExitTMP < distExit) {
            distExit = distExitTMP;
@@ -187,7 +194,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        if (!origInBinder) {

            int distEntryTMP = (int)((min.x - orig.x + EPSILON)/dir.x);
            Real distEntryTMP = (min.x - orig.x + EPSILON)/dir.x;

            if (distEntryTMP > distEntry) {
                distEntry = distEntryTMP;
@@ -195,9 +202,9 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        }

    } else if (dir.x < EPSILON) {
    } else if (dir.x < -EPSILON) {

        int distExitTMP = (int)((min.x - orig.x + EPSILON)/dir.x);
        Real distExitTMP = (min.x - orig.x + EPSILON)/dir.x;

        if (distExitTMP < distExit) {
            distExit = distExitTMP;
@@ -205,7 +212,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        if (!origInBinder) {

            int distEntryTMP = (int)((max.x - orig.x - EPSILON)/dir.x);
            Real distEntryTMP = (max.x - orig.x - EPSILON)/dir.x;

            if (distEntryTMP > distEntry) {
                distEntry = distEntryTMP;
@@ -228,7 +235,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
    // ### Debut : Intersection en Y
    if (dir.y > EPSILON) {

        int distExitTMP = (int)((max.y - orig.y - EPSILON)/dir.y);
        Real distExitTMP = (max.y - orig.y - EPSILON)/dir.y;

        if (distExitTMP < distExit) {
            distExit = distExitTMP;
@@ -236,7 +243,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        if (!origInBinder) {

            int distEntryTMP = (int)((min.y - orig.y + EPSILON)/dir.y);
            Real distEntryTMP = (min.y - orig.y + EPSILON)/dir.y;

            if (distEntryTMP > distEntry) {
                distEntry = distEntryTMP;
@@ -244,9 +251,9 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        }

    } else if (dir.y < EPSILON) {
    } else if (dir.y < -EPSILON) {

        int distExitTMP = (int)((min.y - orig.y + EPSILON)/dir.y);
        Real distExitTMP = (min.y - orig.y + EPSILON)/dir.y;

        if (distExitTMP < distExit) {
            distExit = distExitTMP;
@@ -254,7 +261,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        if (!origInBinder) {

            int distEntryTMP = (int)((max.y - orig.y - EPSILON)/dir.y);
            Real distEntryTMP = (max.y - orig.y - EPSILON)/dir.y;

            if (distEntryTMP > distEntry) {
                distEntry = distEntryTMP;
@@ -274,7 +281,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
    // ### Debut : Intersection en Z
    if (dir.z > EPSILON) {

        int distExitTMP = (int)((max.z - orig.z - EPSILON)/dir.z);
        Real distExitTMP = (max.z - orig.z - EPSILON)/dir.z;

        if (distExitTMP < distExit) {
            distExit = distExitTMP;
@@ -282,7 +289,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        if (!origInBinder) {

            int distEntryTMP = (int)((min.z - orig.z + EPSILON)/dir.z);
            Real distEntryTMP = (min.z - orig.z + EPSILON)/dir.z;

            if (distEntryTMP > distEntry) {
                distEntry = distEntryTMP;
@@ -290,9 +297,9 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        }

    } else if (dir.z < EPSILON) {
    } else if (dir.z < -EPSILON) {

        int distExitTMP = (int)((min.z - orig.z + EPSILON)/dir.z);
        Real distExitTMP = (min.z - orig.z + EPSILON)/dir.z;

        if (distExitTMP < distExit) {
            distExit = distExitTMP;
@@ -300,7 +307,7 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min

        if (!origInBinder) {

            int distEntryTMP = (int)((max.z - orig.z - EPSILON)/dir.z);
            Real distEntryTMP = (max.z - orig.z - EPSILON)/dir.z;

            if (distEntryTMP > distEntry) {
                distEntry = distEntryTMP;
@@ -326,8 +333,8 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
    pointEntry = ray.getPoint(distEntry + EPSILON);

    curVoxelX = (int)(((pointEntry.x - min.x) / m_lenBinder.x) * m_nbVoxelX);
    curVoxelY = (int)(((pointEntry.x - min.x) / m_lenBinder.x) * m_nbVoxelX);
    curVoxelZ = (int)(((pointEntry.x - min.x) / m_lenBinder.x) * m_nbVoxelX);
    curVoxelY = (int)(((pointEntry.y - min.y) / m_lenBinder.y) * m_nbVoxelY);
    curVoxelZ = (int)(((pointEntry.z - min.z) / m_lenBinder.z) * m_nbVoxelZ);

    if (origInBinder) {
        minbound = 2 * EPSILON;
@@ -347,12 +354,12 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
            dx = m_lenVoxel.x / dir.x;
            Dx = (min.x + m_lenVoxel.x * (curVoxelX+1) - orig.x) / dir.x;

    } else if (dir.x < EPSILON) {
    } else if (dir.x < -EPSILON) {

            vX = -1;
            incVoxelX = -1;

            dx = m_lenVoxel.x / dir.x;
            dx = -m_lenVoxel.x / dir.x;
            Dx = (min.x + m_lenVoxel.x * (curVoxelX) - orig.x) / dir.x;

    } else {
@@ -370,12 +377,12 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
            dy = m_lenVoxel.y / dir.y;
            Dy = (min.y + m_lenVoxel.y * (curVoxelY+1) - orig.y) / dir.y;

    } else if (dir.y < EPSILON) {
    } else if (dir.y < -EPSILON) {

            vY = -1;
            incVoxelY = -m_nbVoxelX;

            dy = m_lenVoxel.y / dir.y;
            dy = -m_lenVoxel.y / dir.y;
            Dy = (min.y + m_lenVoxel.y * (curVoxelY) - orig.y) / dir.y;

    } else {
@@ -394,12 +401,12 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
            dz = m_lenVoxel.z / dir.z;
            Dz = (min.z + m_lenVoxel.z * (curVoxelZ+1) - orig.z) / dir.z;

    } else if (dir.z < EPSILON) {
    } else if (dir.z < -EPSILON) {

            vZ = -1;
            incVoxelZ = -(m_nbVoxelX * m_nbVoxelY);

            dz = m_lenVoxel.z / dir.z;
            dz = -m_lenVoxel.z / dir.z;
            Dz = (min.z + m_lenVoxel.z * (curVoxelZ) - orig.z) / dir.z;

    } else {
@@ -437,12 +444,13 @@ bool LrBinderRegularGrid::getIntersection(const LrRay &ray, LrHit *hit, Real min
            impact = entity->getIntersection(ray, hit, numFrag, minbound-EPSILON, maxbound+EPSILON);
            intersection = intersection || impact;


            if (impact) {
                if (hit != NULL) {
                    maxbound = hit->distance;
                } else {
                    break;
                }
            }

        }

+2 −2
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ void LrEntityElementary::getMinMax(LrPoint &min, LrPoint &max, int fragment,
{
    fragmentLocal = fragment;
    entityLocal = (LrEntity*)this;
    m_geometry->getMinMax(min,max,fragment);
    m_geometry->getMinMax(min, max, fragment, m_transf);
}

int LrEntityElementary::getNbFragments() const{
+16 −8
Original line number Diff line number Diff line
@@ -213,6 +213,14 @@ void LrGeometry::getMinMax(LrPoint &min, LrPoint &max, const LrMatrix &transform
    transformMinMax(min, max, transform);
}

void LrGeometry::getMinMax(LrPoint &min, LrPoint &max, int fragment, const LrMatrix &transform) const {

    getMinMax(min, max, fragment);
    transformMinMax(min, max, transform);

}


void LrGeometry::xyz2uv(const LrPoint &point, Real &u, Real &v) const
{
   LrPoint min, max;
+25 −23
Original line number Diff line number Diff line
@@ -167,6 +167,8 @@ public:
    virtual void getMinMax(LrPoint &min, LrPoint &max,
                           const LrMatrix &transform) const;

    virtual void getMinMax(LrPoint &min, LrPoint &max, int fragment, const LrMatrix &transform) const;

protected:
    /**
     * @brief Conversion de coordonnées absolues en paramétriques.
+6 −5
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ void LrSceneRayTracing::generateImagePart(int lOffset, int lNb)
        for (int c = 0; c < m_image->getWidth(); c++)
        {


            LrColor pixel = LrColor::BLACK;

            for (int i = 0; i < nbRayPerPixel; i++)