diff --git a/bl_types/bl_camera.py b/bl_types/bl_camera.py index be88f7d..b36baeb 100644 --- a/bl_types/bl_camera.py +++ b/bl_types/bl_camera.py @@ -1,30 +1,60 @@ +from jsondiff import diff + import bpy import mathutils -from jsondiff import diff from .. import utils from .bl_datablock import BlDatablock + class BlCamera(BlDatablock): def load(self, data, target): utils.dump_anything.load(target, data) + dof_settings = data.get('dof') + + # DOF settings + if dof_settings: + utils.dump_anything.load(target.dof, dof_settings) + def construct(self, data): return bpy.data.cameras.new(data["name"]) def dump(self, pointer=None): assert(pointer) - - return utils.dump_datablock(pointer, 1) - + + dumper = utils.dump_anything.Dumper() + dumper.depth = 2 + dumper.include_filter = [ + "name", + 'type', + 'lens', + 'lens_unit', + 'shift_x', + 'shift_y', + 'clip_start', + 'clip_end', + 'dof', + 'use_dof', + 'sensor_fit', + 'sensor_width', + 'focus_object', + 'focus_distance', + 'aperture_fstop', + 'aperture_blades', + 'aperture_rotation', + 'aperture_ratio', + ] + return dumper.dump(pointer) + def resolve(self): - assert(self.buffer) + assert(self.buffer) self.pointer = bpy.data.cameras.get(self.buffer['name']) - + def diff(self): return (self.bl_diff() or - len(diff(self.dump(pointer=self.pointer), self.buffer)) > 1) - + len(diff(self.dump(pointer=self.pointer), self.buffer))) + def is_valid(self): return bpy.data.cameras.get(self.buffer['name']) @@ -35,4 +65,4 @@ bl_rep_class = BlCamera bl_delay_refresh = 1 bl_delay_apply = 1 bl_automatic_push = True -bl_icon = 'CAMERA_DATA' \ No newline at end of file +bl_icon = 'CAMERA_DATA'