-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from Autodesk/chenh/wireframe-bbox-reprs-and-…
…proxy-transformation-visibility * Optimized VP2RenderDelegate repr update. * Added wireframe display for USD mesh. * Added bbox display for USD mesh (BBox will be hidden for Rprims without authored extent). * Added proxy shape transformation and visibility support.
- Loading branch information
Showing
13 changed files
with
1,354 additions
and
663 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// Copyright 2019 Autodesk | ||
// | ||
// 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 "bboxGeom.h" | ||
|
||
#include "pxr/base/arch/threads.h" | ||
#include "pxr/base/tf/diagnostic.h" | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
//! Constructor. Call from main thread only. | ||
HdVP2BBoxGeom::HdVP2BBoxGeom() | ||
: _range(GfVec3d(-0.5, -0.5, -0.5), GfVec3d(0.5, 0.5, 0.5)) | ||
{ | ||
// MVertexBuffer::commit() & MIndexBuffer::commit() can work only when being | ||
// called from main thread. | ||
TF_VERIFY(ArchIsMainThread(), "Creating HdVP2BBoxGeom from worker threads"); | ||
|
||
const MHWRender::MVertexBufferDescriptor vbDesc( | ||
"", MGeometry::kPosition, MGeometry::kFloat, 3); | ||
|
||
_positionBuffer.reset(new MHWRender::MVertexBuffer(vbDesc)); | ||
|
||
if (void* buffer = _positionBuffer->acquire(8, true)) { | ||
constexpr float vertexData[] = { | ||
-0.5f, -0.5f, -0.5f, // vtx 0 | ||
-0.5f, -0.5f, 0.5f, // vtx 1 | ||
-0.5f, 0.5f, -0.5f, // vtx 2 | ||
-0.5f, 0.5f, 0.5f, // vtx 3 | ||
0.5f, -0.5f, -0.5f, // vtx 4 | ||
0.5f, -0.5f, 0.5f, // vtx 5 | ||
0.5f, 0.5f, -0.5f, // vtx 6 | ||
0.5f, 0.5f, 0.5f // vtx 7 | ||
}; | ||
|
||
memcpy(buffer, vertexData, sizeof(vertexData)); | ||
|
||
_positionBuffer->commit(buffer); | ||
} | ||
|
||
_indexBuffer.reset(new MHWRender::MIndexBuffer(MGeometry::kUnsignedInt32)); | ||
|
||
if (void* buffer = _indexBuffer->acquire(24, true)) { | ||
constexpr unsigned int indexData[] = { | ||
0, 4, // edge 0 | ||
1, 5, // edge 1 | ||
2, 6, // edge 2 | ||
3, 7, // edge 3 | ||
0, 2, // edge 4 | ||
1, 3, // edge 5 | ||
4, 6, // edge 6 | ||
5, 7, // edge 7 | ||
0, 1, // edge 8 | ||
2, 3, // edge 9 | ||
4, 5, // edge 10 | ||
6, 7 // edge 11 | ||
}; | ||
|
||
memcpy(buffer, indexData, sizeof(indexData)); | ||
|
||
_indexBuffer->commit(buffer); | ||
} | ||
} | ||
|
||
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,60 @@ | ||
// | ||
// Copyright 2019 Autodesk | ||
// | ||
// 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. | ||
// | ||
|
||
#ifndef HD_VP2_BBOX_GEOM | ||
#define HD_VP2_BBOX_GEOM | ||
|
||
#include "maya/MHWGeometry.h" | ||
|
||
#include "pxr/pxr.h" | ||
#include "pxr/base/gf/range3d.h" | ||
|
||
#include <memory> | ||
|
||
PXR_NAMESPACE_OPEN_SCOPE | ||
|
||
/*! \brief Geometry used for bounding box display in VP2. | ||
\class HdVP2BBoxGeom | ||
The class defines a unit wire cube centered at origin. It can be used to | ||
provide shared geometry for all Rprims to display bounding box in VP2. | ||
The class can only be instantiated from main thread. | ||
*/ | ||
class HdVP2BBoxGeom final | ||
{ | ||
public: | ||
HdVP2BBoxGeom(); | ||
~HdVP2BBoxGeom() = default; | ||
|
||
const MHWRender::MVertexBuffer* GetPositionBuffer() const { | ||
return _positionBuffer.get(); | ||
} | ||
|
||
const MHWRender::MIndexBuffer* GetIndexBuffer() const { | ||
return _indexBuffer.get(); | ||
} | ||
|
||
const GfRange3d& GetRange() const { return _range; } | ||
|
||
private: | ||
std::unique_ptr<MVertexBuffer> _positionBuffer; //!< Position buffer of the geometry | ||
std::unique_ptr<MIndexBuffer> _indexBuffer; //!< Index buffer of the geometry | ||
GfRange3d _range; //!< Range of the geometry | ||
}; | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE | ||
|
||
#endif // HD_VP2_BBOX_GEOM |
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
Oops, something went wrong.