RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
997 stars 182 forks source link

Incorrect bounds returned #387

Closed paulmelis closed 4 years ago

paulmelis commented 4 years ago

With 8879ce67e1f3d6095cae05ce781eae92585af0ef the returned bounds from a cpp::Group and cpp::World are incorrect. They seem to duplicate the x values for y and z. This is true also for the underlying OSPBounds:

#include <ospray/ospray_cpp.h>

using namespace ospcommon::math;
using namespace ospray::cpp;

int main(int argc, const char *argv[])
{
    ospInit(&argc, argv);

    std::vector<vec3f>  vertices;
    std::vector<vec3ui>  indices;

    vertices.push_back(vec3f(-3, -2, -1));
    vertices.push_back(vec3f(0, 0, 0));
    vertices.push_back(vec3f(1, 2, 3));

    indices.push_back(vec3ui(0, 1, 2));

    Geometry mesh("mesh");
    mesh.setParam("vertex.position", Data(vertices));
    mesh.setParam("index", Data(indices));
    mesh.commit();

    GeometricModel gmodel(mesh);
    gmodel.commit();

    Group group;
    group.setParam("geometry", Data(gmodel));
    group.commit();

    box3f bounds = group.getBounds();
    printf("%.6f %.6f %.6f -> %.6f %.6f %.6f\n", bounds.lower.x, bounds.lower.y, bounds.lower.z,
        bounds.upper.x, bounds.upper.y, bounds.upper.z);

    OSPGroup _group = group.handle();
    OSPBounds _bounds = ospGetBounds(_group);

    printf("%.6f %.6f %.6f -> %.6f %.6f %.6f\n", _bounds.lower[0], _bounds.lower[1], 
        _bounds.lower[2], _bounds.upper[0], _bounds.upper[1], _bounds.upper[2]);

    Instance instance(group);
    instance.commit();

    World world;
    world.setParam("instance", Data(instance));
    world.commit();

    bounds = world.getBounds();
    printf("%.6f %.6f %.6f -> %.6f %.6f %.6f\n", bounds.lower.x, bounds.lower.y, bounds.lower.z,
        bounds.upper.x, bounds.upper.y, bounds.upper.z);    
}

For me the above outputs:

$ ./t_bound 
-3.000000 -3.000000 -3.000000 -> 1.000000 1.000000 1.000000
-3.000000 -3.000000 -3.000000 -> 1.000000 1.000000 1.000000
-3.000000 -3.000000 -3.000000 -> 1.000000 1.000000 1.000000
paulmelis commented 4 years ago

Error is here:

https://github.com/ospray/ospray/blob/8879ce67e1f3d6095cae05ce781eae92585af0ef/ospray/common/Group.cpp#L174-L186

The vectors are initialized with the first element of upper/lower, instead of passing the array pointer. Same thing happens in World.cpp.

paulmelis commented 4 years ago

@jeffamstutz As a 2.0 release seems to be imminent just wanted to remark that this issue is still there

jeffamstutz commented 4 years ago

Thanks, we were on a time crunch for v2.0 to be "out", so there's likely a v2.0.1 patch release with several bug fixes right around the corner.

jeffamstutz commented 4 years ago

Wow, my tunnel vision on v2.0 was bad, this fix is simple! Thanks for your patience.