Skip to content

Commit

Permalink
[SHOT-3349] Scene Breakdown should not remove clones when updating in…
Browse files Browse the repository at this point in the history
… VRED (#30)

* In the scene breakdown, display only one item for a reference file even if many instances have been loaded in the current scene
* when updating cloned references, be sure to update very reference and keep the grouping information
* clone other instance of the references instead of loading them to improve performances
  • Loading branch information
barbara-darkshot authored May 6, 2020
1 parent 6fffd70 commit cf2def4
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions hooks/tk-multi-breakdown/basic/scene_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def scan_scene(self):
engine = self.parent.engine
operations = engine.operations

return operations.get_references()
# if many references to the same file exist in the scene, only keep one instance
scene_ref = operations.get_references()
scene_ref = [dict(r) for r in {tuple(d.items()) for d in scene_ref}]

return scene_ref

def update(self, items):
"""
Expand Down Expand Up @@ -58,19 +62,27 @@ def _update_node(self, item):
if len(nodes) <= 0:
return

node = nodes[0]
path = item["path"]
new_node = vrFileIO.loadGeometry(path)
name, extension = os.path.splitext(os.path.basename(path))

if name == new_node.getName():
materials_dict = self._obtain_materials()
self._apply_transformations(node, new_node, materials_dict)

# Put the new node as a child of the old's node parent
node.getParent().addChild(new_node)
materials_dict = self._obtain_materials()

vrScenegraph.deleteNode(node, True)
# load the geometry for the first node but after that, try to clone this node to avoid importing the file
# many time
new_node = vrFileIO.loadGeometry(path)
if name == new_node.getName():
self._apply_transformations(nodes[0], new_node, materials_dict)
nodes[0].getParent().addChild(new_node)

# now, clone the new node as many time as we have remaining node instances
for n in nodes[1:]:
new_n = new_node.clone()
if name == new_n.getName():
self._apply_transformations(n, new_n, materials_dict)
n.getParent().addChild(new_n)

# delete the nodes once everything has been created to avoid parent/child issue
vrScenegraph.deleteNodes(nodes, True)

def _obtain_materials(self):
"""
Expand Down

0 comments on commit cf2def4

Please sign in to comment.