-
Notifications
You must be signed in to change notification settings - Fork 4
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
HYDRA-30 : support faces picking in Hydra viewport #139
Changes from 5 commits
8a28384
108f8cb
f8472ea
a39367a
5147fac
d16fb80
3698207
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,7 +142,7 @@ void MayaHydraRenderItemAdapter::UpdateFromDelta(const UpdateFromDeltaData& data | |
// const bool isNew = flags & MViewportScene::MVS_new; //not used yet | ||
const bool visible = data._flags & MVS::MVS_visible; | ||
const bool matrixChanged = data._flags & MVS::MVS_changedMatrix; | ||
const bool geomChanged = (data._flags & MVS::MVS_changedGeometry) || positionsHaveBeenReset; | ||
bool geomChanged = (data._flags & MVS::MVS_changedGeometry) || positionsHaveBeenReset;//Non const as we may modify it later | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If MAYA-134200 gets fixed, should this be const again? If so I'd probably mention the issue number here as well so we don't forget it |
||
const bool topoChanged = (data._flags & MVS::MVS_changedTopo) || positionsHaveBeenReset; | ||
const bool visibChanged = data._flags & MVS::MVS_changedVisibility; | ||
const bool effectChanged = data._flags & MVS::MVS_changedEffect; | ||
|
@@ -192,6 +192,34 @@ void MayaHydraRenderItemAdapter::UpdateFromDelta(const UpdateFromDeltaData& data | |
static const bool passNormalsToHydra = MayaHydraSceneIndex::passNormalsToHydra(); | ||
|
||
const int vertexBuffercount = geom ? geom->vertexBufferCount() : 0; | ||
|
||
//Temp workaround for a bug in Maya MAYA-134200 | ||
if ((!geomChanged && topoChanged) && vertexBuffercount) { | ||
//With face components selection, we have topoChanged which is true but geomChanged is false, but this is wrong, the number of vertices may have changed. | ||
//We want to check here if we also need to update the geometry if the number of vertices is different from what is stored already | ||
for (int vbIdx = 0; vbIdx < vertexBuffercount; vbIdx++) { | ||
MVertexBuffer* mvb = geom->vertexBuffer(vbIdx); | ||
if (!mvb) { | ||
continue; | ||
} | ||
|
||
const MVertexBufferDescriptor& desc = mvb->descriptor(); | ||
const auto semantic = desc.semantic(); | ||
switch (semantic) { | ||
case MGeometry::Semantic::kPosition: { | ||
// Vertices | ||
MVertexBuffer* verts = mvb; | ||
const unsigned int originalVertexCount = verts->vertexCount(); | ||
Comment on lines
+211
to
+212
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Super nitpicky, but is there a reason we create a separate variable to point to the same object? As this could just be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure what you mean ? We use the vertexCount in 2 places only in this function and keeping a variable for it wouldn't be useful IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's more that the |
||
if (_positions.size() != originalVertexCount) {//Is it different ? | ||
geomChanged = true; | ||
vbIdx = vertexBuffercount; //Stop looping | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional/Thinking out loud : personally I would have instead gone with adding a check in the for loop's condition that checks for geomChanged not being true, i.e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, I changed it the way you said. |
||
} | ||
} break; | ||
default: break; | ||
} | ||
} | ||
} | ||
|
||
// Vertices | ||
if (geomChanged && vertexBuffercount) { | ||
//vertexBuffercount > 0 means geom is non null | ||
|
@@ -356,21 +384,25 @@ void MayaHydraRenderItemAdapter::UpdateFromDelta(const UpdateFromDeltaData& data | |
switch (GetPrimitive()) { | ||
case MGeometry::Primitive::kTriangles:{ | ||
static const bool passNormalsToHydra = MayaHydraSceneIndex::passNormalsToHydra(); | ||
if (passNormalsToHydra){ | ||
_topology.reset(new HdMeshTopology( | ||
PxOsdOpenSubdivTokens->none,//For the OGS normals vertex buffer to be used, we need to use PxOsdOpenSubdivTokens->none | ||
UsdGeomTokens->rightHanded, | ||
vertexCounts, | ||
vertexIndices)); | ||
} else{ | ||
_topology.reset(new HdMeshTopology( | ||
(GetMayaHydraSceneIndex()->GetParams().displaySmoothMeshes | ||
|| GetDisplayStyle().refineLevel > 0) | ||
? PxOsdOpenSubdivTokens->catmullClark | ||
: PxOsdOpenSubdivTokens->none, | ||
UsdGeomTokens->rightHanded, | ||
vertexCounts, | ||
vertexIndices)); | ||
if (vertexCounts.size()) { | ||
if (passNormalsToHydra) { | ||
_topology.reset(new HdMeshTopology( | ||
PxOsdOpenSubdivTokens | ||
->none, // For the OGS normals vertex buffer to be used, we need to use | ||
// PxOsdOpenSubdivTokens->none | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor autoformat nitpick, but breaking up the -> statement from its deref'd pointer feels a bit weird to me, I'd probably have the comment as a line above so autoformat doesn't split it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
UsdGeomTokens->rightHanded, | ||
vertexCounts, | ||
vertexIndices)); | ||
} else { | ||
_topology.reset(new HdMeshTopology( | ||
(GetMayaHydraSceneIndex()->GetParams().displaySmoothMeshes | ||
|| GetDisplayStyle().refineLevel > 0) | ||
? PxOsdOpenSubdivTokens->catmullClark | ||
: PxOsdOpenSubdivTokens->none, | ||
UsdGeomTokens->rightHanded, | ||
vertexCounts, | ||
vertexIndices)); | ||
} | ||
} | ||
} | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
//Local headers | ||
#include "mhWireframeColorInterfaceImp.h" | ||
#include "mixedUtils.h" | ||
|
||
//Flow viewport headers | ||
#include <flowViewport/colorPreferences/fvpColorPreferences.h> | ||
|
@@ -29,14 +30,6 @@ | |
|
||
PXR_NAMESPACE_USING_DIRECTIVE | ||
|
||
// An implementation for maya of the WireframeColorInterface to get the wireframe color from a prim for selection highlighting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has been moved to mixedUtils.h to make this common to multiple cpp files |
||
namespace { | ||
PXR_NS::GfVec4f getPreferencesColor(const PXR_NS::TfToken& token) { | ||
PXR_NS::GfVec4f color; | ||
Fvp::ColorPreferences::getInstance().getColor(token, color); | ||
return color; | ||
} | ||
} | ||
namespace MAYAHYDRA_NS_DEF { | ||
|
||
MhWireframeColorInterfaceImp::MhWireframeColorInterfaceImp(const std::shared_ptr<Fvp::Selection>& selection | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ target_sources(${TARGET_NAME} | |
mayaHydraCameraDataSource.cpp | ||
mayaHydraLightDataSource.cpp | ||
mayaHydraDefaultLightDataSource.cpp | ||
mayaHydraDefaultMaterialDataSource.cpp | ||
mayaHydraMaterialDataSource.cpp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mayaHydraDefaultMaterialDataSource has been converted to a generic mayaHydraMaterialDataSource class since nothing special in it was for the default material. |
||
mayaHydraMayaDataProducerSceneIndexData.cpp | ||
mayaHydraMayaDataProducerSceneIndexDataConcreteFactory.cpp | ||
mayaHydraSceneIndexDataFactoriesSetup.cpp | ||
|
@@ -31,7 +31,7 @@ set(HEADERS | |
mayaHydraLightDataSource.h | ||
mayaHydraSceneIndexUtils.h | ||
mayaHydraDefaultLightDataSource.h | ||
mayaHydraDefaultMaterialDataSource.h | ||
mayaHydraMaterialDataSource.h | ||
mayaHydraMayaDataProducerSceneIndexData.h | ||
mayaHydraMayaDataProducerSceneIndexDataConcreteFactory.h | ||
mayaHydraSceneIndexDataFactoriesSetup.h | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a bug fix for a warning at maya startup