added assetrions
MODIFY
include/irr/asset/IMeshManipulator.h
include/irr/asset/IMeshManipulator.h
@@ -87,7 +87,7 @@ namespace asset
virtual asset::ICPUMeshBuffer* createMeshBufferUniquePrimitives(asset::ICPUMeshBuffer* inbuffer) const = 0;
//
- virtual asset::ICPUMeshBuffer* calculateSmoothNormals(asset::ICPUMeshBuffer* inbuffer, float epsilon = 1.525e-5f,
+ virtual asset::ICPUMeshBuffer* calculateSmoothNormals(asset::ICPUMeshBuffer* inbuffer, bool makeNewMesh = false, float epsilon = 1.525e-5f,
asset::E_VERTEX_ATTRIBUTE_ID normalAttrID = asset::E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3,
VxCmpFunction vxcmp = [](const IMeshManipulator::SSNGVertexData& v0, const IMeshManipulator::SSNGVertexData& v1, asset::ICPUMeshBuffer* buffer)
{

MODIFY
src/irr/asset/CMeshManipulator.cpp
src/irr/asset/CMeshManipulator.cpp
@@ -335,13 +335,23 @@ asset::ICPUMeshBuffer* CMeshManipulator::createMeshBufferUniquePrimitives(asset:
}
//
-asset::ICPUMeshBuffer* CMeshManipulator::calculateSmoothNormals(asset::ICPUMeshBuffer* inbuffer, float epsilon,
+asset::ICPUMeshBuffer* CMeshManipulator::calculateSmoothNormals(asset::ICPUMeshBuffer* inbuffer, bool makeNewMesh, float epsilon,
asset::E_VERTEX_ATTRIBUTE_ID normalAttrID, VxCmpFunction vxcmp) const
{
if (inbuffer == nullptr)
+ {
+ _IRR_DEBUG_BREAK_IF(true);
+ return nullptr;
+ }
+
+ //Mesh has to have unique primitives
+ if (inbuffer->getIndexType() != asset::E_INDEX_TYPE::EIT_UNKNOWN)
+ {
+ _IRR_DEBUG_BREAK_IF(true);
return nullptr;
+ }
- asset::ICPUMeshBuffer* outbuffer = createMeshBufferDuplicate(inbuffer);
+ asset::ICPUMeshBuffer* outbuffer = (makeNewMesh == true) ? createMeshBufferDuplicate(inbuffer) : inbuffer;
CSmoothNormalGenerator::calculateNormals(outbuffer, epsilon, normalAttrID, vxcmp);
return outbuffer;

MODIFY
src/irr/asset/CMeshManipulator.h
src/irr/asset/CMeshManipulator.h
@@ -48,7 +48,7 @@ public:
virtual asset::ICPUMeshBuffer* createMeshBufferUniquePrimitives(asset::ICPUMeshBuffer* inbuffer) const;
//
- virtual asset::ICPUMeshBuffer* calculateSmoothNormals(asset::ICPUMeshBuffer* inbuffer, float epsilon,
+ virtual asset::ICPUMeshBuffer* calculateSmoothNormals(asset::ICPUMeshBuffer* inbuffer, bool makeNewMesh, float epsilon,
asset::E_VERTEX_ATTRIBUTE_ID normalAttrID, VxCmpFunction vxcmp) const override;
//! Creates a copy of the mesh, which will have all duplicated vertices removed, i.e. maximal amount of vertices are shared via indexing.

MODIFY
src/irr/asset/CSmoothNormalGenerator.cpp
src/irr/asset/CSmoothNormalGenerator.cpp
@@ -56,7 +56,7 @@ CSmoothNormalGenerator::VertexHashMap::VertexHashMap(size_t _vertexCount, uint32
:hashTableMaxSize(_hashTableMaxSize),
cellSize(_cellSize)
{
- _IRR_DEBUG_BREAK_IF((!core::isPoT(_hashTableMaxSize)));
+ assert((core::isPoT(hashTableMaxSize)));
vertices.reserve(_vertexCount);
buckets.reserve(_hashTableMaxSize+1);
@@ -135,7 +135,6 @@ void CSmoothNormalGenerator::VertexHashMap::validate()
CSmoothNormalGenerator::VertexHashMap CSmoothNormalGenerator::setupData(asset::ICPUMeshBuffer * buffer, float epsilon)
{
const size_t idxCount = buffer->getIndexCount();
-
_IRR_DEBUG_BREAK_IF((idxCount % 3));
VertexHashMap vertices(idxCount, std::min(16u * 1024u, core::roundUpToPoT<unsigned int>(idxCount * 1.0f/32.0f)), epsilon == 0.0f ? 0.00001f : epsilon * 1.00001f);

added assetrions