-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
22 changed files
with
571 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2021 Autodesk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/// @file common_bits.h | ||
/// | ||
/// Common bits for Hydra and Usd Imaging Adapters. | ||
#include "api.h" | ||
#include <pxr/pxr.h> | ||
|
||
#include <pxr/imaging/hd/changeTracker.h> | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
// For now we reserve a single bit for all the parameter changes. | ||
enum ArnoldUsdRprimBits : HdDirtyBits { | ||
ArnoldUsdRprimBitsParams = HdChangeTracker::CustomBitsBegin, | ||
}; | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021 Autodesk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
#include "common_utils.h" | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
std::string MakeCamelCase(const std::string &in) | ||
{ | ||
std::string out; | ||
out.reserve(in.length()); | ||
bool capitalize = false; | ||
unsigned char c; | ||
for (size_t i = 0; i < in.length(); ++i) { | ||
c = in[i]; | ||
if (c == '_') { | ||
capitalize = true; | ||
} else { | ||
if (capitalize) { | ||
c = toupper(c); | ||
capitalize = false; | ||
} | ||
out += c; | ||
} | ||
} | ||
return out; | ||
} | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2021 Autodesk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/// @file common_utils.h | ||
/// | ||
/// Common utils. | ||
#include "api.h" | ||
|
||
#include <string> | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
// convert from "snake_case" to "camelCase" | ||
// ignores the capitalization of input strings: letters are only capitalized | ||
// if they follow an underscore | ||
// | ||
ARNOLDUSD_API | ||
std::string MakeCamelCase(const std::string &in); | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2021 Autodesk, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
#include "native_rprim.h" | ||
|
||
#include "material.h" | ||
|
||
#include <common_bits.h> | ||
#include <constant_strings.h> | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
#if PXR_VERSION >= 2102 | ||
HdArnoldNativeRprim::HdArnoldNativeRprim( | ||
HdArnoldRenderDelegate* renderDelegate, const AtString& arnoldType, const SdfPath& id) | ||
: HdArnoldRprim<HdRprim>(arnoldType, renderDelegate, id), | ||
_paramList(renderDelegate->GetNativeRprimParamList(arnoldType)) | ||
{ | ||
} | ||
#else | ||
HdArnoldNativeRprim::HdArnoldNativeRprim( | ||
HdArnoldRenderDelegate* renderDelegate, const AtString& arnoldType, const SdfPath& id, const SdfPath& instancerId) | ||
: HdArnoldRprim<HdRprim>(arnoldType, renderDelegate, id, instancerId), | ||
_paramList(renderDelegate->GetNativeRprimParamList(arnoldType)) | ||
{ | ||
} | ||
#endif | ||
|
||
void HdArnoldNativeRprim::Sync( | ||
HdSceneDelegate* sceneDelegate, HdRenderParam* renderParam, HdDirtyBits* dirtyBits, const TfToken& reprToken) | ||
{ | ||
TF_UNUSED(reprToken); | ||
HdArnoldRenderParamInterrupt param(renderParam); | ||
const auto& id = GetId(); | ||
|
||
// Sync any built-in parameters. | ||
if (*dirtyBits & ArnoldUsdRprimBitsParams && Ai_likely(_paramList != nullptr)) { | ||
param.Interrupt(); | ||
for (const auto& paramIt : *_paramList) { | ||
const auto val = sceneDelegate->Get(id, paramIt.first); | ||
// Do we need to check for this? | ||
if (!val.IsEmpty()) { | ||
HdArnoldSetParameter(GetArnoldNode(), paramIt.second, val); | ||
} | ||
} | ||
} | ||
|
||
if (HdChangeTracker::IsVisibilityDirty(*dirtyBits, id)) { | ||
param.Interrupt(); | ||
_UpdateVisibility(sceneDelegate, dirtyBits); | ||
SetShapeVisibility(_sharedData.visible ? AI_RAY_ALL : uint8_t{0}); | ||
} | ||
|
||
auto transformDirtied = false; | ||
if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) { | ||
param.Interrupt(); | ||
HdArnoldSetTransform(GetArnoldNode(), sceneDelegate, GetId()); | ||
transformDirtied = true; | ||
} | ||
|
||
if (*dirtyBits & HdChangeTracker::DirtyMaterialId) { | ||
param.Interrupt(); | ||
const auto* material = reinterpret_cast<const HdArnoldMaterial*>( | ||
sceneDelegate->GetRenderIndex().GetSprim(HdPrimTypeTokens->material, sceneDelegate->GetMaterialId(id))); | ||
if (material != nullptr) { | ||
AiNodeSetPtr(GetArnoldNode(), str::shader, material->GetSurfaceShader()); | ||
} else { | ||
// AiNodeSetPtr(GetArnoldNode(), str::shader, GetRenderDelegate()->GetFallbackShader()); | ||
AiNodeResetParameter(GetArnoldNode(), str::shader); | ||
} | ||
} | ||
|
||
SyncShape(*dirtyBits, sceneDelegate, param, transformDirtied); | ||
|
||
*dirtyBits = HdChangeTracker::Clean; | ||
} | ||
|
||
HdDirtyBits HdArnoldNativeRprim::GetInitialDirtyBitsMask() const | ||
{ | ||
return HdChangeTracker::Clean | HdChangeTracker::InitRepr | HdChangeTracker::DirtyTransform | | ||
HdChangeTracker::DirtyMaterialId | HdChangeTracker::DirtyPrimvar | HdChangeTracker::DirtyVisibility | | ||
HdArnoldShape::GetInitialDirtyBitsMask() | ArnoldUsdRprimBitsParams; | ||
} | ||
|
||
const TfTokenVector& HdArnoldNativeRprim::GetBuiltinPrimvarNames() const | ||
{ | ||
const static TfTokenVector r{}; | ||
return r; | ||
} | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
Oops, something went wrong.