vai_list& vas
)
{
- const int indexSize = sizeof(T) * std::bitset<32>(indexMask).count();
- const int vaSize = sizeof(T) * std::bitset<32>(vaMask).count();
+ const int indexSize = sizeof(T) * std::bitset<32>((int)indexMask).count();
+ const int vaSize = sizeof(T) * std::bitset<32>((int)vaMask).count();
const int count = bytes / (indexSize + vaSize);
// fix endian-ness of the whole lot, if required
if (vaMask & SG_VA_FLOAT_3) vas[7].push_back(*src++);
}
} // of elements in the index
+
+ // WS2.0 fix : toss zero area triangles
+ if ( ( count == 3 ) && (indexMask & SG_IDX_VERTICES) ) {
+ if ( (vertices[0] == vertices[1]) ||
+ (vertices[1] == vertices[2]) ||
+ (vertices[2] == vertices[0]) ) {
+ vertices.clear();
+ }
+ }
}
template <class T>
const vai_list& vas )
{
unsigned int count = vertices.size();
- const int indexSize = sizeof(T) * std::bitset<32>(indexMask).count();
- const int vaSize = sizeof(T) * std::bitset<32>(vaMask).count();
+ const int indexSize = sizeof(T) * std::bitset<32>((int)indexMask).count();
+ const int vaSize = sizeof(T) * std::bitset<32>((int)vaMask).count();
sgWriteUInt(fp, (indexSize + vaSize) * count);
for (unsigned int i=0; i < count; ++i) {
throw sg_exception("Error reading object properties");
}
- size_t indexCount = std::bitset<32>(idx_mask).count();
+ size_t indexCount = std::bitset<32>((int)idx_mask).count();
if (indexCount == 0) {
throw sg_exception("object index mask has no bits set");
}
read_indices<uint16_t>(ptr, nbytes, idx_mask, vertex_attrib_mask, vs, ns, cs, tcs, vas );
}
- vertices.push_back( vs );
- normals.push_back( ns );
- colors.push_back( cs );
- texCoords.push_back( tcs );
- vertexAttribs.push_back( vas );
- materials.push_back( material );
+ // Fix for WS2.0 - ignore zero area triangles
+ if ( !vs.empty() ) {
+ vertices.push_back( vs );
+ normals.push_back( ns );
+ colors.push_back( cs );
+ texCoords.push_back( tcs );
+ vertexAttribs.push_back( vas );
+ materials.push_back( material );
+ }
} // of element iteration
}