#include <maya/MPxSubSceneOverride.h>
#include <map>
#include <set>
#include <vector>
#include <memory>
class apiMesh;
class apiMeshGeom;
struct ID3D11Buffer;
namespace apiMeshSubSceneOverrideHelpers {
class LinkLostUserData;
}
typedef std::multimap<int, int> ViewSelectedFaceInfo;
typedef std::map<std::string, ViewSelectedFaceInfo> ViewSelectedFaceInfoMap;
{
public:
static MPxSubSceneOverride* Creator(
const MObject& obj)
{
return new apiMeshSubSceneOverride(obj);
}
~apiMeshSubSceneOverride() override;
) const override;
void untrackLinkLostData(apiMeshSubSceneOverrideHelpers::LinkLostUserData* data);
static MStatus registerComponentConverters();
static MStatus deregisterComponentConverters();
private:
apiMeshSubSceneOverride(
const MObject& obj);
void manageRenderItems(
bool updateGeometry);
void manageIsolateSelectRenderItems(
const ViewSelectedFaceInfo& currInfo,
const bool updateMaterial,
const bool updateGeometry);
void rebuildGeometryBuffers();
void rebuildActiveComponentIndexBuffers();
void deleteBuffers();
void deleteGeometryBuffers();
void deleteActiveComponentIndexBuffers();
static void shadedItemLinkLost(
MUserData* userData);
void updateRenderItemShader(
MRenderItem&,
bool updateMaterial,
bool nonTextured
);
apiMesh* fMesh = nullptr;
struct InstanceInfo
{
bool fIsSelected;
InstanceInfo() : fIsSelected(false) {}
InstanceInfo(
const MMatrix& matrix,
bool selected)
: fTransform(matrix), fIsSelected(selected)
{}
};
typedef std::map<unsigned int, InstanceInfo> InstanceInfoMap;
InstanceInfoMap fInstanceInfoCache;
ViewSelectedFaceInfoMap fViewSelectedFaceInfoCache;
static std::set<std::string> sViewSelectedFaceSelectionNames;
static const MString sSelectedBoxName;
static const MString sTexturedName;
static const MString sVertexSelectionName;
static const MString sEdgeSelectionName;
static const MString sFaceSelectionName;
static const MString sActiveVertexName;
static const MString sActiveEdgeName;
static const MString sActiveFaceName;
std::unique_ptr<MHWRender::MVertexBuffer>
fPositionBuffer,
fNormalBuffer,
fBoxPositionBuffer;
std::unique_ptr<MHWRender::MIndexBuffer>
fWireIndexBuffer,
fBoxIndexBuffer,
fShadedIndexBuffer,
fActiveVerticesIndexBuffer,
fActiveEdgesIndexBuffer,
fActiveFacesIndexBuffer;
unsigned int fBoxPositionBufferId = 0;
unsigned int fBoxIndexBufferId = 0;
ID3D11Buffer* fBoxPositionBufferDX = nullptr;
ID3D11Buffer* fBoxIndexBufferDX = nullptr;
float fThickLineWidth = -1.0f;
unsigned int fNumInstances = 0;
bool fIsInstanceMode = false;
bool fAreUIDrawablesDirty = true;
bool fUseQueuedLineUpdate = false;
float fQueuedLineWidth = -1.0f;
bool fQueueUpdate = false;
std::set<int> fActiveVerticesSet;
std::set<int> fActiveEdgesSet;
std::set<int> fActiveFacesSet;
std::vector<apiMeshSubSceneOverrideHelpers::LinkLostUserData*> fLinkLostUserDatas;
};