File tree Expand file tree Collapse file tree 5 files changed +72
-14
lines changed Expand file tree Collapse file tree 5 files changed +72
-14
lines changed Original file line number Diff line number Diff line change @@ -128,10 +128,22 @@ namespace geode
128128 const Attribute< Type >& attribute ) \
129129 { \
130130 Type result{ 0 }; \
131+ bool is_same{ true }; \
132+ const auto & first_value = \
133+ attribute.value ( interpolator.indices_ [0 ] ); \
131134 for ( auto i : Indices{ interpolator.indices_ } ) \
132135 { \
133- result += interpolator.lambdas_ [i] \
134- * attribute.value ( interpolator.indices_ [i] ); \
136+ const auto & value = \
137+ attribute.value ( interpolator.indices_ [i] ); \
138+ if ( is_same ) \
139+ { \
140+ is_same = value == first_value; \
141+ } \
142+ result += interpolator.lambdas_ [i] * value; \
143+ } \
144+ if ( is_same ) \
145+ { \
146+ return first_value; \
135147 } \
136148 return result; \
137149 } \
@@ -151,16 +163,28 @@ namespace geode
151163 { \
152164 std::array< Type, array_size > result; \
153165 result.fill ( 0 ); \
166+ bool is_same{ true }; \
167+ const auto & first_value = \
168+ attribute.value ( interpolator.indices_ [0 ] ); \
154169 for ( const auto vertex_id : Indices{ interpolator.indices_ } ) \
155170 { \
156171 const auto & array_value = \
157172 attribute.value ( interpolator.indices_ [vertex_id] ); \
158173 for ( const auto position : Indices{ array_value } ) \
159174 { \
175+ if ( is_same ) \
176+ { \
177+ is_same = \
178+ array_value[position] == first_value[position]; \
179+ } \
160180 result[position] += interpolator.lambdas_ [vertex_id] \
161181 * array_value[position]; \
162182 } \
163183 } \
184+ if ( is_same ) \
185+ { \
186+ return first_value; \
187+ } \
164188 return result; \
165189 } \
166190 }
Original file line number Diff line number Diff line change @@ -219,11 +219,22 @@ namespace geode
219219 const Attribute< Point< dimension > > &attribute )
220220 {
221221 Point< dimension > result;
222+ bool is_same{ true };
223+ const auto &first_value =
224+ attribute.value ( interpolator.indices_ [0 ] );
222225 for ( const auto i : Indices{ interpolator.indices_ } )
223226 {
224- result = result
225- + attribute.value ( interpolator.indices_ [i] )
226- * interpolator.lambdas_ [i];
227+ const auto &i_value =
228+ attribute.value ( interpolator.indices_ [i] );
229+ if ( is_same )
230+ {
231+ is_same = i_value == first_value;
232+ }
233+ result = result + i_value * interpolator.lambdas_ [i];
234+ }
235+ if ( is_same )
236+ {
237+ return first_value;
227238 }
228239 return result;
229240 }
Original file line number Diff line number Diff line change @@ -174,11 +174,22 @@ namespace geode
174174 const Attribute< Vector< dimension > > &attribute )
175175 {
176176 Vector< dimension > result;
177+ bool is_same{ true };
178+ const auto &first_value =
179+ attribute.value ( interpolator.indices_ [0 ] );
177180 for ( const auto i : Indices{ interpolator.indices_ } )
178181 {
179- result = result
180- + attribute.value ( interpolator.indices_ [i] )
181- * interpolator.lambdas_ [i];
182+ const auto &i_value =
183+ attribute.value ( interpolator.indices_ [i] );
184+ if ( is_same )
185+ {
186+ is_same = i_value == first_value;
187+ }
188+ result = result + i_value * interpolator.lambdas_ [i];
189+ }
190+ if ( is_same )
191+ {
192+ return first_value;
182193 }
183194 return result;
184195 }
Original file line number Diff line number Diff line change @@ -107,10 +107,22 @@ namespace geode
107107 const Attribute< GreyscaleColor > &attribute )
108108 {
109109 local_index_t result{ 0 };
110+ bool is_same{ true };
111+ const auto &first_value =
112+ attribute.value ( interpolator.indices_ [0 ] ).value ();
110113 for ( const auto i : Indices{ interpolator.indices_ } )
111114 {
112- result += attribute.value ( interpolator.indices_ [i] ).value ()
113- * interpolator.lambdas_ [i];
115+ const auto &i_value =
116+ attribute.value ( interpolator.indices_ [i] ).value ();
117+ if ( is_same )
118+ {
119+ is_same = i_value == first_value;
120+ }
121+ result = result + i_value * interpolator.lambdas_ [i];
122+ }
123+ if ( is_same )
124+ {
125+ return GreyscaleColor{ first_value };
114126 }
115127 return GreyscaleColor{ result };
116128 }
Original file line number Diff line number Diff line change @@ -103,20 +103,20 @@ namespace geode
103103 for ( const auto & direction : directions )
104104 {
105105 const Ray3D ray{ direction, point };
106- geode:: index_t nb_intersections{ 0 };
107- geode:: index_t could_not_determine{ 0 };
106+ index_t nb_intersections{ 0 };
107+ bool could_determine{ true };
108108 for ( const auto & surface : brep.boundaries ( block ) )
109109 {
110110 auto intersections = count_real_intersections_with_boundaries (
111111 ray, surface.mesh () );
112112 if ( !intersections.has_value () )
113113 {
114- could_not_determine++ ;
114+ could_determine = false ;
115115 break ;
116116 }
117117 nb_intersections += intersections.value ();
118118 }
119- if ( could_not_determine == 0 )
119+ if ( could_determine )
120120 {
121121 return ( nb_intersections % 2 == 1 );
122122 }
You can’t perform that action at this time.
0 commit comments