@@ -115,7 +115,7 @@ class IMeshPacker : public IMeshPackerBase
115
115
protected:
116
116
virtual ~IMeshPacker () {}
117
117
118
- inline size_t calcVertexSize (const SVertexInputParams& vtxInputParams, const E_VERTEX_INPUT_RATE inputRate) const
118
+ static inline size_t calcVertexSize (const SVertexInputParams& vtxInputParams, const E_VERTEX_INPUT_RATE inputRate)
119
119
{
120
120
size_t size = 0ull ;
121
121
for (size_t i = 0 ; i < SVertexInputParams::MAX_VERTEX_ATTRIB_COUNT; ++i)
@@ -128,12 +128,15 @@ class IMeshPacker : public IMeshPackerBase
128
128
return size;
129
129
}
130
130
131
- inline constexpr uint32_t calcVertexCountBoundWithBatchDuplication (uint32_t triCnt )
131
+ static inline uint32_t calcVertexCountBoundWithBatchDuplication (const MeshBufferType* meshBuffer )
132
132
{
133
- return triCnt*3u ;
133
+ uint32_t triCnt;
134
+ if (IMeshManipulator::getPolyCount (triCnt,meshBuffer))
135
+ return triCnt*3u ;
136
+ return 0u ;
134
137
}
135
138
136
- inline constexpr uint32_t calcBatchCountBound (uint32_t triCnt)
139
+ inline uint32_t calcBatchCountBound (uint32_t triCnt) const
137
140
{
138
141
if (triCnt!=0u )
139
142
return (triCnt-1u )/m_minTriangleCountPerMDIData+1u ;
@@ -150,10 +153,10 @@ class IMeshPacker : public IMeshPackerBase
150
153
core::vector<Triangle> triangles;
151
154
};
152
155
153
- core::vector<TriangleBatch> constructTriangleBatches (MeshBufferType* meshBuffer)
156
+ core::vector<TriangleBatch> constructTriangleBatches (const MeshBufferType* meshBuffer) const
154
157
{
155
158
uint32_t triCnt;
156
- const bool success = IMeshManipulator::getPolyCount (meshBuffer);
159
+ const bool success = IMeshManipulator::getPolyCount (triCnt, meshBuffer);
157
160
assert (success);
158
161
159
162
const uint32_t batchCount = calcBatchCountBound (triCnt);
@@ -191,9 +194,10 @@ class IMeshPacker : public IMeshPackerBase
191
194
{
192
195
if (i == (batchCount - 1 ))
193
196
{
194
- if (triCnt % m_maxTriangleCountPerMDIData)
197
+ const auto lastBatchLen = triCnt % uint32_t (m_maxTriangleCountPerMDIData);
198
+ if (lastBatchLen)
195
199
{
196
- output[i].triangles = core::vector<Triangle>(triCnt % m_maxTriangleCountPerMDIData );
200
+ output[i].triangles = core::vector<Triangle>(lastBatchLen );
197
201
continue ;
198
202
}
199
203
}
@@ -231,7 +235,7 @@ class IMeshPacker : public IMeshPackerBase
231
235
return output;
232
236
}
233
237
234
- core::unordered_map<uint32_t , uint16_t > constructNewIndicesFromTriangleBatch (TriangleBatch& batch, uint16_t *& indexBuffPtr)
238
+ static core::unordered_map<uint32_t , uint16_t > constructNewIndicesFromTriangleBatch (TriangleBatch& batch, uint16_t *& indexBuffPtr)
235
239
{
236
240
core::unordered_map<uint32_t , uint16_t > usedVertices;
237
241
core::vector<Triangle> newIdxTris = batch.triangles ;
@@ -264,7 +268,7 @@ class IMeshPacker : public IMeshPackerBase
264
268
return usedVertices;
265
269
}
266
270
267
- void deinterleaveAndCopyAttribute (MeshBufferType* meshBuffer, uint16_t attrLocation, const core::unordered_map<uint32_t , uint16_t >& usedVertices, uint8_t * dstAttrPtr)
271
+ static void deinterleaveAndCopyAttribute (MeshBufferType* meshBuffer, uint16_t attrLocation, const core::unordered_map<uint32_t , uint16_t >& usedVertices, uint8_t * dstAttrPtr)
268
272
{
269
273
uint8_t * srcAttrPtr = meshBuffer->getAttribPointer (attrLocation);
270
274
SVertexInputParams& mbVtxInputParams = meshBuffer->getPipeline ()->getVertexInputParams ();
0 commit comments