@@ -74,3 +74,45 @@ def test_scene_graph_hierarchy_changes(self):
74
74
self .assertTrue ((grandchild .get_local2world_mat ()[:3 , 3 ] == [4 , 0 , 0 ]).all ())
75
75
self .assertEqual (root .get_children (), [grandchild ])
76
76
self .assertEqual (child .get_children (), [])
77
+
78
+ def test_duplicate_linked (self ):
79
+ bproc .clean_up (True )
80
+
81
+ cube = bproc .object .create_primitive ("CUBE" )
82
+ duplicate_cube = cube .duplicate (False )
83
+ self .assertEqual (cube .blender_obj .data , duplicate_cube .blender_obj .data )
84
+
85
+ empty = bproc .object .create_empty ("empty" )
86
+ duplicate_empty = empty .duplicate (False )
87
+ self .assertEqual (duplicate_empty .blender_obj .data , None )
88
+
89
+ light = Light ()
90
+ duplicate_light = light .duplicate (False )
91
+ self .assertEqual (light .blender_obj .data , duplicate_light .blender_obj .data )
92
+
93
+ def test_duplicate_hierarchy (self ):
94
+ bproc .clean_up (True )
95
+
96
+ root = bproc .object .create_primitive ("CUBE" )
97
+ child = bproc .object .create_primitive ("CUBE" )
98
+ grandchild = bproc .object .create_primitive ("CUBE" )
99
+
100
+ grandchild .set_location ([1 , 1 , 1 ])
101
+ grandchild .set_parent (child )
102
+
103
+ child .set_location ([1 , 1 , 1 ])
104
+ child .set_parent (root )
105
+
106
+ duplicate_root = root .duplicate ()
107
+ duplicate_child = duplicate_root .get_children ()[0 ]
108
+ duplicate_grandchild = duplicate_child .get_children ()[0 ]
109
+
110
+ # world location
111
+ self .assertTrue ((duplicate_root .get_local2world_mat ()[:3 , 3 ] == [0 , 0 , 0 ]).all ())
112
+ self .assertTrue ((duplicate_child .get_local2world_mat ()[:3 , 3 ] == [1 , 1 , 1 ]).all ())
113
+ self .assertTrue ((duplicate_grandchild .get_local2world_mat ()[:3 , 3 ] == [2 , 2 , 2 ]).all ())
114
+
115
+ # relative location
116
+ self .assertTrue ((duplicate_root .get_location () == [0 , 0 , 0 ]).all ())
117
+ self .assertTrue ((duplicate_child .get_location () == [1 , 1 , 1 ]).all ())
118
+ self .assertTrue ((duplicate_grandchild .get_location () == [1 , 1 , 1 ]).all ())
0 commit comments