Jump to content

Delete zero-weight bones from skin [SOLVED]


Recommended Posts

Hello there !
I'm looking for a way to replicate the "prune small skin weights" of Maya into Houdini.

I've found the capture correct node, in which I can clamp the weights. The thing is, the bones are still weighted to the points, just with a zero weight. I want the bone to be removed from the list altogether.
Is there a way of doing that ? The "Regions to Remove" field sounds promising, but I haven't been able to do anything with it.

If you can answer the previous question, then the rest is not usefull anymore. But if you can answer it too, I'll be a happy little Houdini user :) grateful.
Instead, I tried to do it manually. I dropped down a capture attrib unpack and a python node in which I recreate the arrays without the zero-weight bones.
The thing is, I can't find how to create an array attribute on the points ! What is the correct syntax ?

I've tried

node = hou.pwd()
geo = node.geometry()

geo.addAttrib(hou.attribType.Point, 'myAttrib', [ 1, 2, 3 ])

but this creates 3 attributes myAttrib[0] myAttrib[1] myAttrib[2].

Thanks !

delete bone from skin.hipnc

EDIT : Real-time update : Figured how to create an array attribute :
geo.addArrayAttrib( hou.attribType.Point, "myAttrib", hou.attribData.Float, 1 )

geo.addArrayAttrib( hou.attribType.Point, "myAttrib", hou.attribData.Float, 1 )

But now I've got to figure how to populate it.

Edited by Alain2131
Link to comment
Share on other sites

Well, I figured out how to do it in VEX.

int success = 0; // Don't know why this is not optional

float data_array[] = pointattrib( 0, "boneCapture_data", @ptnum, success );
float index_array[] = pointattrib( 0, "boneCapture_index", @ptnum, success );

for( int i=0; i<len(data_array); i++ ) {
    pop(f[]@boneCapture_data); // Would need a more efficient way to clear the current point's array data
    pop(i[]@boneCapture_index);
}

for( int i=0; i<len(data_array); i++ ) {
    if(data_array[i] != 0.0 ) {
        setpointattrib( 0, "boneCapture_data", @ptnum, data_array[i], "append" );
        setpointattrib( 0, "boneCapture_index", @ptnum, index_array[i], "append" );
    }
}

I heard that Python is pretty slow compared to VEX, so I thought why not. And it turned out easier to do.

delete bone from skin_1.hipnc

Link to comment
Share on other sites

  • Alain2131 changed the title to Delete zero-weight bones from skin [SOLVED]

Sorry for double-post (triple if we count yesterday's), but here's a little change in logic, should be more optimized now :

for( int i=0; i<len(f[]@boneCapture_data); i++ ) {
    if(f[]@boneCapture_data[i] == 0.0 ) {
        setpointattrib( 0, "boneCapture_data", @ptnum, slice( f[]@boneCapture_data, 0, i ), "set" );
        setpointattrib( 0, "boneCapture_index", @ptnum, slice( i[]@boneCapture_index, 0, i ), "set" );
        break;
    }
}

Cheers !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...