Page MenuHome

OBJ: more robust .mtl texture offset/scale parsing (T89421)
ClosedPublic

Authored by Aras Pranckevicius (aras_p) on Jul 6 2022, 11:55 AM.

Details

Summary

As pointed out in a comment on T89421, if a MTL file contained something like: map_Ka -o 1 2.png then it was parsed as having offset 1 2 and the texture filename just a .png. Make it so that mtl option numbers are parsed in a way where the number is only accepted only if it's followed by whitespace.

Extend unit test coverage, which also needs to apply this diff to the subversion tests repository:

--- io_tests/obj/materials.mtl	(revision 62967)
+++ io_tests/obj/materials.mtl	(working copy)
@@ -57,7 +57,7 @@
 newmtl Parser_ScaleOffset_Test
 map_Kd -o 2.5 OffsetOneValue.png
 map_Ks -s 1.5 2.5 -o 3.5 4.5 ScaleOffsetBothTwovalues.png
-map_Ns -s 0.5 ScaleOneValue.png
+map_Ns -s 0.5 1.Value.png
 
 # these mtl options are not supported yet
 map_Ka -s 1.5 2.5 3.5 -o 4.5 5.5 6.5 -mm 0.1 0.2 sometex_a.jpg

Diff Detail

Repository
rB Blender

Event Timeline

Aras Pranckevicius (aras_p) requested review of this revision.Jul 6 2022, 11:55 AM
Aras Pranckevicius (aras_p) created this revision.

Not sure if you meant to put me as a reviewer. I'm not a Blender dev or anything. (FWIW, it does look fine to me though.)

This revision was not accepted when it landed; it landed in state Needs Review.Jul 7 2022, 10:35 AM
This revision was automatically updated to reflect the committed changes.