PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
6k stars 1.19k forks source link

UsdImagingGL purposes not updated when UsdGeomImageable purposes are #575

Open jcouet opened 6 years ago

jcouet commented 6 years ago

Description of Issue

UsdImagingGL engine doesn't refresh/update its authored purposes cache when purposes are changed on USD prims. Thus, it's not possible to see dynamically the effect of purposes edition without resetting the engine

Steps to Reproduce

Here is a little code that presents the bug

Test() {
        mParams.showGuides = true;
        mParams.showProxy = true;
        mParams.showRender = false;
        mRenderer = std::make_shared<UsdImagingGL>();

        m_stage = UsdStage::CreateNew("sphere.usd");
        UsdGeomXform::Define(m_stage, SdfPath("/xfo"));
        UsdGeomSphere::Define(m_stage, SdfPath("/xfo/sphere"));
    }

    void renderPurpose(const TfToken& purpose) {
        UsdPrim prim = mStage->GetPrimAtPath(SdfPath("/xfo/sphere"););
        if (prim.IsA<UsdGeomImageable>()) {
            UsdGeomImageable imageable(prim);
            TfToken token(purpose);
            VtValue vtValue(token);
            UsdAttribute attribute = imageable.CreatePurposeAttr(vtValue);
        }
        mRenderer.reset(new UsdImagingGL); // --> !!! Need to re-construct the render engine to see the effects of a purpose change
        mRenderer->Render(mDefaultPrim, mParams);
    }
private:
    UsdStageRefPtr mStage;
    UsdImagingGLRefPtr mRenderer;
    UsdImagingGLEngine::RenderParams mParams;
}

System Information (OS, Hardware)

All

Package Versions

0.8.5

Build Flags

jtran56 commented 6 years ago

Filed as internal issue #163337.

marktucker commented 5 years ago

I assume this is the same bug, just a different way to reproduce, using usdview...

  1. Load the attached file in usdview purposes.zip
  2. Make sure that the Render and Guide purposes are turned off. You should only see a sphere.
  3. In the Interpreter window, run: i = UsdGeom.Imageable(usdviewApi.stage.GetPrimAtPath('/sopimport1/mesh0')) i.GetPurposeAttr().Set(UsdGeom.Tokens.default)
  4. I would expect to see the grid (mesh_0) appear in the viewport, but it does not. Changing the display purposes at this point will force a refresh that will make the grid show up.