From 5d519c72b337f07b2ac500e6e2ac5679ef38b9e6 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Fri, 28 Jun 2024 11:28:39 -0700 Subject: [PATCH 1/2] [hdEmbree] factor out a _CalculateHitPosition utility function --- pxr/imaging/plugin/hdEmbree/renderer.cpp | 26 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/pxr/imaging/plugin/hdEmbree/renderer.cpp b/pxr/imaging/plugin/hdEmbree/renderer.cpp index 95663f7639..88d5e79093 100644 --- a/pxr/imaging/plugin/hdEmbree/renderer.cpp +++ b/pxr/imaging/plugin/hdEmbree/renderer.cpp @@ -22,6 +22,24 @@ #include #include +namespace { + +PXR_NAMESPACE_USING_DIRECTIVE + +// ------------------------------------------------------------------------- +// General Ray Utilities +// ------------------------------------------------------------------------- + +inline GfVec3f +_CalculateHitPosition(RTCRayHit const& rayHit) +{ + return GfVec3f(rayHit.ray.org_x + rayHit.ray.tfar * rayHit.ray.dir_x, + rayHit.ray.org_y + rayHit.ray.tfar * rayHit.ray.dir_y, + rayHit.ray.org_z + rayHit.ray.tfar * rayHit.ray.dir_z); +} + +} // anonymous namespace + PXR_NAMESPACE_OPEN_SCOPE HdEmbreeRenderer::HdEmbreeRenderer() @@ -762,9 +780,7 @@ HdEmbreeRenderer::_ComputeDepth(RTCRayHit const& rayHit, } if (clip) { - GfVec3f hitPos = GfVec3f(rayHit.ray.org_x + rayHit.ray.tfar * rayHit.ray.dir_x, - rayHit.ray.org_y + rayHit.ray.tfar * rayHit.ray.dir_y, - rayHit.ray.org_z + rayHit.ray.tfar * rayHit.ray.dir_z); + GfVec3f hitPos = _CalculateHitPosition(rayHit); hitPos = GfVec3f(_viewMatrix.Transform(hitPos)); hitPos = GfVec3f(_projMatrix.Transform(hitPos)); @@ -874,9 +890,7 @@ HdEmbreeRenderer::_ComputeColor(RTCRayHit const& rayHit, rtcGetGeometryUserData(rtcGetGeometry(instanceContext->rootScene,rayHit.hit.geomID))); // Compute the worldspace location of the rayHit hit. - GfVec3f hitPos = GfVec3f(rayHit.ray.org_x + rayHit.ray.tfar * rayHit.ray.dir_x, - rayHit.ray.org_y + rayHit.ray.tfar * rayHit.ray.dir_y, - rayHit.ray.org_z + rayHit.ray.tfar * rayHit.ray.dir_z); + GfVec3f hitPos = _CalculateHitPosition(rayHit); // If a normal primvar is present (e.g. from smooth shading), use that // for shading; otherwise use the flat face normal. From dabdeb59ac6617624e48a9e47e79bbc5749c36e1 Mon Sep 17 00:00:00 2001 From: Paul Molodowitch Date: Tue, 30 Jul 2024 00:32:15 -0700 Subject: [PATCH 2/2] [hdEmbree] minor fixes in hdEmbree/mesh.h - forward-declare some types as struct instead of class (avoids msvc compiler warning) - comment typo fix --- pxr/imaging/plugin/hdEmbree/mesh.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pxr/imaging/plugin/hdEmbree/mesh.h b/pxr/imaging/plugin/hdEmbree/mesh.h index 29b0d55029..bbb006302f 100644 --- a/pxr/imaging/plugin/hdEmbree/mesh.h +++ b/pxr/imaging/plugin/hdEmbree/mesh.h @@ -20,8 +20,8 @@ PXR_NAMESPACE_OPEN_SCOPE -class HdEmbreePrototypeContext; -class HdEmbreeInstanceContext; +struct HdEmbreePrototypeContext; +struct HdEmbreeInstanceContext; /// \class HdEmbreeMesh /// @@ -171,7 +171,7 @@ class HdEmbreeMesh final : public HdMesh { private: // Every HdEmbreeMesh is treated as instanced; if there's no instancer, - // the prototype has a single identity istance. The prototype is stored + // the prototype has a single identity instance. The prototype is stored // as _rtcMeshId, in _rtcMeshScene. unsigned _rtcMeshId; RTCScene _rtcMeshScene;