X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=blender%2Fio_mspgl%2Fscene.py;fp=blender%2Fio_mspgl%2Fscene.py;h=4cb6be5baf63a45d521511a42d28d86de0c86c43;hb=ccc48ed8c2ab0c934e820131746442462ddd8f93;hp=7a0fa2f037d290108e8e3d951d8a7617874208c5;hpb=e23fecdc48dc34a61b05296f101bff13fbf9be7d;p=libs%2Fgl.git diff --git a/blender/io_mspgl/scene.py b/blender/io_mspgl/scene.py index 7a0fa2f0..4cb6be5b 100644 --- a/blender/io_mspgl/scene.py +++ b/blender/io_mspgl/scene.py @@ -1,4 +1,5 @@ import itertools +import bpy import mathutils def is_same_object(obj1, obj2): @@ -11,10 +12,16 @@ def is_same_object(obj1, obj2): class Instance: def __init__(self, obj, prototype): - self.name = obj.name - self.matrix_world = obj.matrix_world - self.rotation_mode = obj.rotation_mode - self.prototype = prototype + if type(obj)==bpy.types.DepsgraphObjectInstance: + self.name = None + self.matrix_world = mathutils.Matrix(obj.matrix_world) + self.rotation_mode = prototype.rotation_mode + self.prototype = bpy.data.objects[prototype.name] + else: + self.name = obj.name + self.matrix_world = obj.matrix_world + self.rotation_mode = obj.rotation_mode + self.prototype = prototype class Scene: def __init__(self, scene, obj_filter=None): @@ -65,6 +72,10 @@ class Scene: if o.data.use_shadow: self.use_shadow = True + for i in scene.view_layers[0].depsgraph.object_instances: + if i.is_instance and i.object.type=='MESH': + self.add_instance(Instance(i, i.object)) + proto_map = {} for i in itertools.chain(self.instances, self.blended_instances): p = proto_map.get(i.prototype)