@@ -136,86 +136,6 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CPolygonGeometryManipulator::createU
136136 return outGeometry;
137137}
138138
139-
140- namespace
141- {
142- bool isAttributeValEqual (const ICPUPolygonGeometry::SDataView& view, uint64_t index1, uint64_t index2, float epsilon)
143- {
144- if (!view) return true ;
145- const auto channelCount = getFormatChannelCount (view.composed .format );
146- switch (view.composed .rangeFormat )
147- {
148- case IGeometryBase::EAABBFormat::U64:
149- case IGeometryBase::EAABBFormat::U32:
150- {
151- hlsl::uint64_t4 val1, val2;
152- view.decodeElement <hlsl::uint64_t4>(index1, val1);
153- view.decodeElement <hlsl::uint64_t4>(index2, val2);
154- for (auto channel_i = 0u ; channel_i < channelCount; channel_i++)
155- if (val1[channel_i] != val2[channel_i]) return false ;
156- break ;
157- }
158- case IGeometryBase::EAABBFormat::S64:
159- case IGeometryBase::EAABBFormat::S32:
160- {
161- hlsl::int64_t4 val1, val2;
162- view.decodeElement <hlsl::int64_t4>(index1, val1);
163- view.decodeElement <hlsl::int64_t4>(index2, val2);
164- for (auto channel_i = 0u ; channel_i < channelCount; channel_i++)
165- if (val1[channel_i] != val2[channel_i]) return false ;
166- break ;
167- }
168- default :
169- {
170- hlsl::float64_t4 val1, val2;
171- view.decodeElement <hlsl::float64_t4>(index1, val1);
172- view.decodeElement <hlsl::float64_t4>(index2, val2);
173- for (auto channel_i = 0u ; channel_i < channelCount; channel_i++)
174- {
175- const auto diff = abs (val1[channel_i] - val2[channel_i]);
176- if (diff > epsilon) return false ;
177- }
178- break ;
179- }
180- }
181- return true ;
182- }
183-
184- bool isAttributeDirEqual (const ICPUPolygonGeometry::SDataView& view, uint64_t index1, uint64_t index2, float epsilon)
185- {
186- if (!view) return true ;
187- const auto channelCount = getFormatChannelCount (view.composed .format );
188- switch (view.composed .rangeFormat )
189- {
190- case IGeometryBase::EAABBFormat::U64:
191- case IGeometryBase::EAABBFormat::U32:
192- {
193- hlsl::uint64_t4 val1, val2;
194- view.decodeElement <hlsl::uint64_t4>(index1, val1);
195- view.decodeElement <hlsl::uint64_t4>(index2, val2);
196- return (1.0 - hlsl::dot (val1, val2)) < epsilon;
197- }
198- case IGeometryBase::EAABBFormat::S64:
199- case IGeometryBase::EAABBFormat::S32:
200- {
201- hlsl::int64_t4 val1, val2;
202- view.decodeElement <hlsl::int64_t4>(index1, val1);
203- view.decodeElement <hlsl::int64_t4>(index2, val2);
204- return (1.0 - hlsl::dot (val1, val2)) < epsilon;
205- }
206- default :
207- {
208- hlsl::float64_t4 val1, val2;
209- view.decodeElement <hlsl::float64_t4>(index1, val1);
210- view.decodeElement <hlsl::float64_t4>(index2, val2);
211- return (1.0 - hlsl::dot (val1, val2)) < epsilon;
212- }
213- }
214- return true ;
215- }
216- }
217-
218-
219139core::smart_refctd_ptr<ICPUPolygonGeometry> CPolygonGeometryManipulator::createSmoothVertexNormal (const ICPUPolygonGeometry* inPolygon, bool enableWelding, float epsilon, VxCmpFunction vxcmp)
220140{
221141 if (!inPolygon)
@@ -231,27 +151,10 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CPolygonGeometryManipulator::createS
231151 return nullptr ;
232152 }
233153
234- auto canJoinVertices = [epsilon](const ICPUPolygonGeometry* polygon, uint32_t index1, uint32_t index2)-> bool
235- {
236- if (!isAttributeValEqual (polygon->getPositionView (), index1, index2, epsilon))
237- return false ;
238- if (!isAttributeDirEqual (polygon->getNormalView (), index1, index2, epsilon))
239- return false ;
240- for (const auto & jointWeightView : polygon->getJointWeightViews ())
241- {
242- if (!isAttributeValEqual (jointWeightView.indices , index1, index2, epsilon)) return false ;
243- if (!isAttributeValEqual (jointWeightView.weights , index1, index2, epsilon)) return false ;
244- }
245- for (const auto & auxAttributeView : polygon->getAuxAttributeViews ())
246- if (!isAttributeValEqual (auxAttributeView, index1, index2, epsilon)) return false ;
247-
248- return true ;
249- };
250-
251154 auto result = CSmoothNormalGenerator::calculateNormals (inPolygon, epsilon, vxcmp);
252155 if (enableWelding)
253156 {
254- return CVertexWelder::weldVertices (result.geom .get (), result.vertexHashGrid , canJoinVertices );
157+ return CVertexWelder::weldVertices (result.geom .get (), result.vertexHashGrid , CVertexWelder::DefaultWeldPredicate (epsilon) );
255158 }
256159 return result.geom ;
257160}
0 commit comments