Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hdEmbree] minor fixes / tweaks (hdEmbree-UsdLux-PR03) #3185

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pxr/imaging/plugin/hdEmbree/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

PXR_NAMESPACE_OPEN_SCOPE

class HdEmbreePrototypeContext;
class HdEmbreeInstanceContext;
struct HdEmbreePrototypeContext;
struct HdEmbreeInstanceContext;

/// \class HdEmbreeMesh
///
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 20 additions & 6 deletions pxr/imaging/plugin/hdEmbree/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
#include <chrono>
#include <thread>

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()
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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.
Expand Down