fast_obj icon indicating copy to clipboard operation
fast_obj copied to clipboard

Proposal: move material texture maps into fastObjMesh

Open laurelkeys opened this issue 1 year ago • 5 comments

This PR replaces the fastObjTexture maps in fastObjMaterial with unsigned int indices (which index into a newly added fastObjMesh::textures array).

With this, all texture maps used in an OBJ file are grouped together and directly accessible from a fastObjMesh, making it really straight-forward to load them (i.e. without having to traverse the fastObjMesh::materials array checking all textures maps for each material, and where materials often contain duplicate texture maps between themselves).

It also makes the sizeof(fastObjMaterial) smaller, and concentrates/minimizes string allocations, but a downside is that read_map will now do string comparisons.

laurelkeys avatar Aug 29 '22 14:08 laurelkeys

P.S.: I've bumped the version to 1.3 since this would lead to a breaking change.

laurelkeys avatar Aug 29 '22 14:08 laurelkeys

Thanks! Let me have a think about this - I think it's probably a better way of doing things, but slightly worried by the API change, mostly because I've never written any proper docs, so communicating the change to people is a pain!

thisistherk avatar Aug 30 '22 17:08 thisistherk

I 100% approve of this change!

kodokaii avatar Sep 25 '23 18:09 kodokaii

Woah, sorry, thanks for the prod. Completely forgot to get back to this! I'll try and make some time in the next couple of weeks to get this in - could do with a 1.3 release anyway for recent changes, and I can explain the diffs in the release notes.

thisistherk avatar Sep 25 '23 20:09 thisistherk

Fixed conflicts with https://github.com/thisistherk/fast_obj/pull/45

laurelkeys avatar Dec 30 '23 19:12 laurelkeys

Thank you! Sorry this took so long!

thisistherk avatar Jun 04 '24 19:06 thisistherk