Skip to content

Commit

Permalink
Renaming geometry time samples to deform keys. (Autodesk#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpalee committed Mar 12, 2021
1 parent e0f7b7c commit 7f54764
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion common/constant_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ASTR2(arnold_filename, "arnold:filename");
ASTR2(arnold_node_entry, "arnold:node_entry");
ASTR2(b_spline, "b-spline");
ASTR2(catmull_rom, "catmull-rom");
ASTR2(geometryTimeSamples, "arnold:geometry_time_samples");
ASTR2(deformKeys, "arnold:deform_keys");
ASTR2(inputs_code, "inputs:code");
ASTR2(primvars_arnold_subdiv_type, "primvars:arnold:subdiv_type");
ASTR2(renderPassAOVDriver, "HdArnoldRenderPass_aov_driver");
Expand Down
6 changes: 3 additions & 3 deletions render_delegate/points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ void HdArnoldPoints::Sync(
if (*dirtyBits & HdChangeTracker::DirtyPrimvar) {
param.Interrupt();
for (const auto& primvar : sceneDelegate->GetPrimvarDescriptors(id, HdInterpolation::HdInterpolationConstant)) {
if (primvar.name == str::geometryTimeSamples) {
if (primvar.name == str::deformKeys) {
const auto value = sceneDelegate->Get(id, primvar.name);
if (value.IsHolding<int>()) {
extrapolatePoints = SetGeometryTimeSamples(value.UncheckedGet<int>());
extrapolatePoints = SetDeformKeys(value.UncheckedGet<int>());
}
} else {
HdArnoldSetConstantPrimvar(GetArnoldNode(), id, sceneDelegate, primvar);
Expand Down Expand Up @@ -114,7 +114,7 @@ void HdArnoldPoints::Sync(
if (extrapolatePoints || HdChangeTracker::IsPrimvarDirty(*dirtyBits, id, HdTokens->points)) {
param.Interrupt();
HdArnoldSetPositionFromPrimvar(
GetArnoldNode(), id, sceneDelegate, str::points, param(), GetGeometryTimeSamples());
GetArnoldNode(), id, sceneDelegate, str::points, param(), GetDeformKeys());
}

SyncShape(*dirtyBits, sceneDelegate, param, transformDirtied);
Expand Down
16 changes: 8 additions & 8 deletions render_delegate/rprim.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,22 @@ class HdArnoldRprim : public HydraType {
TF_UNUSED(dirtyBits);
}

bool SetGeometryTimeSamples(int samples)
bool SetDeformKeys(int keys)
{
const auto s = static_cast<decltype(_geometryTimeSamples)>(std::max(0, samples));
if (_geometryTimeSamples != s) {
_geometryTimeSamples = s;
const auto k = static_cast<decltype(_deformKeys)>(std::max(0, keys));
if (_deformKeys != k) {
_deformKeys = k;
return true;
}
return false;
}

uint8_t GetGeometryTimeSamples() const { return _geometryTimeSamples; }
uint8_t GetDeformKeys() const { return _deformKeys; }

protected:
HdArnoldShape _shape; ///< HdArnoldShape to handle instances and shape creation.
HdArnoldRenderDelegate* _renderDelegate; ///< Pointer to the Arnold Render Delegate.
uint8_t _geometryTimeSamples = HD_ARNOLD_MAX_PRIMVAR_SAMPLES; ///< Number of geometry time samples.
HdArnoldShape _shape; ///< HdArnoldShape to handle instances and shape creation.
HdArnoldRenderDelegate* _renderDelegate; ///< Pointer to the Arnold Render Delegate.
uint8_t _deformKeys = HD_ARNOLD_MAX_PRIMVAR_SAMPLES; ///< Number of deform keys.
};

PXR_NAMESPACE_CLOSE_SCOPE
9 changes: 4 additions & 5 deletions render_delegate/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ inline bool _SetFromValueOrArray(

inline size_t _ExtrapolatePositions(
AtNode* node, const AtString& paramName, HdArnoldSampledType<VtVec3fArray>& xf, const VtVec3fArray& velocities,
const VtVec3fArray& accelerations, const HdArnoldRenderParam* param, int geometryTimeSamples)
const VtVec3fArray& accelerations, const HdArnoldRenderParam* param, int deformKeys)
{
if (Ai_unlikely(param == nullptr) || param->InstananeousShutter() || xf.count != 1) {
return 0;
Expand All @@ -866,7 +866,7 @@ inline size_t _ExtrapolatePositions(
}
const auto& t0 = xf.times[0];
auto shutter = param->GetShutterRange();
const auto numKeys = hasAcceleration ? geometryTimeSamples : std::min(2, geometryTimeSamples);
const auto numKeys = hasAcceleration ? deformKeys : std::min(2, deformKeys);
TfSmallVector<float, HD_ARNOLD_MAX_PRIMVAR_SAMPLES> times;
times.resize(numKeys);
times[0] = shutter[0];
Expand Down Expand Up @@ -1301,7 +1301,7 @@ void HdArnoldSetInstancePrimvar(

size_t HdArnoldSetPositionFromPrimvar(
AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const AtString& paramName,
const HdArnoldRenderParam* param, int geometryTimeSamples)
const HdArnoldRenderParam* param, int deformKeys)
{
HdArnoldSampledPrimvarType sample;
sceneDelegate->SamplePrimvar(id, HdTokens->points, &sample);
Expand Down Expand Up @@ -1329,7 +1329,7 @@ size_t HdArnoldSetPositionFromPrimvar(
}
// Check if we can/should extrapolate positions based on velocities/accelerations.
const auto extrapolatedCount =
_ExtrapolatePositions(node, paramName, xf, velocities, accelerations, param, geometryTimeSamples);
_ExtrapolatePositions(node, paramName, xf, velocities, accelerations, param, deformKeys);
if (extrapolatedCount != 0) {
return extrapolatedCount;
}
Expand Down Expand Up @@ -1382,7 +1382,6 @@ void HdArnoldSetRadiusFromPrimvar(AtNode* node, const SdfPath& id, HdSceneDelega
AiNodeSetArray(node, str::radius, arr);
}


AtArray* HdArnoldGenerateIdxs(unsigned int numIdxs, const VtIntArray* vertexCounts, const size_t* vertexCountSum)
{
if (vertexCountSum != nullptr && numIdxs != *vertexCountSum) {
Expand Down
4 changes: 2 additions & 2 deletions render_delegate/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ void HdArnoldSetInstancePrimvar(
/// @param id Path to the Hydra Primitive.
/// @param sceneDelegate Pointer to the Scene Delegate.
/// @param param Constant pointer to the Arnold Render param struct.
/// @param geometryTimeSamples Number of geometry time sampels to extrapolate when using acceleration.
/// @param deformKeys Number of geometry time sampels to extrapolate when using acceleration.
/// @return Number of keys for the position.
HDARNOLD_API
size_t HdArnoldSetPositionFromPrimvar(
AtNode* node, const SdfPath& id, HdSceneDelegate* sceneDelegate, const AtString& paramName,
const HdArnoldRenderParam* param, int geometryTimeSamples = HD_ARNOLD_MAX_PRIMVAR_SAMPLES);
const HdArnoldRenderParam* param, int deformKeys = HD_ARNOLD_MAX_PRIMVAR_SAMPLES);
/// Sets positions attribute on an Arnold shape from a VtValue holding VtVec3fArray.
///
/// @param node Pointer to an Arnold node.
Expand Down

0 comments on commit 7f54764

Please sign in to comment.