Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volume Previs HDA Broken on Install #31

Open
tomgiagtz opened this issue Aug 9, 2022 · 0 comments
Open

Volume Previs HDA Broken on Install #31

tomgiagtz opened this issue Aug 9, 2022 · 0 comments

Comments

@tomgiagtz
Copy link

tomgiagtz commented Aug 9, 2022

Typo in the volume points python code.

x /= reduce
y /= reduce
z /= reduce

bounds = geo.boundingBox()
bmin = bounds.minvec()
bmax = bounds.maxvec()
bstep = hou.Vector3((bmax[0] - bmin[0]) / x, (bmax[1] - bmin[1]) / y, (bmax[2] - bmin[2]) / z) 

geo.clear()

for i in xrange(x):  #<<<======
    for j in range(y):
        for k in range(z):
            p = geo.createPoint()
            p.setPosition((bmin[0] + (i*bstep[0]),bmin[1] + (j*bstep[1]),bmin[2] + (k*bstep[2])))

Fixing produced a float to int casting error.

Didn't take long to fix, I'm going to create a PR for this. Here's the updated version of the volumepoints.py

    if isinstance(geo, hou.Geometry):
        for prim in geo.prims():
            if isinstance(prim, hou.Volume):
                if prim.stringAttribValue('name') == name :
                    return prim;
            
        raise hou.Error("Cannot find Volume with name of : %s" % name )        
        return None
    raise hou.Error("Error: geo parameter is not of Geometry type")
    return None
    
# This code is called when instances of this SOP cook.
node = hou.pwd()
geo = node.geometry()

volumename = node.parm("parm_volumename").evalAsString()
volume = FindNamedVolume(geo,volumename)
reduce = node.parm("parm_reduce").evalAsInt()

x = volume.resolution()[0]
y = volume.resolution()[1]
z = volume.resolution()[2]

x = x // reduce
y = y // reduce
z = z // reduce

bounds = geo.boundingBox()
bmin = bounds.minvec()
bmax = bounds.maxvec()
bstep = hou.Vector3((bmax[0] - bmin[0]) / x, (bmax[1] - bmin[1]) / y, (bmax[2] - bmin[2]) / z) 

geo.clear()

for i in range(x):
    for j in range(y):
        for k in range(z):
            p = geo.createPoint()
            p.setPosition((bmin[0] + (i*bstep[0]),bmin[1] + (j*bstep[1]),bmin[2] + (k*bstep[2])))
@tomgiagtz tomgiagtz changed the title Volume Previs Broken on Install Volume Previs HDA Broken on Install Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant