feat: correct camera dof loading
This commit is contained in:
parent
5d71c49f3d
commit
158deb623c
@ -1,21 +1,51 @@
|
|||||||
|
from jsondiff import diff
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import mathutils
|
import mathutils
|
||||||
from jsondiff import diff
|
|
||||||
|
|
||||||
from .. import utils
|
from .. import utils
|
||||||
from .bl_datablock import BlDatablock
|
from .bl_datablock import BlDatablock
|
||||||
|
|
||||||
|
|
||||||
class BlCamera(BlDatablock):
|
class BlCamera(BlDatablock):
|
||||||
def load(self, data, target):
|
def load(self, data, target):
|
||||||
utils.dump_anything.load(target, data)
|
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):
|
def construct(self, data):
|
||||||
return bpy.data.cameras.new(data["name"])
|
return bpy.data.cameras.new(data["name"])
|
||||||
|
|
||||||
def dump(self, pointer=None):
|
def dump(self, pointer=None):
|
||||||
assert(pointer)
|
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):
|
def resolve(self):
|
||||||
assert(self.buffer)
|
assert(self.buffer)
|
||||||
@ -23,7 +53,7 @@ class BlCamera(BlDatablock):
|
|||||||
|
|
||||||
def diff(self):
|
def diff(self):
|
||||||
return (self.bl_diff() or
|
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):
|
def is_valid(self):
|
||||||
return bpy.data.cameras.get(self.buffer['name'])
|
return bpy.data.cameras.get(self.buffer['name'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user