Skip to content

Commit fefe302

Browse files
authored
Merge pull request #30 from compas-dev/fix/double-transformation
fix double transformation in viewer
2 parents 897f3f1 + 895cb23 commit fefe302

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
### Changed
1919

2020
* Fixed bug in `compas_viewer` due to import of `RobotModelObject` inside registration function.
21+
* Fixed a double transformation issue with `RobotModelObject` for `compas_viewer>=1.4.0`.
2122

2223
### Removed
2324

src/compas_robots/viewer/scene/robotmodelobject.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ def show_visual(self, value: bool):
7373
if value == self._show_visual:
7474
return
7575
self._show_visual = value
76+
parent = self
7677
for i, visual_object in enumerate(self.visual_objects):
7778
if value:
78-
parent = self
79-
if i > 0:
80-
parent = self.visual_objects[i - 1]
79+
# NOTE: This is a workaround to avoid double transformation issue with latest version of `compas_viewer`.
80+
# if i > 0:
81+
# parent = self.visual_objects[i - 1]
8182
self.scene.add(visual_object, parent)
8283
self.scene.instance_colors[visual_object.instance_color.rgb255] = visual_object
8384
else:
@@ -91,12 +92,13 @@ def show_collision(self):
9192
def show_collision(self, value: bool):
9293
if value == self._show_collision:
9394
return
95+
parent = self
9496
self._show_collision = value
9597
for i, collision_object in enumerate(self.collision_objects):
9698
if value:
97-
parent = self
98-
if i > 0:
99-
parent = self.visual_objects[i - 1]
99+
# NOTE: This is a workaround to avoid double transformation issue with latest version of `compas_viewer`.
100+
# if i > 0:
101+
# parent = self.visual_objects[i - 1]
100102
self.scene.add(collision_object, parent)
101103
self.scene.instance_colors[collision_object.instance_color.rgb255] = collision_object
102104
else:
@@ -113,8 +115,9 @@ def add_objects(objects, show_flag):
113115
for i, obj in enumerate(objects):
114116
obj.init()
115117
if show_flag:
116-
if i > 0:
117-
parent = objects[i - 1]
118+
# NOTE: This is a workaround to avoid double transformation issue with latest version of `compas_viewer`.
119+
# if i > 0:
120+
# parent = objects[i - 1]
118121
self.viewer.scene.add(obj, parent)
119122
self.viewer.scene.instance_colors[obj.instance_color.rgb255] = obj
120123

@@ -160,10 +163,10 @@ def update_joints(self, joint_state: Configuration):
160163

161164
if self.show_visual:
162165
for obj in self.visual_objects:
163-
obj._update_matrix()
166+
obj.update()
164167

165168
if self.show_collision:
166169
for obj in self.collision_objects:
167-
obj._update_matrix()
170+
obj.update()
168171

169172
self.viewer.renderer.update()

0 commit comments

Comments
 (0)