Changeset View
Changeset View
Standalone View
Standalone View
space_view3d_math_vis/utils.py
| Context not available. | |||||
| return console.locals | return console.locals | ||||
| return {} | return {} | ||||
| def is_display_list(listvar): | |||||
| from mathutils import Vector | |||||
| for var in listvar: | |||||
| if type(var) is not Vector: | |||||
| return False | |||||
| return True | |||||
| def cleanup_math_data(): | |||||
| from mathutils import Matrix, Vector, Quaternion, Euler | |||||
| locals = console_namespace() | |||||
| if not locals: | |||||
| return | |||||
| candidates = [] | |||||
| for key, var in locals.items(): | |||||
| if key[0] == "_" or not var: | |||||
| continue | |||||
| if type(var) in [Matrix, Vector, Quaternion, Euler]: | |||||
| candidates.append(key) | |||||
| elif type(var) in [tuple, list] and is_display_list(var): | |||||
| candidates.append(key) | |||||
| for key in candidates: | |||||
| del locals[key] | |||||
| def console_math_data(): | def console_math_data(): | ||||
| from mathutils import Matrix, Vector, Quaternion, Euler | from mathutils import Matrix, Vector, Quaternion, Euler | ||||
| Context not available. | |||||
| data_quat[key] = var | data_quat[key] = var | ||||
| elif var_type is Euler: | elif var_type is Euler: | ||||
| data_euler[key] = var | data_euler[key] = var | ||||
| elif var_type in {list, tuple}: | elif var_type in {list, tuple} and is_display_list(var): | ||||
| if var: | data_vector_array[key] = var | ||||
| ok = True | |||||
| for item in var: | |||||
| if type(item) is not Vector: | |||||
| ok = False | |||||
| break | |||||
| if ok: | |||||
| data_vector_array[key] = var | |||||
| return data_matrix, data_quat, data_euler, data_vector, data_vector_array | return data_matrix, data_quat, data_euler, data_vector, data_vector_array | ||||
| Context not available. | |||||
mont29: `=` & spaces… | |||||
Done Inline Actionsspace before the \ mont29: space before the `\` | |||||
Done Inline ActionsUse sets rather than lists here ({tuple, list} etc.) mont29: Use sets rather than lists here (`{tuple, list}` etc.) | |||||
= & spaces…