24 #ifndef SDC_CATMARK_SCHEME_H
25 #define SDC_CATMARK_SCHEME_H
27 #include "../version.h"
29 #include "../sdc/scheme.h"
33 namespace OpenSubdiv {
34 namespace OPENSUBDIV_VERSION {
52 template <
typename EDGE,
typename MASK>
56 typedef typename MASK::Weight Weight;
58 int faceCount = edge.GetNumFaces();
60 mask.SetNumVertexWeights(2);
61 mask.SetNumEdgeWeights(0);
62 mask.SetNumFaceWeights(faceCount);
70 bool face0IsTri =
false;
71 bool face1IsTri =
false;
73 if (useTriangleOption) {
78 useTriangleOption = face0IsTri || face1IsTri;
80 useTriangleOption =
false;
84 if (!useTriangleOption) {
85 mask.VertexWeight(0) = 0.25f;
86 mask.VertexWeight(1) = 0.25f;
89 mask.FaceWeight(0) = 0.25f;
90 mask.FaceWeight(1) = 0.25f;
92 Weight fWeight = 0.5f / (Weight)faceCount;
93 for (
int i = 0; i < faceCount; ++i) {
94 mask.FaceWeight(i) = fWeight;
102 const Weight CATMARK_SMOOTH_TRI_EDGE_WEIGHT = 0.470f;
104 Weight f0Weight = face0IsTri ? CATMARK_SMOOTH_TRI_EDGE_WEIGHT : 0.25f;
105 Weight f1Weight = face1IsTri ? CATMARK_SMOOTH_TRI_EDGE_WEIGHT : 0.25f;
107 Weight fWeight = 0.5f * (f0Weight + f1Weight);
108 Weight vWeight = 0.5f * (1.0f - 2.0f * fWeight);
110 mask.VertexWeight(0) = vWeight;
111 mask.VertexWeight(1) = vWeight;
113 mask.FaceWeight(0) = fWeight;
114 mask.FaceWeight(1) = fWeight;
124 template <
typename VERTEX,
typename MASK>
128 typedef typename MASK::Weight Weight;
130 int valence = vertex.GetNumEdges();
132 mask.SetNumVertexWeights(1);
133 mask.SetNumEdgeWeights(valence);
134 mask.SetNumFaceWeights(0);
136 Weight vWeight = 0.75f;
137 Weight eWeight = 0.125f;
139 mask.VertexWeight(0) = vWeight;
146 if (edgeSharpness != 0) {
148 for (
int i = 0; i < valence; ++i) {
149 mask.EdgeWeight(i) = (edgeSharpness[i] > 0.0f) ? eWeight : 0.0f;
153 mask.EdgeWeight(0) = eWeight;
154 for (
int i = 1; i < (valence - 1); ++i) {
155 mask.EdgeWeight(i) = 0.0f;
157 mask.EdgeWeight(valence-1) = eWeight;
162 template <
typename VERTEX,
typename MASK>
166 typedef typename MASK::Weight Weight;
181 int valence = vertex.GetNumFaces();
183 mask.SetNumVertexWeights(1);
184 mask.SetNumEdgeWeights(valence);
185 mask.SetNumFaceWeights(valence);
187 Weight vWeight = (Weight)(valence - 2) / (Weight)valence;
188 Weight fWeight = 1.0f / (Weight)(valence * valence);
189 Weight eWeight = fWeight;
191 mask.VertexWeight(0) = vWeight;
192 for (
int i = 0; i < valence; ++i) {
193 mask.EdgeWeight(i) = eWeight;
194 mask.FaceWeight(i) = fWeight;
201 using namespace OPENSUBDIV_VERSION;
void assignSmoothMaskForVertex(VERTEX const &edge, MASK &mask) const
void assignSmoothMaskForEdge(EDGE const &edge, MASK &mask) const
void assignCreaseMaskForVertex(VERTEX const &edge, MASK &mask, float const sharpness[]) const