#ifndef _gpuCacheShapeNode_h_
#define _gpuCacheShapeNode_h_
#include <gpuCacheGeometry.h>
#include <gpuCacheMaterial.h>
#include <CacheReader.h>
#include <maya/MPxSurfaceShape.h>
#include <maya/MPxSurfaceShapeUI.h>
#include <maya/MMessage.h>
#include <maya/MPxGeometryData.h>
#include <boost/shared_ptr.hpp>
#include <gpuCacheSpatialSubdivision.h>
#include <vector>
namespace{
using namespace GPUCache;
class BufferCache{
public:
BufferCache(double seconds){fBufferReadTime = seconds; fUseCachedBuffers = false; fTotalNumTris=0; fTotalNumVerts=0; fNumShapes=0;}
~BufferCache(){
}
std::vector<MMatrix> fXFormMatrix;
std::vector<MMatrix> fXFormMatrixInverse;
std::vector<IndexBuffer::ReadInterfacePtr> fTriangleVertIndices;
std::vector<IndexBuffer::ReadInterfacePtr> fEdgeVertIndices;
std::vector<VertexBuffer::ReadInterfacePtr> fPositions;
std::vector<size_t> fNumTriangles;
std::vector<size_t> fNumEdges;
std::vector<MBoundingBox> fBoundingBoxes;
unsigned int fNumShapes;
unsigned int fTotalNumTris;
unsigned int fTotalNumVerts;
bool fUseCachedBuffers;
double fBufferReadTime;
};
}
namespace GPUCache {
{
public:
static void* creator();
static MStatus init3dViewPostRenderCallbacks();
static const MString drawDbClassificationGeometry;
static const MString drawDbClassificationSubScene;
static const MString drawRegistrantId;
static const char* nodeTypeName;
static const char* selectionMaskName;
enum BackgroundReadingState {
kReadingHierarchyInProgress,
kReadingShapesInProgress,
kReadingDone
};
ShapeNode();
~ShapeNode();
virtual void postConstructor();
virtual bool isBounded() const;
virtual bool getInternalValueInContext(
const MPlug& plug,
virtual bool setInternalValueInContext(
const MPlug& plug,
virtual void copyInternalData(
MPxNode* source);
virtual MStringArray getFilesToArchive(
bool shortName =
false,
bool unresolvedName = false,
bool markCouldBeImageSequence = false ) const;
virtual bool excludeAsPluginShape() const;
void refreshCachedGeometry();
const GPUCache::SubNode::Ptr& getCachedGeometry() const;
const GPUCache::MaterialGraphMap::Ptr& getCachedMaterial() const;
const BackgroundReadingState backgroundReadingState() const;
void removedFromModelCB();
bool canMakeLive() const;
bool readBuffers(const SubNode::Ptr subNode, double seconds)const;
void closestPoint(
const MPoint &toThisPoint,
MPoint &theClosestPoint,
double tolerance = 0.1);
bool closestPoint(
const MPoint &raySource,
const MVector &rayDirection,
MPoint &theClosestPoint,
MVector &theClosestNormal,
bool findClosestOnMiss,
double tolerance=MPoint_kTol);
unsigned int getIntersectionAccelerator(const gpuCacheIsectAccelParams& accelParams, double seconds) const;
private:
ShapeNode(const ShapeNode& obj);
const ShapeNode& operator=(const ShapeNode& obj);
bool setInternalValues(
const MString& newFileName,
bool getEdgeSnapPoint(
const MPoint &rayPoint,
const MVector &rayDirection,
MPoint &theClosestPoint);
mutable BufferCache* fBufferCache;
mutable std::vector<gpuCacheSpatialSubdivision *> fSpatialSub;
mutable GPUCache::SubNode::Ptr fCachedGeometry;
mutable GPUCache::MaterialGraphMap::Ptr fCachedMaterial;
mutable GlobalReaderCache::CacheReaderProxy::Ptr fCacheReaderProxy;
mutable BackgroundReadingState fBackgroundReadingState;
MCallbackId fRemoveFromModelCallbackId;
static MCallbackId fsModelEditorChangedCallbackId;
};
class DisplayPref
{
public:
enum WireframeOnShadedMode {
kWireframeOnShadedFull,
kWireframeOnShadedReduced,
kWireframeOnShadedNone
};
static WireframeOnShadedMode wireframeOnShadedMode();
private:
static void displayPrefChanged(void*);
static WireframeOnShadedMode fsWireframeOnShadedMode;
static MCallbackId fsDisplayPrefChangedCallbackId;
};
{
public:
static void* creator();
ShapeUI();
~ShapeUI();
virtual void getDrawRequests(
const MDrawInfo & info,
bool objectAndActiveOnly,
private:
ShapeUI(const ShapeUI& obj);
const ShapeUI& operator=(const ShapeUI& obj);
enum DrawToken {
kBoundingBox,
kDrawWireframe,
kDrawWireframeOnShaded,
kDrawSmoothShaded,
kDrawSmoothShadedDepthOffset
};
};
}
#endif