Skip to content

Commit 00fbb69

Browse files
MeshAlgo::triangulate : Don't make unused copy of input primvars
1 parent 91b9ae5 commit 00fbb69

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/IECoreScene/MeshAlgoTriangulate.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,24 @@ void triangulateMeshIndices(
142142
}
143143
}
144144

145+
DataPtr newMatchingData( const Data *source )
146+
{
147+
return dispatch( source,
148+
[]( const auto *typedSource ) -> DataPtr
149+
{
150+
using DataType = typename std::remove_const_t< std::remove_pointer_t< decltype( typedSource ) > >;
151+
typename DataType::Ptr result = new DataType();
152+
153+
if constexpr( TypeTraits::IsGeometricTypedData< DataType >::value )
154+
{
155+
result->setInterpretation( typedSource->getInterpretation() );
156+
}
157+
158+
return result;
159+
}
160+
);
161+
}
162+
145163

146164
/// A functor for use with despatchTypedData, which copies elements from another vector, as specified by an array of indices into that data
147165
struct TriangleDataRemap
@@ -243,7 +261,7 @@ struct TriangulateFn
243261
}
244262

245263
const Data *inputData = it->second.indices ? it->second.indices.get() : it->second.data.get();
246-
DataPtr result = inputData->copy();
264+
DataPtr result = newMatchingData( inputData );
247265
remap->m_other = inputData;
248266

249267
// \todo - using this to reindex data is a waste of time and memory. If there are no indices,

0 commit comments

Comments
 (0)