From 923069f877a068334d4c955ed6089697b5bf9597 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 20 Mar 2014 12:57:31 +0100 Subject: [PATCH] ported cylinder.cpp improvements to hair.cpp --- src/shapes/hair.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/shapes/hair.cpp b/src/shapes/hair.cpp index 4aef8248..39e3bce4 100644 --- a/src/shapes/hair.cpp +++ b/src/shapes/hair.cpp @@ -840,6 +840,11 @@ void HairShape::fillIntersectionRecord(const Ray &ray, const Vector relHitPoint = its.p - m_kdtree->firstVertex(iv); its.geoFrame.n = Normal(normalize(relHitPoint - dot(axis, relHitPoint) * axis)); its.geoFrame.t = cross(its.geoFrame.n, its.geoFrame.s); + + /* Migitate roundoff error issues by a normal shift of the computed intersection point */ + const Vector local = its.geoFrame.toLocal(relHitPoint); + its.p += its.geoFrame.n * (m_kdtree->getRadius() - std::sqrt(local.y*local.y+local.z*local.z)); + its.shFrame = its.geoFrame; its.wi = its.toLocal(-ray.d); its.hasUVPartials = false;