Bug in exporter for assets >= 100000 vertices

Discussions about MHX2 and other plugins that are developed outside the scope of MakeHuman. Note that bug reports should go to the respective code projects and might go unseen here.

Moderator: joepal

Bug in exporter for assets >= 100000 vertices

Postby punkduck » Tue May 01, 2018 10:06 pm

Hi

Normally I would add this to the bugtracker, but it is mhx2, so I choose this way ...

After creating the wonderful hairdo made by o4saken with makeclothes I was able to load it into MakeHuman. I also was able to export it in mhx2 format. But I was not able to load it into Blender. This will happen:

error.png


I just figured out that the system stopped while creating vertex-groups. The internal part of the mhx2-file looks like this (shortened):

Code: Select all
 {
            "license" : {
            },
            "name" : "Evi:O4saken_curly01",
            "uuid" : "1e389f96-1cc8-46df-a523-8f6d856d79b7",
            "offset" : [0,8.1831,0],
            "scale" : 1,
            "issubdivided" : false,
            "material" : "Evi:O4saken_curly01:04saken_curly01",
            "mesh" : {
                "vertices" : ...
                "faces" : ...
                "uv_coordinates" : ...
                "uv_faces" : ...
                "weights" : {
                    "spine03" : ...
                    ...
                    "levator05.R" : [[68864,0.0031742],[68865,0.014959], ... ,

>>>!!!!
                    [1.195e+05,0.00048838],[1.1956e+05,0.00015145],[1.1958e+05,0.00066446],[1.1958e+05,0.0039],[1.1958e+05,0.0018054],[1.2022e+05,0.018331],
                    [1.2022e+05,0.025266],[1.2022e+05,0.018534],[1.2022e+05,0.017707],[1.203e+05,0.00039211],[1.2053e+05,0.0011459],[1.206e+05,0.007656],[1.2060e+05,0.0082733],[1.2114e+05,0.0041977]]
>>>!!!!

                }
            },
            "seed_mesh" : {
                "vertices" : ...
                    "levator05.R" :

>>>!!!!
same problem
>>>!!!!

                }
            },
            "human" : false,
            "proxy" : {
                "license" : {
                    "author" : "04saken",
                    "license" : "CC BY 4.0",
                    "homepage" : "http://www.makehuman.org/"
                },
                "name" : "O4saken_curly01",
                "type" : "Hair",
                "uuid" : "ba9ec978-a9b3-4859-a8a7-1729c2dcf2dc",
                "basemesh" : "hm08",
                "tags" : ["curly","female"],
                "fitting" :
                "delete_verts" :
                "vertex_bone_weights" : null
            }
        },



Vertex number bigger than 100000 will be presented in float style. The reason is the json-printer. I created a work around:

In 9_export_mhx2/save_json.py

Line 59 and 105

change
return "%.5g" % data
to
return "%.6g" % data

Of course it now only works for numbers lower than 1 million. I guess the first value should be an integer in this context but was saved as "something else" (numpy?).
Nevertheless Blender expects integers and %.5g will make the numbers 100000 - 100009 to 1e5. I hope you can fix the error with my "findings". I'm still not good enough to do that myself :(
User avatar
punkduck
 
Posts: 1216
Joined: Mon Oct 17, 2016 7:24 pm
Location: Nuremberg, Germany

Re: Bug in exporter for assets >= 100000 vertices

Postby wolgade » Wed May 02, 2018 5:47 pm

RobBaer still might be in contact with Thomas. At least some of his fixes got merged by Thomas two weeks ago. I'd try to contact Rob about this issue to have it fixed upstream.
wolgade
 
Posts: 795
Joined: Wed Jan 30, 2013 6:50 pm

Re: Bug in exporter for assets >= 100000 vertices

Postby Aranuvir » Wed May 02, 2018 10:28 pm

Getting the fix upstream is one thing. But what makes me wonder is the fact, that the function is intended to handle float data, at the the point where the fix takes place, but on blender's side integer data is expected. I am not against your provided bug fix, though it seems more like a workaround to a deeper problem in the interaction of the exporter and importer. @Punkduck do you think you could dig deeper into this problem?
Aranuvir
 
Posts: 1314
Joined: Sun Oct 12, 2014 2:12 pm

Re: Bug in exporter for assets >= 100000 vertices

Postby punkduck » Thu May 03, 2018 5:22 pm

Aranuvir wrote:Getting the fix upstream is one thing. But what makes me wonder is the fact, that the function is intended to handle float data, at the the point where the fix takes place, but on blender's side integer data is expected. I am not against your provided bug fix, though it seems more like a workaround to a deeper problem in the interaction of the exporter and importer. @Punkduck do you think you could dig deeper into this problem?


My idea with the internals of numpy seems to be not that wrong. But I'm no expert yet ;)

In line 406 of mh2mhx2.py

mhWeights[<bonename>] = np.array(assoc)

is created. "assoc" is an two dimensional array of vertex number and weight. If you put these into np.array, the function uses float for both parameters because of weight. Unfortunately I'm not yet able to fix this using numpy. Even though np.array has an optional parameter called "dtype". But this can be only used for all values without restructuring the array.

There is a method to have different input types, but then the array is created as a dictionary.

When you simply write:
mhWeights[<bonename>] = assoc

then the form of the output is different (longer, because the values are written line by line), but you can see the structure, the vertex number as an integer and the weight as a float.
I've not tried it to import such a file. Maybe it works.
User avatar
punkduck
 
Posts: 1216
Joined: Mon Oct 17, 2016 7:24 pm
Location: Nuremberg, Germany


Return to MHX2 and other plugins developed outside MakeHuman

Who is online

Users browsing this forum: No registered users and 1 guest