diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-07-13 23:33:25 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-07-13 23:33:25 +0400 |
commit | 33b65832d2002979c27b39a1fbe1d59f77a24565 (patch) | |
tree | 331a9914fe8a231a7b0ecaa3cd2513750f314a02 /source/blender/freestyle/intern/view_map/GridDensityProvider.h | |
parent | b7396654e181b84985ef54b7afce252b2584e69a (diff) |
Fix for [#35482] 2.67 freestyle line visibility computation bug.
The reported line visibility issue was caused by a wrong calculation of a 2D
bounding box (so-called "proscenium face" in Freestyle) in the case of a
spherical grid data structure used for a perspective camera. The problem was
resulting from the proscenium computation based on two corners (min and max)
of the 3D bounding box of imported mesh data. Aware of the spherical coordinate
transformation involving non-linear (arctangent) functions, now the proscenium
is computed by taking in account all the eight corners of the 3D bounding box.
Also added minor code changes to facilitate future debugging.
Diffstat (limited to 'source/blender/freestyle/intern/view_map/GridDensityProvider.h')
-rw-r--r-- | source/blender/freestyle/intern/view_map/GridDensityProvider.h | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h b/source/blender/freestyle/intern/view_map/GridDensityProvider.h index d096fb3aacd..fe14efbe20f 100644 --- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h +++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h @@ -100,24 +100,29 @@ public: static void calculateQuickProscenium(const GridHelpers::Transform& transform, const BBox<Vec3r>& bbox, real proscenium[4]) { - real z; - // We want to use the z-coordinate closest to the camera to determine the proscenium face - if (::fabs(bbox.getMin()[2]) < ::fabs(bbox.getMax()[2])) { - z = bbox.getMin()[2]; - } - else { - z = bbox.getMax()[2]; - } - // Now calculate the proscenium according to the min and max values of the x and y coordinates - Vec3r minPoint = transform(Vec3r(bbox.getMin()[0], bbox.getMin()[1], z)); - Vec3r maxPoint = transform(Vec3r(bbox.getMax()[0], bbox.getMax()[1], z)); - proscenium[0] = std::min(minPoint[0], maxPoint[0]); - proscenium[1] = std::max(minPoint[0], maxPoint[0]); - proscenium[2] = std::min(minPoint[1], maxPoint[1]); - proscenium[3] = std::max(minPoint[1], maxPoint[1]); + // Transform the coordinates of the 8 corners of the 3D bounding box + real xm = bbox.getMin()[0], xM = bbox.getMax()[0]; + real ym = bbox.getMin()[1], yM = bbox.getMax()[1]; + real zm = bbox.getMin()[2], zM = bbox.getMax()[2]; + Vec3r p1 = transform(Vec3r(xm, ym, zm)); + Vec3r p2 = transform(Vec3r(xm, ym, zM)); + Vec3r p3 = transform(Vec3r(xm, yM, zm)); + Vec3r p4 = transform(Vec3r(xm, yM, zM)); + Vec3r p5 = transform(Vec3r(xM, ym, zm)); + Vec3r p6 = transform(Vec3r(xM, ym, zM)); + Vec3r p7 = transform(Vec3r(xM, yM, zm)); + Vec3r p8 = transform(Vec3r(xM, yM, zM)); + // Determine the proscenium face according to the min and max values of the transformed x and y coordinates + proscenium[0] = std::min(std::min(std::min(p1.x(), p2.x()), std::min(p3.x(), p4.x())), + std::min(std::min(p5.x(), p6.x()), std::min(p7.x(), p8.x()))); + proscenium[1] = std::max(std::max(std::max(p1.x(), p2.x()), std::max(p3.x(), p4.x())), + std::max(std::max(p5.x(), p6.x()), std::max(p7.x(), p8.x()))); + proscenium[2] = std::min(std::min(std::min(p1.y(), p2.y()), std::min(p3.y(), p4.y())), + std::min(std::min(p5.y(), p6.y()), std::min(p7.y(), p8.y()))); + proscenium[3] = std::max(std::max(std::max(p1.y(), p2.y()), std::max(p3.y(), p4.y())), + std::max(std::max(p5.y(), p6.y()), std::max(p7.y(), p8.y()))); if (G.debug & G_DEBUG_FREESTYLE) { - cout << "Bounding box: " << minPoint << " to " << maxPoint << endl; - cout << "Proscenium : " << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2] << ", " << + cout << "Proscenium: " << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2] << ", " << proscenium[3] << endl; } } |