bug fix : ptex coord tables wasn't spliced in FarMultiMeshFactory

This commit is contained in:
Takahito Tejima 2013-05-14 18:10:19 -07:00
parent b16272d6a5
commit b273a19b7c

View File

@ -198,6 +198,16 @@ copyWithOffset(IT dst_iterator, V const &src, int start, int count, int offset)
std::bind2nd(std::plus<typename V::value_type>(), offset));
}
template <typename V, typename IT> static IT
copyWithPtexFaceOffset(IT dst_iterator, V const &src, int start, int count, int offset) {
for (typename V::const_iterator it = src.begin()+start; it != src.begin()+start+count; ++it) {
typename V::value_type ptexCoord = *it;
ptexCoord.faceIndex += offset;
*dst_iterator++ = ptexCoord;
}
return dst_iterator;
}
template <typename V, typename IT> static IT
copyWithOffsetF_ITa(IT dst_iterator, V const &src, int offset) {
for (typename V::const_iterator it = src.begin(); it != src.end();) {
@ -565,6 +575,23 @@ FarMultiMeshFactory<T, U>::splicePatchTables(FarMeshVector const &meshes) {
}
}
// merge ptexCoord table
for (FarPatchTables::Descriptor::iterator it = FarPatchTables::Descriptor::begin(); it != FarPatchTables::Descriptor::end(); ++it) {
int ptexFaceOffset = 0;
for (size_t i = 0; i < meshes.size(); ++i) {
FarPatchTables const *ptables = meshes[i]->GetPatchTables();
FarPatchTables::PatchArray const *parray = ptables->GetPatchArray(*it);
if (not parray) continue;
copyWithPtexFaceOffset(std::back_inserter(result->_ptexTable),
ptables->_ptexTable,
parray->GetPatchIndex(),
parray->GetNumPatches(), ptexFaceOffset);
ptexFaceOffset += meshes[i]->GetNumPtexFaces();
}
}
return result;
}