Skip to content

Classify method in IvAABB.cpp has a typo issue #60

@vagnerlands

Description

@vagnerlands

Hello, the instructions in the book are correct, but the code in github has a typo issue.

The diagMin, diagMax should be inverted if the normal is negative (i.e., diagMin.x = mMaxima.x; diagMax.x = mMinima.x).
Second issue, is that for Y axis we're comparing "x" instead of "y" (should be: plane.GetNormal().y, instead of plane.GetNormal().x).

Here is how the code should be:

// set min/max values for x direction
if ( plane.GetNormal().x >= 0.0f )
{
    diagMin.x = mMinima.x;
    diagMax.x = mMaxima.x;
}
else
{
    diagMin.x = mMaxima.x;
    diagMax.x = mMinima.x;
}
// set min/max values for y direction
if ( plane.GetNormal().y >= 0.0f )
{
    diagMin.y = mMinima.y;
    diagMax.y = mMaxima.y;
}
else
{
    diagMin.y = mMaxima.y;
    diagMax.y = mMinima.y;
}
// set min/max values for z direction
if ( plane.GetNormal().z >= 0.0f )
{
    diagMin.z = mMinima.z;
    diagMax.z = mMaxima.z;
}
else
{
    diagMin.z = mMaxima.z;
    diagMax.z = mMinima.z;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions