Skip to content

Commit 9b4f730

Browse files
author
kevyuu
committed
Fix bug in vertex welder
1 parent 378108d commit 9b4f730

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

include/nbl/asset/utils/CVertexWelder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class CVertexWelder {
153153
if (!polygon->valid()) return false;
154154

155155
const auto& positionView = polygon->getPositionView();
156-
if (IGeometryBase::getMatchingAABBFormat(positionView.composed.format) == positionView.composed.rangeFormat) return false;
156+
if (IGeometryBase::getMatchingAABBFormat(positionView.composed.format) != positionView.composed.rangeFormat) return false;
157157
m_positionViewContext = {
158158
.channelCount = getFormatChannelCount(positionView.composed.format),
159159
.byteSize = getTexelOrBlockBytesize(positionView.composed.format),
@@ -181,6 +181,8 @@ class CVertexWelder {
181181
m_auxAttributeViewContexts.push_back(getViewContext(auxAttributeView));
182182
}
183183

184+
return true;
185+
184186
}
185187

186188
inline bool operator()(const ICPUPolygonGeometry* polygon, uint32_t index1, uint32_t index2) const override
@@ -213,9 +215,11 @@ class CVertexWelder {
213215
};
214216

215217
template <VertexWelderAccelerationStructure AccelStructureT>
216-
static inline core::smart_refctd_ptr<ICPUPolygonGeometry> weldVertices(const ICPUPolygonGeometry* polygon, const AccelStructureT& as, const WeldPredicate& shouldWeldFn) {
218+
static inline core::smart_refctd_ptr<ICPUPolygonGeometry> weldVertices(const ICPUPolygonGeometry* polygon, const AccelStructureT& as, WeldPredicate& shouldWeldFn) {
217219
auto outPolygon = core::move_and_static_cast<ICPUPolygonGeometry>(polygon->clone(0u));
218220

221+
if (!shouldWeldFn.init(polygon)) return nullptr;
222+
219223
const auto& positionView = polygon->getPositionView();
220224
const auto vertexCount = positionView.getElementCount();
221225

src/nbl/asset/utils/CPolygonGeometryManipulator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ core::smart_refctd_ptr<ICPUPolygonGeometry> CPolygonGeometryManipulator::createS
154154
auto result = CSmoothNormalGenerator::calculateNormals(inPolygon, epsilon, vxcmp);
155155
if (enableWelding)
156156
{
157-
return CVertexWelder::weldVertices(result.geom.get(), result.vertexHashGrid, CVertexWelder::DefaultWeldPredicate(epsilon));
157+
auto weldPredicate = CVertexWelder::DefaultWeldPredicate(epsilon);
158+
return CVertexWelder::weldVertices(result.geom.get(), result.vertexHashGrid, weldPredicate);
158159
}
159160
return result.geom;
160161
}

0 commit comments

Comments
 (0)