Skip to content

Commit

Permalink
hdGatling: fix compilation against latest USD dev
Browse files Browse the repository at this point in the history
There's still a problem with MSVC and the pxrctor section. See ASWF slack.
  • Loading branch information
pablode committed Sep 21, 2024
1 parent 8a2cae5 commit 221e876
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/hdGatling/light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ PXR_NAMESPACE_OPEN_SCOPE

namespace
{
float _AreaEllipsoid(const GfMatrix4d& t, float radiusX, float radiusY, float radiusZ)
float _AreaEllipsoid(float radiusX, float radiusY, float radiusZ)
{
float ab = powf(radiusX * radiusY, 1.6f);
float ac = powf(radiusX * radiusZ, 1.6f);
Expand Down Expand Up @@ -111,7 +111,7 @@ void HdGatlingSphereLight::Sync(HdSceneDelegate* sceneDelegate,
{
const SdfPath& id = GetId();

const GfMatrix4d& transform = sceneDelegate->GetTransform(id);
const GfMatrix4f transform(sceneDelegate->GetTransform(id));

if (*dirtyBits & DirtyBits::DirtyTransform)
{
Expand All @@ -129,7 +129,7 @@ void HdGatlingSphereLight::Sync(HdSceneDelegate* sceneDelegate,

VtValue boxedNormalize = sceneDelegate->GetLightParamValue(id, HdLightTokens->normalize);
bool normalize = boxedNormalize.GetWithDefault<bool>(false);
float area = _AreaEllipsoid(transform, radiusX, radiusY, radiusZ);
float area = _AreaEllipsoid(radiusX, radiusY, radiusZ);
float normalizeFactor = (normalize && area > 0.0f) ? area : 1.0f;
GfVec3f baseEmission = _CalcBaseEmission(sceneDelegate, normalizeFactor);

Expand Down Expand Up @@ -168,8 +168,8 @@ void HdGatlingDistantLight::Sync(HdSceneDelegate* sceneDelegate,

if (*dirtyBits & DirtyBits::DirtyTransform)
{
const GfMatrix4d& transform = sceneDelegate->GetTransform(id);
GfMatrix4d normalMatrix = transform.GetInverse().GetTranspose();
const GfMatrix4f transform(sceneDelegate->GetTransform(id));
GfMatrix4f normalMatrix(transform.GetInverse().GetTranspose());

GfVec3f dir = normalMatrix.TransformDir(GfVec3f(0.0f, 0.0f, -1.0f));
dir.Normalize();
Expand Down Expand Up @@ -221,7 +221,7 @@ void HdGatlingRectLight::Sync(HdSceneDelegate* sceneDelegate,
{
const SdfPath& id = GetId();

const GfMatrix4d& transform = sceneDelegate->GetTransform(id);
const GfMatrix4f transform(sceneDelegate->GetTransform(id));

if (*dirtyBits & DirtyBits::DirtyTransform)
{
Expand Down Expand Up @@ -284,7 +284,7 @@ void HdGatlingDiskLight::Sync(HdSceneDelegate* sceneDelegate,
{
const SdfPath& id = GetId();

const GfMatrix4d& transform = sceneDelegate->GetTransform(id);
const GfMatrix4f transform(sceneDelegate->GetTransform(id));

if (*dirtyBits & DirtyBits::DirtyTransform)
{
Expand Down
14 changes: 12 additions & 2 deletions src/hdGatling/materialNetworkCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ void _PatchMaterialXColor3Vector3Mismatches(HdMaterialNetwork2& network)
{
SdrShaderPropertyConstPtr sdrInput = sdrNode->GetShaderInput(input.first);

SdfValueTypeName inputType = sdrInput->GetTypeAsSdfType().first;
auto ndrSdfType = sdrInput->GetTypeAsSdfType();
#if PXR_VERSION > 2408
SdfValueTypeName inputType = ndrSdfType.GetSdfType();
#else
SdfValueTypeName inputType = ndrSdfType.first;
#endif
if (inputType == SdfValueTypeNames->Token)
{
continue;
Expand Down Expand Up @@ -173,7 +178,12 @@ void _PatchMaterialXColor3Vector3Mismatches(HdMaterialNetwork2& network)
continue;
}

SdfValueTypeName upstreamOutputType = upstreamSdrOutput->GetTypeAsSdfType().first;
auto upstreamNdrSdfType = upstreamSdrOutput->GetTypeAsSdfType();
#if PXR_VERSION > 2408
SdfValueTypeName upstreamOutputType = upstreamNdrSdfType.GetSdfType();
#else
SdfValueTypeName upstreamOutputType = upstreamNdrSdfType.first;
#endif
if (upstreamOutputType == SdfValueTypeNames->Token)
{
continue;
Expand Down
9 changes: 5 additions & 4 deletions src/hdGatling/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "mesh.h"

#include <pxr/base/gf/matrix4f.h>
#include <pxr/imaging/hd/meshUtil.h>
#include <pxr/imaging/hd/vertexAdjacency.h>
#include <pxr/imaging/hd/smoothNormals.h>
Expand Down Expand Up @@ -62,7 +63,7 @@ namespace
_VertexAttr<float> bitangentSigns;
};

GiVertex _MakeGiVertex(GfMatrix4d transform, GfMatrix4d normalMatrix, const GfVec3f& point, const GfVec3f& normal,
GiVertex _MakeGiVertex(const GfMatrix4f& transform, const GfMatrix4f& normalMatrix, const GfVec3f& point, const GfVec3f& normal,
const GfVec2f& texCoords, const GfVec3f& tangent, float bitangentSign)
{
GfVec3f newPoint = transform.Transform(point);
Expand Down Expand Up @@ -293,11 +294,11 @@ namespace
}

void _BakeMeshGeometry(_VertexStreams& s,
const GfMatrix4d& transform,
const GfMatrix4f& transform,
std::vector<GiFace>& faces,
std::vector<GiVertex>& vertices)
{
GfMatrix4d normalMatrix = transform.GetInverse().GetTranspose();
GfMatrix4f normalMatrix(transform.GetInverse().GetTranspose());

bool hasTexCoords = s.texCoords.array.size() > 0;
bool calcTangents = s.tangents.array.empty();
Expand Down Expand Up @@ -786,7 +787,7 @@ void HdGatlingMesh::_CreateGiMesh(HdSceneDelegate* sceneDelegate)

std::vector<GiFace> faces;
std::vector<GiVertex> vertices;
_BakeMeshGeometry(s, GfMatrix4d(1.0), faces, vertices);
_BakeMeshGeometry(s, GfMatrix4f(1.0f), faces, vertices);

TfToken orientation = topology.GetOrientation();
bool isLeftHanded = (orientation == _tokens->leftHanded);
Expand Down

0 comments on commit 221e876

Please sign in to comment.