[Sidefx-houdini-list] HDK - help with volumes

Andy Milne Andrew.Milne at disneyanimation.com
Tue Mar 15 12:43:13 EDT 2011


I've done a little work with volumes.  I have some code that 
looks similar to yours, except that instead of using the 
voxelHandle directly, I get the voxel array from the voxel 
handle and set it using an iterator.  I don't remember why I 
did it that way, but you might try this to see if it helps.  
This is in a SOP, and it calls gdp->clearAndDestroy() 
without any crash.

     GU_PrimVolume *vol =
         dynamic_cast<GU_PrimVolume*>( GU_PrimVolume::build( gdp ) );
     UT_VoxelArrayWriteHandleF voxelH =
         vol->getVoxelWriteHandle();
     UT_VoxelArrayF *voxels =&(*voxelH);
     voxels->size( counts.x, counts.y, counts.z );
     UT_VoxelArrayIteratorF vit( voxels );
     vit.setCompressOnExit( true );
     for ( vit.rewind(); !vit.atEnd(); vit.advance() ) {
         phi = grid[vit.x()][vit.y()][vit.z()];
         vit.setValue( phi );
     }


For an overview of what the GU_, GB_, GD_ prefixes mean, see:
http://www.sidefx.com/docs/hdk11.0/hdk_geometry_intro.html#HDK_Geometry_Intro_Classes
UT_ is just "utilities"




Andy Milne

On 03/14/2011 03:38 PM, Vincent Houzé wrote:
> Hi,
>
> I'm trying to port my Cuda fluid solver (http://vimeo.com/20625705) to Houdini.
> I want to do it as a black box sop first, because it seems easier, and
> faster as well, from what I have read.
> I had a first successful try copying values to the color attributes on
> primitives, but now I'd like to fill a volume primitive.
>
> The code from the gengeovolume sample works on the first cook (I
> modified the SOP_star example) :
>
> GU_PrimVolume   *volumeGdp = (GU_PrimVolume *)GU_PrimVolume::build(gdp);
> UT_VoxelArrayWriteHandleF voxelHandle = volumeGdp->getVoxelWriteHandle();
> voxelHandle->size(global_grid.grid_x, global_grid.grid_y, global_grid.grid_z);
> .......
> voxelHandle->setValue( x, y, z, phi);
>
>
> but on the next one gdp->clearAndDestroy() causes Houdini to crash,
> which is already described in this forum post
> http://forums.odforce.net/index.php?/topic/11677-how-can-i-delete-gu-primvolume/page__gopid__80497&#entry80497
> but wasn't answered.
>
>
>
> I had another try, this time I create a volume sop and I want to
> modify the volume primitive instead of creating it, avoiding the
> clearanddestroy().
> But no success either.
> with
> pprim = gdp->primitives().head();
> volume = (GU_PrimVolume *)pprim;
> UT_VoxelArrayWriteHandleF	handle = volume->getVoxelWriteHandle();
>
> the handle seems correct, but I get a crash with the first setValue().
> It seems related to the compression of the tiles (only difference
> between the volume I create from scratch and the volume I get from a
> volume sop is myDitherType set to "DITHER_ORDERED", and the crash
> occurs in UT_VoxelTile::uncompress(), called by setValue().
> The docs don't say much, except access to the tiles should be transparent.
>
> Thanks a lot for any help/a working example,
> Vincent
>
> PS : also what do the GU_, GB_, GD_, UT_ prefixes mean ? The docs
> don't say, maybe it would help me understand the inheritance diagram
> which don't make much sense right now to me!
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>



More information about the Sidefx-houdini-list mailing list