27 #include "../version.h"
29 #include "../sdc/type.h"
30 #include "../sdc/options.h"
31 #include "../sdc/crease.h"
37 namespace OpenSubdiv {
38 namespace OPENSUBDIV_VERSION {
96 template <Type SCHEME_TYPE>
115 template <
typename FACE,
typename MASK>
133 template <
typename EDGE,
typename MASK>
147 template <
typename VERTEX,
typename MASK>
160 template <
typename VERTEX,
typename MASK>
163 template <
typename VERTEX,
typename MASK>
166 MASK& tangent2Mask)
const;
174 template <
typename EDGE,
typename MASK>
177 template <
typename EDGE,
typename MASK>
181 template <
typename VERTEX,
typename MASK>
184 template <
typename VERTEX,
typename MASK>
187 template <
typename VERTEX,
typename MASK>
197 template <
typename WEIGHT>
233 template <
typename USER_MASK>
245 dst.VertexWeight(0) = dstCoeff * dst.VertexWeight(0) + thisCoeff * this->
VertexWeight(0);
248 if (edgeWeightCount) {
249 if (dst.GetNumEdgeWeights() == 0) {
250 dst.SetNumEdgeWeights(edgeWeightCount);
251 for (
int i = 0; i < edgeWeightCount; ++i) {
252 dst.EdgeWeight(i) = thisCoeff * this->
EdgeWeight(i);
255 for (
int i = 0; i < edgeWeightCount; ++i) {
256 dst.EdgeWeight(i) = dstCoeff * dst.EdgeWeight(i) + thisCoeff * this->
EdgeWeight(i);
262 if (faceWeightCount) {
263 if (dst.GetNumFaceWeights() == 0) {
264 dst.SetNumFaceWeights(faceWeightCount);
265 for (
int i = 0; i < faceWeightCount; ++i) {
266 dst.FaceWeight(i) = thisCoeff * this->
FaceWeight(i);
269 for (
int i = 0; i < faceWeightCount; ++i) {
270 dst.FaceWeight(i) = dstCoeff * dst.FaceWeight(i) + thisCoeff * this->
FaceWeight(i);
294 template <Sdc::Type SCHEME>
295 template <
typename EDGE,
typename MASK>
299 mask.SetNumVertexWeights(2);
300 mask.SetNumEdgeWeights(0);
301 mask.SetNumFaceWeights(0);
303 mask.VertexWeight(0) = 0.5f;
304 mask.VertexWeight(1) = 0.5f;
307 template <Sdc::Type SCHEME>
308 template <
typename VERTEX,
typename MASK>
312 mask.SetNumVertexWeights(1);
313 mask.SetNumEdgeWeights(0);
314 mask.SetNumFaceWeights(0);
316 mask.VertexWeight(0) = 1.0f;
323 template <Sdc::Type SCHEME>
324 template <
typename FACE,
typename MASK>
328 int vertCount = face.GetNumVertices();
330 mask.SetNumVertexWeights(vertCount);
331 mask.SetNumEdgeWeights(0);
332 mask.SetNumFaceWeights(0);
334 typename MASK::Weight vWeight = 1.0f / (
typename MASK::Weight) vertCount;
335 for (
int i = 0; i < vertCount; ++i) {
336 mask.VertexWeight(i) = vWeight;
366 template <Sdc::Type SCHEME>
367 template <
typename EDGE,
typename MASK>
381 assignSmoothMaskForEdge(edge, mask);
385 assignCreaseMaskForEdge(edge, mask);
403 bool childIsCrease =
false;
406 childIsCrease =
true;
407 }
else if (edge.GetSharpness() >= 1.0f) {
409 childIsCrease =
true;
412 childIsCrease =
false;
415 float cEdgeSharpness[2];
416 edge.GetChildSharpnesses(crease, cEdgeSharpness);
417 childIsCrease = (cEdgeSharpness[0] > 0.0f) && (cEdgeSharpness[1] > 0.0f);
420 assignCreaseMaskForEdge(edge, mask);
434 assignSmoothMaskForEdge(edge, mask);
436 typedef typename MASK::Weight Weight;
438 Weight pWeight = edge.GetSharpness();
439 Weight cWeight = 1.0f - pWeight;
441 mask.VertexWeight(0) = pWeight * 0.5f + cWeight * mask.VertexWeight(0);
442 mask.VertexWeight(1) = pWeight * 0.5f + cWeight * mask.VertexWeight(1);
444 int faceCount = mask.GetNumFaceWeights();
445 for (
int i = 0; i < faceCount; ++i) {
446 mask.FaceWeight(i) *= cWeight;
486 template <Type SCHEME>
487 template <
typename VERTEX,
typename MASK>
496 assignSmoothMaskForVertex(vertex, mask);
503 int valence = vertex.GetNumEdges();
509 float * pEdgeSharpnessBuffer = (
float *)alloca(valence*
sizeof(
float)),
510 * pEdgeSharpness = 0,
511 pVertexSharpness = 0.0f;
516 if (requireParentSharpness) {
517 pVertexSharpness = vertex.GetSharpness();
518 pEdgeSharpness = vertex.GetSharpnessPerEdge(pEdgeSharpnessBuffer);
526 assignSmoothMaskForVertex(vertex, mask);
529 assignCreaseMaskForVertex(vertex, mask, pEdgeSharpness);
531 assignCornerMaskForVertex(vertex, mask);
533 if (cRule == pRule)
return;
540 float * cEdgeSharpnessBuffer = (
float *)alloca(valence*
sizeof(
float)),
541 * cEdgeSharpness = vertex.GetChildSharpnessPerEdge(crease, cEdgeSharpnessBuffer),
542 cVertexSharpness = vertex.GetChildSharpness(crease);
546 if (cRule == pRule)
return;
553 typedef typename MASK::Weight Weight;
555 Weight * cMaskWeights = (Weight *)alloca((1 + 2 * valence)*
sizeof(Weight));
556 LocalMask<Weight> cMask(cMaskWeights, cMaskWeights + 1, cMaskWeights + 1 + valence);
559 assignSmoothMaskForVertex(vertex, cMask);
561 assignCreaseMaskForVertex(vertex, cMask, cEdgeSharpness);
563 assignCornerMaskForVertex(vertex, cMask);
567 valence, pEdgeSharpness, cEdgeSharpness);
568 Weight cWeight = 1.0f - pWeight;
576 using namespace OPENSUBDIV_VERSION;
Weight & VertexWeight(int index)
void ComputeVertexVertexMask(VERTEX const &vertexNeighborhood, MASK &vertexVertexMask, Crease::Rule parentRule=Crease::RULE_UNKNOWN, Crease::Rule childRule=Crease::RULE_UNKNOWN) const
void assignSmoothMaskForVertex(VERTEX const &edge, MASK &mask) const
void ComputeEdgeVertexMask(EDGE const &edgeNeighborhood, MASK &edgeVertexMask, Crease::Rule parentRule=Crease::RULE_UNKNOWN, Crease::Rule childRule=Crease::RULE_UNKNOWN) const
void ComputeVertexLimitMask(VERTEX const &vertexNeighborhood, MASK &positionMask) const
void assignSmoothMaskForEdge(EDGE const &edge, MASK &mask) const
void ComputeFaceVertexMask(FACE const &faceNeighborhood, MASK &faceVertexMask) const
int GetNumVertexWeights() const
void assignCornerMaskForVertex(VERTEX const &edge, MASK &mask) const
void SetNumEdgeWeights(int count)
int GetNumFaceWeights() const
void assignCreaseMaskForVertex(VERTEX const &edge, MASK &mask, float const sharpness[]) const
Weight const & FaceWeight(int index) const
LocalMask(Weight *v, Weight *e, Weight *f)
Rule DetermineVertexVertexRule(float vertexSharpness, int incidentEdgeCount, float const *incidentEdgeSharpness) const
float ComputeFractionalWeightAtVertex(float vertexSharpness, float childVertexSharpness, int incidentEdgeCount, float const *incidentEdgeSharpness, float const *childEdgesSharpness) const
void CombineVertexVertexMasks(Weight thisCoeff, Weight dstCoeff, USER_MASK &dst) const
Weight const & VertexWeight(int index) const
int GetNumEdgeWeights() const
Weight & FaceWeight(int index)
Scheme(Options const &options)
Weight & EdgeWeight(int index)
void SetOptions(const Options &newOptions)
void SetNumFaceWeights(int count)
Weight const & EdgeWeight(int index) const
Options GetOptions() const
void assignCreaseMaskForEdge(EDGE const &edge, MASK &mask) const
void SetNumVertexWeights(int count)