c++structheadermitsuba-renderer

Unable to use properties of custom defined struct


I have a struct defined like so in my header:

struct AABB2 {
    Float xMin, xMax, yMin, yMax;
    AABB2(Float xMin_ = Float(0.0f), Float xMax_ = Float(0.0f), Float yMin_ = Float(0.0f), Float yMax_ = Float(0.0f)) :
        xMin(xMin_), xMax(xMax_), yMin(yMin_), yMax(yMax_) {}
};

and in the cpp file I have a function like this :

EDIT: Sorry I posted the wrong function the first time!

AABB2 combineAABB(const AABB2 &aabb1, const AABB2 &aabb2) {
    AABB2 aabb;
    aabb.xMin = std::min(aabb1.xMin, aabb2.xMin);
    aabb.xMax = std::max(aabb1.xMax, aabb2.xMax);
    aabb.yMin = std::min(aabb1.yMin, aabb2.yMin);
    aabb.yMax = std::max(aabb1.yMax, aabb2.yMax);
    return aabb;
}

AABB2 combineAABB(const AABB2 &aabb1, const AABB2 &aabb2, const AABB2 &aabb3, const AABB2 &aabb4) {
    AABB2 aabbA = combineAABB(aabb1, aabb2);
    AABB2 aabbB = combineAABB(aabb3, aabb4);
    return combineAABB(aabbA, aabbB);
}


// the call to the combine function

 vector<AABB2> &angularBBRow = angularBBLayer[i];

for (int j = 0; j < currentWidth; j++) {
                AABB2 aabb1 = angularBB[currentLayer - 1][i * 2 + 0][j * 2 + 0];
                AABB2 aabb2 = angularBB[currentLayer - 1][i * 2 + 1][j * 2 + 0];
                AABB2 aabb3 = angularBB[currentLayer - 1][i * 2 + 1][j * 2 + 1];
                AABB2 aabb4 = angularBB[currentLayer - 1][i * 2 + 0][j * 2 + 1];

        angularBBRow.push_back(combineAABB(aabb1, aabb2, aabb3, aabb4));
}


but for some reason why I try to call this function to actually use it I get an error message saying error: ‘mitsuba::AABB2’ has no member named ‘xMin’

EXTRA INFO:

mitsuba is a rendering engine that I am trying to implement this in and so that's why it is present in the error message.

Any idea why this is the case?


Solution

  • The mitsuba rendering engine defines its own type for AABB2:

    typedef TAABB<Point2> AABB2
    

    It is clear that the error message is referring to this type, which lives in the mitsuba namespace. When the compiler tries to resolve the type of AABB2 it is picking up mitsuba's version, not yours.

    While you haven't shown adequate code despite our efforts in requesting it, there's a high likelihood that you are doing one of the following:

    You may well fix the problem by addressing these points. Alternatively, you could try renaming your struct to something that is not used by mitsuba.