Round transforms to 0.01, as TTS keeps changing them
This commit is contained in:
parent
449f91aaad
commit
5392c2b1d6
@ -43,6 +43,22 @@ def shouldRecurse(obj, subobject_prop):
|
||||
and obj.get('Name') not in ('Deck', 'DeckCustom') \
|
||||
and len(obj[subobject_prop]) > 1
|
||||
|
||||
def normalize_value(value):
|
||||
rounded = round(value, 2)
|
||||
if rounded == -0.0:
|
||||
return 0.0
|
||||
else:
|
||||
return rounded
|
||||
|
||||
def recursively_normalize_values(d):
|
||||
if type(d) == dict:
|
||||
return {key: recursively_normalize_values(value) for key, value in d.items()}
|
||||
elif type(d) == list:
|
||||
return [recursively_normalize_values(value) for value in d]
|
||||
elif type(d) == float:
|
||||
return normalize_value(d)
|
||||
else:
|
||||
return d
|
||||
|
||||
def recursivelyUnpackObject(parent_dir, obj,
|
||||
subobject_prop='ContainedObjects', base_name=None):
|
||||
@ -66,6 +82,11 @@ def recursivelyUnpackObject(parent_dir, obj,
|
||||
|
||||
obj['LuaScript'] = IncludeTag(obj_base_name + '.ttslua')
|
||||
|
||||
# round transforms, as TTS seems to slightly change them on each save
|
||||
for k in ['Transform', 'AttachedSnapPoints', 'SnapPoints', 'Hands']:
|
||||
if k in obj:
|
||||
obj[k] = recursively_normalize_values(obj[k])
|
||||
|
||||
with open(file_base_path + '.yaml', 'w') as f:
|
||||
yaml.dump(obj, f)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user