]> git.tdb.fi Git - libs/math.git/commitdiff
Use the proper array size in the raytrace example
authorMikko Rasa <tdb@tdb.fi>
Sat, 2 Jul 2016 16:58:44 +0000 (19:58 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 2 Jul 2016 16:58:44 +0000 (19:58 +0300)
examples/raytrace.cpp

index 2af86530ba227389b4c2421802fb08cb0b0dec7c..7827bd39105674a0d1726b286948257dab9a4880 100644 (file)
@@ -50,6 +50,8 @@ int RayTracer::main()
 {
        load_shape();
 
+       vector<Geometry::SurfacePoint<double, 3> > points(shape->get_max_ray_intersections());
+
        for(unsigned y=0; y<height; ++y)
        {
                double yf = 1.0-y*2.0/height;
@@ -57,8 +59,7 @@ int RayTracer::main()
                {
                        double xf = x*2.0/width-1.0;
                        Geometry::Ray<double, 3> ray(LinAl::Vector<double, 3>(0, 0, 5), LinAl::Vector<double, 3>(xf, yf, -2));
-                       Geometry::SurfacePoint<double, 3> points[4];
-                       unsigned count = shape->get_intersections(ray, points, 4);
+                       unsigned count = shape->get_intersections(ray, &points[0], points.size());
                        UInt8 *pixel = pixels+y*width+x;
                        if(count)
                                *pixel = 255*(0.2+max(dot(points[0].normal, LinAl::Vector<double, 3>(0, 0, 1)), 0.0)*0.8);