refactored type init
This commit is contained in:
parent
060612d789
commit
c0ab4bb7ad
7 changed files with 66 additions and 58 deletions
|
|
@ -3,7 +3,8 @@ import math
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from .. types import (get_source, get_target)
|
from .. types.sources import get_source
|
||||||
|
from .. types.targets import get_target
|
||||||
|
|
||||||
|
|
||||||
class BakeToIDMapOperator(bpy.types.Operator):
|
class BakeToIDMapOperator(bpy.types.Operator):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from .. operators.bake_to_id_map import BakeToIDMapOperator
|
from .. types.sources import get_source
|
||||||
from ..types import get_source
|
|
||||||
|
|
||||||
|
|
||||||
class BakeToIDInfoPanel(bpy.types.Panel):
|
class BakeToIDInfoPanel(bpy.types.Panel):
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import textwrap
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
from src.types import get_source, get_target
|
from .. types.sources import get_source
|
||||||
|
from .. types.targets import get_target
|
||||||
|
|
||||||
|
|
||||||
class BakeToIDOptionsPanel(bpy.types.Panel):
|
class BakeToIDOptionsPanel(bpy.types.Panel):
|
||||||
|
|
@ -22,6 +23,8 @@ class BakeToIDOptionsPanel(bpy.types.Panel):
|
||||||
|
|
||||||
layout.prop(props, "source")
|
layout.prop(props, "source")
|
||||||
source = get_source(props.source)
|
source = get_source(props.source)
|
||||||
|
|
||||||
|
if len(source.connected_properties) > 0:
|
||||||
source_settings_box = layout.box()
|
source_settings_box = layout.box()
|
||||||
for setting in source.connected_properties:
|
for setting in source.connected_properties:
|
||||||
source_settings_box.prop(props, setting)
|
source_settings_box.prop(props, setting)
|
||||||
|
|
@ -30,6 +33,7 @@ class BakeToIDOptionsPanel(bpy.types.Panel):
|
||||||
|
|
||||||
layout.prop(props, "target")
|
layout.prop(props, "target")
|
||||||
target = get_target(props.target)
|
target = get_target(props.target)
|
||||||
|
if len(target.connected_properties) > 0:
|
||||||
target_settings_box = layout.box()
|
target_settings_box = layout.box()
|
||||||
for setting in target.connected_properties:
|
for setting in target.connected_properties:
|
||||||
target_settings_box.prop(props, setting)
|
target_settings_box.prop(props, setting)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
from bpy.types import (PropertyGroup)
|
from bpy.types import (PropertyGroup)
|
||||||
from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty)
|
from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty)
|
||||||
|
|
||||||
from src.types import get_source_enum, get_targets_enum
|
from src.types.sources import get_source_enum
|
||||||
|
from src.types.targets import get_targets_enum
|
||||||
|
|
||||||
|
|
||||||
class BakeToIDProperties(PropertyGroup):
|
class BakeToIDProperties(PropertyGroup):
|
||||||
|
|
@ -21,8 +22,8 @@ class BakeToIDProperties(PropertyGroup):
|
||||||
name="Source",
|
name="Source",
|
||||||
description="From where should the IDs be taken",
|
description="From where should the IDs be taken",
|
||||||
default="MATERIAL_INDEX"
|
default="MATERIAL_INDEX"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target: EnumProperty(
|
target: EnumProperty(
|
||||||
items=get_targets_enum(),
|
items=get_targets_enum(),
|
||||||
name="Target",
|
name="Target",
|
||||||
|
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
from . sources import material_index as source_mat_index
|
|
||||||
from . sources import object as source_object
|
|
||||||
|
|
||||||
from . targets import vertex_colors as target_vertex_colors
|
|
||||||
|
|
||||||
_sources = [
|
|
||||||
source_mat_index,
|
|
||||||
source_object
|
|
||||||
]
|
|
||||||
|
|
||||||
_targets = [
|
|
||||||
target_vertex_colors
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_source(id):
|
|
||||||
for source in _sources:
|
|
||||||
if source.source_id == id:
|
|
||||||
return source
|
|
||||||
|
|
||||||
raise Exception("Source not found: " + id)
|
|
||||||
|
|
||||||
def get_target(id):
|
|
||||||
for target in _targets:
|
|
||||||
if target.target_id == id:
|
|
||||||
return target
|
|
||||||
|
|
||||||
raise Exception("Target not found: " + id)
|
|
||||||
|
|
||||||
def get_source_enum():
|
|
||||||
enumList = []
|
|
||||||
i = 0
|
|
||||||
for source in _sources:
|
|
||||||
enumList.append((source.source_id, source.name, source.description, i))
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
return enumList
|
|
||||||
|
|
||||||
def get_targets_enum():
|
|
||||||
enumList = []
|
|
||||||
i = 0
|
|
||||||
for target in _targets:
|
|
||||||
enumList.append((target.target_id, target.name, target.description, i))
|
|
||||||
i += 1
|
|
||||||
|
|
||||||
return enumList
|
|
||||||
25
src/types/sources/__init__.py
Normal file
25
src/types/sources/__init__.py
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
from . import material_index
|
||||||
|
from . import object
|
||||||
|
|
||||||
|
_sources = [
|
||||||
|
material_index,
|
||||||
|
object
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_source(id):
|
||||||
|
for source in _sources:
|
||||||
|
if source.source_id == id:
|
||||||
|
return source
|
||||||
|
|
||||||
|
raise Exception("Source not found: " + id)
|
||||||
|
|
||||||
|
|
||||||
|
def get_source_enum():
|
||||||
|
enum_list = []
|
||||||
|
i = 0
|
||||||
|
for source in _sources:
|
||||||
|
enum_list.append((source.source_id, source.name, source.description, i))
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
return enum_list
|
||||||
|
|
||||||
23
src/types/targets/__init__.py
Normal file
23
src/types/targets/__init__.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
from . import vertex_colors
|
||||||
|
|
||||||
|
_targets = [
|
||||||
|
vertex_colors
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_target(id):
|
||||||
|
for target in _targets:
|
||||||
|
if target.target_id == id:
|
||||||
|
return target
|
||||||
|
|
||||||
|
raise Exception("Target not found: " + id)
|
||||||
|
|
||||||
|
|
||||||
|
def get_targets_enum():
|
||||||
|
enum_list = []
|
||||||
|
i = 0
|
||||||
|
for target in _targets:
|
||||||
|
enum_list.append((target.target_id, target.name, target.description, i))
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
return enum_list
|
||||||
Loading…
Add table
Add a link
Reference in a new issue