From 704ded295c2203c369be3e471355166b72b0250f Mon Sep 17 00:00:00 2001 From: tcauchois Date: Wed, 15 Jul 2020 11:37:14 -0700 Subject: [PATCH] [usdview] Change "Pick prims" and "Pick instances" to walk up through native instances, if applicable. Fixes #1196 (Internal change: 2083804) --- pxr/usdImaging/usdviewq/appController.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pxr/usdImaging/usdviewq/appController.py b/pxr/usdImaging/usdviewq/appController.py index 5c10ebb941..dad02aee24 100644 --- a/pxr/usdImaging/usdviewq/appController.py +++ b/pxr/usdImaging/usdviewq/appController.py @@ -4574,23 +4574,32 @@ def onPrimSelected(self, path, instanceIndex, topLevelPath, topLevelInstanceInde prim = model instanceIndex = ALL_INSTANCES - # Prim picking selects the top level boundable: either a - # gprim, or the top-level point instancer of a point - # instanced gprim. It discards the instance index. + # Prim picking selects the top level boundable: either the + # gprim, the top-level point instancer (if it's point + # instanced), or the top level USD instance (if it's marked + # instantiable), whichever is closer to namespace root. + # It discards the instance index. elif self._dataModel.viewSettings.pickMode == PickModes.PRIMS: topLevelPrim = self._dataModel.stage.GetPrimAtPath(topLevelPath) if topLevelPrim: prim = topLevelPrim + while prim.IsInstanceProxy(): + prim = prim.GetParent() instanceIndex = ALL_INSTANCES - # Instance picking is like prim picking, but selects a - # particular instance of the top-level point instancer - # (if applicable). + # Instance picking selects the top level boundable, like + # prim picking; but if that prim is a point instancer or + # a USD instance, it selects the particular instance + # containing the picked object. elif self._dataModel.viewSettings.pickMode == PickModes.INSTANCES: topLevelPrim = self._dataModel.stage.GetPrimAtPath(topLevelPath) if topLevelPrim: prim = topLevelPrim instanceIndex = topLevelInstanceIndex + if prim.IsInstanceProxy(): + while prim.IsInstanceProxy(): + prim = prim.GetParent() + instanceIndex = ALL_INSTANCES # Prototype picking selects a specific instance of the # actual picked gprim, if the gprim is point-instanced.