mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 03:50:52 +00:00
Replace number with selector field
This commit is contained in:
parent
12bf1e5bab
commit
6b39b5f2b1
@ -171,7 +171,7 @@ type_mappings = {
|
|||||||
"bevy_color::linear_rgba::LinearRgba": lambda value: parse_color_rgba(value, float, "LinearRgba"),
|
"bevy_color::linear_rgba::LinearRgba": lambda value: parse_color_rgba(value, float, "LinearRgba"),
|
||||||
"bevy_color::hsva::Hsva": lambda value: parse_color_hsva(value, float, "Hsva"),
|
"bevy_color::hsva::Hsva": lambda value: parse_color_hsva(value, float, "Hsva"),
|
||||||
|
|
||||||
'bevy_ecs::entity::Entity': lambda value: int(value),
|
'bevy_ecs::entity::Entity': lambda value: int(value), # TODO: whatdafuq do we do here?
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_def_value_type(definition, registry):
|
def is_def_value_type(definition, registry):
|
||||||
|
@ -20,14 +20,16 @@ def process_tupples(registry, definition, prefixItems, update, nesting_long_name
|
|||||||
if ref_name in type_infos:
|
if ref_name in type_infos:
|
||||||
original = type_infos[ref_name]
|
original = type_infos[ref_name]
|
||||||
original_long_name = original["long_name"]
|
original_long_name = original["long_name"]
|
||||||
is_value_type = original_long_name in value_types_defaults
|
|
||||||
|
|
||||||
value = value_types_defaults[original_long_name] if is_value_type else None
|
is_value_type = original_long_name in blender_property_mapping
|
||||||
|
has_default_value = original_long_name in value_types_defaults
|
||||||
|
|
||||||
|
value = value_types_defaults[original_long_name] if has_default_value else None
|
||||||
default_values.append(value)
|
default_values.append(value)
|
||||||
prefix_infos.append(original)
|
prefix_infos.append(original)
|
||||||
|
|
||||||
if is_value_type:
|
if is_value_type:
|
||||||
if original_long_name in blender_property_mapping:
|
if has_default_value:
|
||||||
blender_property_def = blender_property_mapping[original_long_name]
|
blender_property_def = blender_property_mapping[original_long_name]
|
||||||
blender_property = blender_property_def["type"](
|
blender_property = blender_property_def["type"](
|
||||||
**blender_property_def["presets"],# we inject presets first
|
**blender_property_def["presets"],# we inject presets first
|
||||||
@ -36,6 +38,15 @@ def process_tupples(registry, definition, prefixItems, update, nesting_long_name
|
|||||||
update= update
|
update= update
|
||||||
)
|
)
|
||||||
|
|
||||||
|
__annotations__[property_name] = blender_property
|
||||||
|
else:
|
||||||
|
blender_property_def = blender_property_mapping[original_long_name]
|
||||||
|
blender_property = blender_property_def["type"](
|
||||||
|
**blender_property_def["presets"],# we inject presets first
|
||||||
|
name = property_name,
|
||||||
|
update= update
|
||||||
|
)
|
||||||
|
|
||||||
__annotations__[property_name] = blender_property
|
__annotations__[property_name] = blender_property
|
||||||
else:
|
else:
|
||||||
original_long_name = original["long_name"]
|
original_long_name = original["long_name"]
|
||||||
|
@ -25,6 +25,9 @@ def property_group_from_infos(property_group_name, property_group_parameters):
|
|||||||
|
|
||||||
return (property_group_pointer, property_group_class)
|
return (property_group_pointer, property_group_class)
|
||||||
|
|
||||||
|
def is_entity_poll(self, object):
|
||||||
|
return True # TODO: only select `object.type`s that get converted to entities
|
||||||
|
|
||||||
# this is where we store the information for all available components
|
# this is where we store the information for all available components
|
||||||
class ComponentsRegistry(PropertyGroup):
|
class ComponentsRegistry(PropertyGroup):
|
||||||
registry: bpy.props. StringProperty(
|
registry: bpy.props. StringProperty(
|
||||||
@ -50,7 +53,6 @@ class ComponentsRegistry(PropertyGroup):
|
|||||||
"u32": dict(type=IntProperty, presets=dict(min=0)),
|
"u32": dict(type=IntProperty, presets=dict(min=0)),
|
||||||
"u64": dict(type=IntProperty, presets=dict(min=0)),
|
"u64": dict(type=IntProperty, presets=dict(min=0)),
|
||||||
"u128": dict(type=IntProperty, presets=dict(min=0)),
|
"u128": dict(type=IntProperty, presets=dict(min=0)),
|
||||||
"u64": dict(type=IntProperty, presets=dict(min=0)),
|
|
||||||
"usize": dict(type=IntProperty, presets=dict(min=0)),
|
"usize": dict(type=IntProperty, presets=dict(min=0)),
|
||||||
|
|
||||||
"i8": dict(type=IntProperty, presets=dict()),
|
"i8": dict(type=IntProperty, presets=dict()),
|
||||||
@ -90,19 +92,19 @@ class ComponentsRegistry(PropertyGroup):
|
|||||||
|
|
||||||
"enum": dict(type=EnumProperty, presets=dict()),
|
"enum": dict(type=EnumProperty, presets=dict()),
|
||||||
|
|
||||||
'bevy_ecs::entity::Entity': {"type": IntProperty, "presets": {"min":0} },
|
"bevy_ecs::entity::Entity": dict(type = PointerProperty, presets=dict(type = bpy.types.Object, poll = is_entity_poll)),
|
||||||
'bevy_utils::Uuid': dict(type=StringProperty, presets=dict()),
|
"bevy_utils::Uuid": dict(type = StringProperty, presets=dict()),
|
||||||
}
|
}
|
||||||
|
|
||||||
value_types_defaults = {
|
value_types_defaults = {
|
||||||
"string":" ",
|
"string":" ",
|
||||||
"boolean": True,
|
"boolean": False,
|
||||||
"float": 0.0,
|
"float": 0.0,
|
||||||
"uint": 0,
|
"uint": 0,
|
||||||
"int":0,
|
"int":0,
|
||||||
|
|
||||||
# todo : we are re-doing the work of the bevy /rust side here, but it seems more pratical to alway look for the same field name on the blender side for matches
|
# todo : we are re-doing the work of the bevy /rust side here, but it seems more pratical to alway look for the same field name on the blender side for matches
|
||||||
"bool": True,
|
"bool": False,
|
||||||
|
|
||||||
"u8": 0,
|
"u8": 0,
|
||||||
"u16":0,
|
"u16":0,
|
||||||
@ -144,8 +146,7 @@ class ComponentsRegistry(PropertyGroup):
|
|||||||
"bevy_color::linear_rgba::LinearRgba": [1.0, 1.0, 0.0, 1.0],
|
"bevy_color::linear_rgba::LinearRgba": [1.0, 1.0, 0.0, 1.0],
|
||||||
"bevy_color::hsva::Hsva": [1.0, 1.0, 0.0, 1.0],
|
"bevy_color::hsva::Hsva": [1.0, 1.0, 0.0, 1.0],
|
||||||
|
|
||||||
'bevy_ecs::entity::Entity': 0,#4294967295, # this is the same as Bevy's Entity::Placeholder, too big for Blender..sigh
|
"bevy_utils::Uuid": '"'+str(uuid.uuid4())+'"'
|
||||||
'bevy_utils::Uuid': '"'+str(uuid.uuid4())+'"'
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user