void Polyhedron::intersect(Plane iplane)
{
	DEBUG_START;
	Intersector* intersector = new Intersector(get_ptr());
	intersector->run(iplane);
	delete intersector;
	DEBUG_END;
}
void Polyhedron::intersectCoalesceMode(Plane iplane, int jfid)
{
	DEBUG_START;
	Intersector* intersector = new Intersector(get_ptr());
	intersector->runCoalesceMode(iplane, jfid);
	delete intersector;
	DEBUG_END;
}
        double get_autofocus_focal_distance(const Intersector& intersector) const
        {
            // The autofocus considers the scene at the middle of the shutter interval.
            const float time = get_shutter_middle_time();
            const Transformd transform = m_transform_sequence.evaluate(time);

            // Create a ray that goes through the center of the lens.
            ShadingRay ray;
            ray.m_org = transform.get_local_to_parent().extract_translation();
            ray.m_dir = normalize(transform.vector_to_parent(-ndc_to_camera(m_autofocus_target)));
            ray.m_tmin = 0.0;
            ray.m_tmax = numeric_limits<double>::max();
            ray.m_time =
                ShadingRay::Time::create_with_normalized_time(
                    0.5f,
                    get_shutter_open_time(),
                    get_shutter_close_time());
            ray.m_flags = VisibilityFlags::ProbeRay;
            ray.m_depth = 0;

            // Trace the ray.
            ShadingPoint shading_point;
            intersector.trace(ray, shading_point);

            if (shading_point.hit())
            {
                // Hit: compute the focal distance.
                const Vector3d v = shading_point.get_point() - ray.m_org;
                const double af_focal_distance = -transform.vector_to_local(v).z;

                RENDERER_LOG_INFO(
                    "camera \"%s\": autofocus sets focal distance to %f (using camera position at time=%.1f).",
                    get_path().c_str(),
                    af_focal_distance,
                    ray.m_time.m_absolute);

                return af_focal_distance;
            }
            else
            {
                // Miss: focus at infinity.
                RENDERER_LOG_INFO(
                    "camera \"%s\": autofocus sets focal distance to infinity (using camera position at time=%.1f).",
                    get_path().c_str(),
                    ray.m_time.m_absolute);

                return 1.0e38;
            }
        }
예제 #4
0
        double get_autofocus_focal_distance(const Intersector& intersector) const
        {
            // The autofocus considers the scene at the middle of the shutter interval.
            const double time = get_shutter_middle_time();
            const Transformd transform = m_transform_sequence.evaluate(time);

            // Compute the camera space coordinates of the focus point.
            const Vector3d film_point = ndc_to_camera(m_autofocus_target);

            // Create a ray in world space.
            ShadingRay ray;
            ray.m_org = transform.point_to_parent(Vector3d(0.0));
            ray.m_dir = transform.point_to_parent(film_point) - ray.m_org;
            ray.m_tmin = 0.0;
            ray.m_tmax = numeric_limits<double>::max();
            ray.m_time = time;
            ray.m_type = ShadingRay::ProbeRay;
            ray.m_depth = 0;

            // Trace the ray.
            ShadingPoint shading_point;
            intersector.trace(ray, shading_point);

            if (shading_point.hit())
            {
                // Hit: compute the focal distance.
                const Vector3d v = shading_point.get_point() - ray.m_org;
                const double af_focal_distance = -transform.vector_to_local(v).z;

                RENDERER_LOG_INFO(
                    "camera \"%s\": autofocus sets focal distance to %f (using camera position at time=%.1f).",
                    get_name(),
                    af_focal_distance,
                    ray.m_time);

                return af_focal_distance;
            }
            else
            {
                // Miss: focus at infinity.
                RENDERER_LOG_INFO(
                    "camera \"%s\": autofocus sets focal distance to infinity (using camera position at time=%.1f).",
                    get_name(),
                    ray.m_time);

                return 1.0e38;
            }
        }
예제 #5
0
void LightSample::make_shading_point(
    ShadingPoint&           shading_point,
    const Vector3d&         direction,
    const Intersector&      intersector) const
{
    assert(m_triangle && !m_light);

    intersector.manufacture_hit(
        shading_point,
        ShadingRay(
            m_point,
            direction,
            0.0,
            0.0,
            ShadingRay::Time(),
            VisibilityFlags::CameraRay, 0),
        ShadingPoint::PrimitiveTriangle,    // note: we assume light samples are always on triangles (and not on curves)
        m_triangle->m_assembly_instance,
        m_triangle->m_assembly_instance->transform_sequence().get_earliest_transform(),
        m_triangle->m_object_instance_index,
        m_triangle->m_region_index,
        m_triangle->m_triangle_index,
        m_triangle->m_triangle_support_plane);
}