Jump to content
Sign in to follow this  

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

Share this post

Link to post
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

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

Share this post

Link to post
Share on other sites

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" );

Cheers !

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this