2020-03-20 14:56:50 +01:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
|
2019-11-04 17:55:41 +01:00
|
|
|
import bpy
|
|
|
|
import mathutils
|
2020-02-07 00:48:34 +01:00
|
|
|
import logging
|
2019-11-04 17:55:41 +01:00
|
|
|
|
2020-04-01 11:37:05 +02:00
|
|
|
from .dump_anything import Loader, Dumper
|
2019-11-04 17:55:41 +01:00
|
|
|
from .bl_datablock import BlDatablock
|
|
|
|
|
|
|
|
|
2020-01-13 18:51:31 +01:00
|
|
|
class BlLightprobe(BlDatablock):
|
|
|
|
bl_id = "lightprobes"
|
|
|
|
bl_class = bpy.types.LightProbe
|
2020-09-17 22:47:11 +02:00
|
|
|
bl_check_common = False
|
2020-01-13 18:51:31 +01:00
|
|
|
bl_icon = 'LIGHTPROBE_GRID'
|
2020-12-09 14:49:26 +01:00
|
|
|
bl_reload_parent = False
|
2020-01-13 18:51:31 +01:00
|
|
|
|
2021-03-26 12:30:15 +01:00
|
|
|
def construct(data: dict) -> object:
|
2020-01-23 11:02:11 +01:00
|
|
|
type = 'CUBE' if data['type'] == 'CUBEMAP' else data['type']
|
2020-02-07 00:48:34 +01:00
|
|
|
# See https://developer.blender.org/D6396
|
|
|
|
if bpy.app.version[1] >= 83:
|
|
|
|
return bpy.data.lightprobes.new(data["name"], type)
|
|
|
|
else:
|
2020-04-22 17:04:14 +02:00
|
|
|
logging.warning("Lightprobe replication only supported since 2.83. See https://developer.blender.org/D6396")
|
2020-03-27 18:18:36 +01:00
|
|
|
|
2021-03-26 12:30:15 +01:00
|
|
|
def load(data: dict, datablock: object):
|
2020-04-01 11:34:24 +02:00
|
|
|
loader = Loader()
|
|
|
|
loader.load(target, data)
|
2019-11-04 17:55:41 +01:00
|
|
|
|
2021-03-26 12:30:15 +01:00
|
|
|
def dump(datablock: object) -> dict:
|
2020-04-07 14:49:43 +02:00
|
|
|
assert(instance)
|
2020-02-07 10:50:14 +01:00
|
|
|
if bpy.app.version[1] < 83:
|
2020-04-22 17:04:14 +02:00
|
|
|
logging.warning("Lightprobe replication only supported since 2.83. See https://developer.blender.org/D6396")
|
2019-11-04 17:55:41 +01:00
|
|
|
|
2020-04-01 11:34:24 +02:00
|
|
|
dumper = Dumper()
|
2019-11-04 17:55:41 +01:00
|
|
|
dumper.depth = 1
|
|
|
|
dumper.include_filter = [
|
|
|
|
"name",
|
2020-01-23 11:02:11 +01:00
|
|
|
'type',
|
2019-11-04 17:55:41 +01:00
|
|
|
'influence_type',
|
|
|
|
'influence_distance',
|
|
|
|
'falloff',
|
|
|
|
'intensity',
|
|
|
|
'clip_start',
|
|
|
|
'clip_end',
|
|
|
|
'visibility_collection',
|
|
|
|
'use_custom_parallax',
|
|
|
|
'parallax_type',
|
|
|
|
'parallax_distance',
|
2020-01-23 11:02:11 +01:00
|
|
|
'grid_resolution_x',
|
|
|
|
'grid_resolution_y',
|
|
|
|
'grid_resolution_z',
|
|
|
|
'visibility_buffer_bias',
|
|
|
|
'visibility_bleed_bias',
|
|
|
|
'visibility_blur'
|
2019-11-04 17:55:41 +01:00
|
|
|
]
|
|
|
|
|
2020-04-07 14:49:43 +02:00
|
|
|
return dumper.dump(instance)
|
2019-11-04 17:55:41 +01:00
|
|
|
|
2020-03-11 15:17:13 +01:00
|
|
|
|
2020-03-09 15:59:30 +01:00
|
|
|
|