Skip to content

Commit 1c7d640

Browse files
author
kevyuu
committed
Fix logic
1 parent f34bf49 commit 1c7d640

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

include/nbl/asset/IPolygonGeometry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ class IPolygonGeometry : public IIndexableGeometry<BufferType>, public IPolygonG
189189
// SoA instead of AoS, first component is the first bone influece, etc.
190190
struct SJointWeight
191191
{
192+
static const size_t JOINT_COUNT_PER_VERTEX = 4;
193+
192194
// one thing this doesn't check is whether every vertex has a weight and index
193195
inline operator bool() const {return indices && isIntegerFormat(indices.composed.format) && weights && weights.composed.isFormatted() && indices.getElementCount()==weights.getElementCount();}
194196

include/nbl/asset/utils/CPolygonGeometryManipulator.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,21 @@ class NBL_API2 CPolygonGeometryManipulator
6565
{
6666
if (!geo || !geo->getPositionView() || geo->getPositionView().composed.rangeFormat>=IGeometryBase::EAABBFormat::Count)
6767
return {};
68-
// the AABB shall be the same format as the Position View's range Format
68+
6969
if (geo->getIndexView() || geo->isSkinned())
7070
{
7171
auto isVertexSkinned = [](const ICPUPolygonGeometry* geo, uint64_t vertex_i)
7272
{
7373
if (!geo->isSkinned()) return false;
74-
const auto& jointWeightView = geo->getJointWeightViews()[vertex_i];
75-
for (auto weight_i = 0u; weight_i < jointWeightView.weights.getElementCount(); weight_i++)
74+
constexpr auto jointCountPerVertex = ICPUPolygonGeometry::SJointWeight::JOINT_COUNT_PER_VERTEX;
75+
for (auto& weightView : geo->getJointWeightViews())
7676
{
77-
hlsl::vector<hlsl::float32_t, 1> weight;
78-
jointWeightView.weights.decodeElement(vertex_i, weight);
79-
auto hasWeight = false;
80-
if (weight.x != 0.f) hasWeight = true;
81-
if (hasWeight) return true;
77+
for (auto weight_i = 0u; weight_i < jointCountPerVertex; weight_i++)
78+
{
79+
hlsl::vector<hlsl::float32_t, 1> weight;
80+
weightView.weights.decodeElement(jointCountPerVertex * vertex_i + weight_i, weight);
81+
if (weight.x != 0.f) return true;
82+
}
8283
}
8384
return false;
8485
};

0 commit comments

Comments
 (0)