All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
bilinearScheme.h
Go to the documentation of this file.
1 //
2 // Copyright 2014 DreamWorks Animation LLC.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef OPENSUBDIV3_SDC_BILINEAR_SCHEME_H
25 #define OPENSUBDIV3_SDC_BILINEAR_SCHEME_H
26 
27 #include "../version.h"
28 
29 #include "../sdc/scheme.h"
30 
31 namespace OpenSubdiv {
32 namespace OPENSUBDIV_VERSION {
33 
34 namespace Sdc {
35 
36 //
37 // Specializations for Scheme<SCHEME_BILINEAR>:
38 //
39 
40 //
41 // Bilinear traits:
42 //
43 template <>
45 
46 template <>
48 
49 template <>
51 
52 template <>
54 
55 
56 //
57 // Refinement masks:
58 //
59 template <>
60 template <typename EDGE, typename MASK>
61 void
63  Crease::Rule, Crease::Rule) const {
64  // This should be inline, otherwise trivially replicate it:
65  assignCreaseMaskForEdge(edge, mask);
66 }
67 
68 template <>
69 template <typename VERTEX, typename MASK>
70 void
71 Scheme<SCHEME_BILINEAR>::ComputeVertexVertexMask(VERTEX const& vertex, MASK& mask,
72  Crease::Rule, Crease::Rule) const {
73  // This should be inline, otherwise trivially replicate it:
74  assignCornerMaskForVertex(vertex, mask);
75 }
76 
77 
78 //
79 // Limit masks for position -- the limit position of all vertices is the refined vertex.
80 //
81 template <>
82 template <typename VERTEX, typename MASK>
83 inline void
84 Scheme<SCHEME_BILINEAR>::assignCornerLimitMask(VERTEX const& /* vertex */, MASK& posMask) const {
85 
86  posMask.SetNumVertexWeights(1);
87  posMask.SetNumEdgeWeights(0);
88  posMask.SetNumFaceWeights(0);
89  posMask.SetFaceWeightsForFaceCenters(false);
90 
91  posMask.VertexWeight(0) = 1.0f;
92 }
93 
94 template <>
95 template <typename VERTEX, typename MASK>
96 inline void
97 Scheme<SCHEME_BILINEAR>::assignCreaseLimitMask(VERTEX const& vertex, MASK& posMask,
98  int const /* creaseEnds */[2]) const {
99 
100  assignCornerLimitMask(vertex, posMask);
101 }
102 
103 template <>
104 template <typename VERTEX, typename MASK>
105 inline void
106 Scheme<SCHEME_BILINEAR>::assignSmoothLimitMask(VERTEX const& vertex, MASK& posMask) const {
107 
108  assignCornerLimitMask(vertex, posMask);
109 }
110 
111 //
112 // Limit masks for tangents -- these are ambiguous around all vertices. Provide
113 // the tangents based on the incident edges of the first face.
114 //
115 template <>
116 template <typename VERTEX, typename MASK>
117 inline void
119  MASK& tan1Mask, MASK& tan2Mask) const {
120 
121  tan1Mask.SetNumVertexWeights(1);
122  tan1Mask.SetNumEdgeWeights(2);
123  tan1Mask.SetNumFaceWeights(0);
124  tan1Mask.SetFaceWeightsForFaceCenters(false);
125 
126  tan2Mask.SetNumVertexWeights(1);
127  tan2Mask.SetNumEdgeWeights(2);
128  tan2Mask.SetNumFaceWeights(0);
129  tan2Mask.SetFaceWeightsForFaceCenters(false);
130 
131  tan1Mask.VertexWeight(0) = -1.0f;
132  tan1Mask.EdgeWeight(0) = 1.0f;
133  tan1Mask.EdgeWeight(1) = 0.0f;
134 
135  tan2Mask.VertexWeight(0) = -1.0f;
136  tan2Mask.EdgeWeight(0) = 0.0f;
137  tan2Mask.EdgeWeight(1) = 1.0f;
138 }
139 
140 template <>
141 template <typename VERTEX, typename MASK>
142 inline void
144  MASK& tan1Mask, MASK& tan2Mask, int const /* creaseEnds */[2]) const {
145 
146  assignCornerLimitTangentMasks(vertex, tan1Mask, tan2Mask);
147 }
148 
149 template <>
150 template <typename VERTEX, typename MASK>
151 inline void
153  MASK& tan1Mask, MASK& tan2Mask) const {
154 
155  assignCornerLimitTangentMasks(vertex, tan1Mask, tan2Mask);
156 }
157 
158 } // end namespace sdc
159 
160 } // end namespace OPENSUBDIV_VERSION
161 using namespace OPENSUBDIV_VERSION;
162 } // end namespace OpenSubdiv
163 
164 #endif /* OPENSUBDIV3_SDC_BILINEAR_SCHEME_H */
void assignCreaseLimitMask(VERTEX const &vertex, MASK &pos, int const creaseEnds[2]) const
void ComputeEdgeVertexMask(EDGE const &edgeNeighborhood, MASK &edgeVertexMask, Crease::Rule parentRule=Crease::RULE_UNKNOWN, Crease::Rule childRule=Crease::RULE_UNKNOWN) const
Edge-vertex masks If known, the Rule for the edge and/or the derived vertex can be specified to accel...
Definition: scheme.h:392
Split
Enumerated type for all face splitting schemes.
Definition: types.h:47
void assignSmoothLimitMask(VERTEX const &vertex, MASK &pos) const
void assignCornerLimitMask(VERTEX const &vertex, MASK &pos) const
void assignCornerLimitTangentMasks(VERTEX const &vertex, MASK &tan1, MASK &tan2) const
void assignSmoothLimitTangentMasks(VERTEX const &vertex, MASK &tan1, MASK &tan2) const
Used by Catmark and Bilinear.
Definition: types.h:48
void ComputeVertexVertexMask(VERTEX const &vertexNeighborhood, MASK &vertexVertexMask, Crease::Rule parentRule=Crease::RULE_UNKNOWN, Crease::Rule childRule=Crease::RULE_UNKNOWN) const
Vertex-vertex masks If known, a single Rule or pair of Rules can be specified (indicating a crease tr...
Definition: scheme.h:512
void assignCreaseLimitTangentMasks(VERTEX const &vertex, MASK &tan1, MASK &tan2, int const creaseEnds[2]) const