Jump to content
Sign in to follow this  
JoshJ

info about GU_Detail::polyIsoSurface

Recommended Posts

I'm experimenting with creating a sop, returning a polygon mesh from an implicit function, using GU_Detail::polyIsoSurface.  The example density function works fine, returning a sphere.

 

SPHERE_FUNCTION:

static float

densityFunction(const UT_Vector3 &P, void *data)

{
// Return the signed distance to the unit sphere
return 1 - P.length();
}

However, when I change the return value so that a level set function should return a plane, I only receive empty geometry.

 

PLANE_FUNCTION:

static float

densityFunction(const UT_Vector3 &P, void *data)

{
// Return the signed distance to the unit sphere
return P.y();
//or
//return 1 - P.y();
//or
//return -P.y();
}

The bounds are set just like in the standalone example file, but in the cookMySop function:

OP_ERROR
SOP_IsoFunction::cookMySop(OP_Context &context)
{

    OP_AutoLockInputs inputs(this);
    if (inputs.lock(context) >= UT_ERROR_ABORT)
        return error();

    // Duplicate input geometry
    duplicateSource(0, context);

    // Flag the SOP as being time dependent (i.e. cook on time changes)
    flags().timeDep = 1;

    gdp->clearAndDestroy();
    UT_BoundingBox bounds;
    bounds.setBounds(-1, -1, -1, 1, 1, 1);
    gdp->polyIsoSurface(densityFunction, NULL, bounds, 20, 20, 20);

    return error();
}

Any ideas why this is returning a sphere with SPHERE_FUNCTION, but empty geometry with PLANE_FUNCTION? The levelset should be crossing the zero threshold on the xz plane, right?

 

Edit: I found that when I add a slight noise to the plane function, it appears.  But if the plane is perfectly flat, it returns empty geometry.  Strange.

Edited by JoshJ

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  

×