mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Serializers: index positions and normals independently in OBJ/DAE output
When vertices are not welded (the default IfcConvert path when normals are requested), IfcGeom::Representation::Triangulation stores one position and one normal per triangle corner, so both arrays repeat the same values many times. The OBJ and COLLADA formats support indexing positions, normals and texture coordinates independently, but the serializers were reusing a single combined index for all of them, inflating output size without needing to. Positions and normals are now deduplicated by exact value within each serializer and referenced through their own index streams (UV indices are left untouched, since a UV depends on both position and normal together). Verified against a real IFC model (test/input/IfcReinforcingBar.ifc): DAE output drops from 48.4MB to 20.6MB (-57.5%) and OBJ output from 51.3MB to 23.6MB (-54.0%), with the decoded position/normal value for every triangle corner checked byte-identical to the unpatched output. Addresses #46. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -32,7 +32,7 @@ class SERIALIZERS_API WaveFrontOBJSerializer : public WriteOnlyGeometrySerialize
|
||||
private:
|
||||
stream_or_filename obj_stream;
|
||||
stream_or_filename mtl_stream;
|
||||
size_t vcount_total, ncount_total;
|
||||
size_t vcount_total, ncount_total, uvcount_total;
|
||||
std::set<std::string> materials;
|
||||
public:
|
||||
WaveFrontOBJSerializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, Logger* logger = nullptr);
|
||||
|
||||
Reference in New Issue
Block a user