1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#ifndef shaveBrushManip_h
#define shaveBrushManip_h
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962
#include <maya/M3dView.h>
#include <maya/MObject.h>
#include <maya/MPxGeometryOverride.h>
#include <maya/MPxManipContainer.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MViewport2Renderer.h>
#if MAYA_API_VERSION < 20180000
class MDagPath;
#endif
class QWidget;
class shaveBrushManip : public MPxManipContainer
{
friend class shaveBrushOverride;
public:
static MString drawDbClassification;
static MString drawRegistrantId;
//test need to invoke geometry override to update
static MObject trigger;
MObject thisObj;
void dirtyDisplay(){MHWRender::MRenderer::setGeometryDrawDirty(thisMObject());}
//void preDrawUI (const M3dView &view)
//{
// MHWRender::MRenderer::setGeometryDrawDirty(thisMObject());
//}
shaveBrushManip();
virtual ~shaveBrushManip();
virtual MStatus connectToDependNode(const MObject& node);
virtual MStatus createChildren();
static void* creator() { return new shaveBrushManip; }
virtual void draw(
M3dView& view,
const MDagPath& path,
M3dView::DisplayStyle dStyle,
M3dView::DisplayStatus dStatus
);
static MStatus initialize();
void getBrushRadii(int& rx, int& ry) const;
void leaveView();
void redrawBrush() { setBrushPos(mCX, mCY, true); }
#if MAYA_API_VERSION >= 201600
virtual SchedulingType schedulingType() const { return kUntrusted; }
#endif
void setActive(bool active);
void setBrushPos(
int cx,
int cy,
bool forceRedraw = false,
bool isMayaDraw = false
);
void setBrushSize(float brushSize);
void setFastBrush(bool fastBrush) { mFastBrush = fastBrush; }
static MTypeId id;
static MString nodeTypeName;
protected:
void calculateRadii();
void drawBrush() const;
static void drawEllipse(int cx, int cy, unsigned rx, unsigned ry);
static void drawMirroredVert(int cx, int cy, int x, int y);
bool eraseBrush(
M3dView& currentView,
bool dontRestoreCurrentView = false
);
bool findOldView(M3dView& view) const;
bool isSameView(M3dView& view) const;
void prepareView(M3dView& view);
void restoreView(M3dView& view);
void saveView(M3dView& view);
static void swapGLBuffers(M3dView& view);
float mBrushSize;
bool mClearOld;
int mCX;
int mCY;
bool mFastBrush;
bool mIsActive;
MObject mProxy;
unsigned mRX;
unsigned mRY;
int mViewHeight;
int mViewWidth;
MNativeWindowHdl mWindow;
QWidget* aWidget;
#ifdef OSMac_
GLint mViewPosX;
GLint mViewPosY;
#endif
};
class shaveBrushOverride : public MHWRender::MPxGeometryOverride {
public:
static MPxGeometryOverride* Creator(const MObject& obj)
{
return new shaveBrushOverride(obj);
}
virtual ~shaveBrushOverride();
virtual MHWRender::DrawAPI supportedDrawAPIs() const;
virtual void updateDG();
virtual void updateRenderItems(
const MDagPath& path,
MHWRender::MRenderItemList& list);
virtual void populateGeometry(
const MHWRender::MGeometryRequirements& requirements,
const MHWRender::MRenderItemList& renderItems,
MHWRender::MGeometry& data
);
virtual void cleanUp();
protected:
shaveBrushOverride(const MObject& obj);
shaveBrushManip* brush;
};
#endif
|