Skip to content

Commit

Permalink
rename properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Weisl committed Jan 30, 2024
1 parent bc0293c commit fb1ce3c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions collider_conversion/convert_from_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def execute(self, context):
regexp = re.compile(str(user_group_03))
if regexp.search(name):
obj['collider_group'] = 'USER_03'

isCollider = True

regexp = re.compile(str(user_group_02))
Expand Down
20 changes: 10 additions & 10 deletions collider_shapes/add_bounding_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,14 @@ def class_collider_name(cls, shape_identifier, user_group, basename='Basename'):
else:
name = basename

if prefs.parent_rename:
if prefs.parent_naming_position == 'SUFFIX':
end = prefs.parent_separator + prefs.parent_extension
if prefs.rigid_body_rename:
if prefs.rigid_body_naming_position == 'SUFFIX':
end = prefs.rigid_body_separator + prefs.rigid_body_extension
if name.endswith(end):
name = name[:-(len(end))]

else:
start = prefs.parent_extension + prefs.parent_separator
start = prefs.rigid_body_extension + prefs.rigid_body_separator
if name.startswith(start):
name = name[len(start):]

Expand Down Expand Up @@ -1128,13 +1128,13 @@ def set_collider_name(self, new_collider, parent_name):

def set_parent_name(self, parent):
new_name = parent.name
if self.prefs.parent_rename:
if self.prefs.parent_naming_position == 'SUFFIX':
if not parent.name.endswith(self.prefs.parent_extension):
new_name = parent.name + self.prefs.parent_separator + self.prefs.parent_extension
if self.prefs.rigid_body_rename:
if self.prefs.rigid_body_naming_position == 'SUFFIX':
if not parent.name.endswith(self.prefs.rigid_body_extension):
new_name = parent.name + self.prefs.rigid_body_separator + self.prefs.rigid_body_extension
else:
if not parent.name.startswith(self.prefs.parent_extension):
new_name = self.prefs.parent_extension + self.prefs.parent_separator + parent.name
if not parent.name.startswith(self.prefs.rigid_body_extension):
new_name = self.prefs.rigid_body_extension + self.prefs.rigid_body_separator + parent.name

parent.name = new_name

Expand Down
16 changes: 8 additions & 8 deletions preferences/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,22 +553,22 @@ class CollisionAddonPrefs(bpy.types.AddonPreferences):
default=False)


parent_rename : bpy.props.BoolProperty(name="Modify Parent Name",
rigid_body_rename : bpy.props.BoolProperty(name="Rigid Body",
description="Add suffix or prefix to parent name",
default=False)

parent_naming_position: bpy.props.EnumProperty(
rigid_body_naming_position: bpy.props.EnumProperty(
name='Parent Extension',
items=(('PREFIX', "Prefix", "Prefix"),
('SUFFIX', "Suffix", "Suffix")),
default='SUFFIX',
description='Add custom naming as prefix or suffix'
)

parent_extension: bpy.props.StringProperty(name="Parent Extension", default="RB",
rigid_body_extension: bpy.props.StringProperty(name="Parent Extension", default="RB",
description='String added to the parent naming')

parent_separator: bpy.props.StringProperty(name="Separator", default="_",
rigid_body_separator: bpy.props.StringProperty(name="Separator", default="_",
description="Separator character used to divide different suffixes (Empty field removes the separator from the naming)")

# DEBUG
Expand All @@ -594,10 +594,10 @@ class CollisionAddonPrefs(bpy.types.AddonPreferences):
]

props_parent = [
"parent_rename",
"parent_separator",
"parent_naming_position",
"parent_extension",
"rigid_body_rename",
"rigid_body_separator",
"rigid_body_naming_position",
"rigid_body_extension",
]

props_collider_groups = [
Expand Down

0 comments on commit fb1ce3c

Please sign in to comment.