2024-08-14 14:57:34 +02:00
|
|
|
|
|
|
|
def get_version_major():
|
|
|
|
return 0
|
|
|
|
def get_version_minor():
|
|
|
|
return 0
|
|
|
|
def get_version_patch():
|
2024-10-31 19:34:47 +01:00
|
|
|
return 2
|
2024-08-14 14:57:34 +02:00
|
|
|
def get_version_string():
|
|
|
|
return f"{get_version_major()}.{get_version_minor()}.{get_version_patch}"
|
|
|
|
def prefix():
|
|
|
|
return "ABC3D"
|
|
|
|
|
2024-05-21 18:00:49 +02:00
|
|
|
import time
|
|
|
|
import datetime
|
2024-07-01 10:25:17 +02:00
|
|
|
from mathutils import (
|
|
|
|
Vector,
|
|
|
|
)
|
2024-05-21 18:00:49 +02:00
|
|
|
|
|
|
|
def get_timestamp():
|
|
|
|
return datetime.datetime \
|
|
|
|
.fromtimestamp(time.time()) \
|
|
|
|
.strftime('%Y.%m.%d-%H:%M:%S')
|
|
|
|
|
|
|
|
def mapRange(in_value, in_min, in_max, out_min, out_max, clamp=False):
|
|
|
|
output = out_min + ((out_max - out_min) / (in_max - in_min)) * (in_value - in_min)
|
|
|
|
if clamp:
|
2024-07-01 10:25:17 +02:00
|
|
|
if out_min < out_max:
|
|
|
|
return min(out_max, max(out_min, output))
|
|
|
|
else:
|
|
|
|
return max(out_max, min(out_min, output))
|
2024-05-21 18:00:49 +02:00
|
|
|
else:
|
2024-07-01 10:25:17 +02:00
|
|
|
return output
|
2024-11-05 16:03:09 +01:00
|
|
|
|
|
|
|
|
2024-08-14 13:39:47 +02:00
|
|
|
import warnings
|
|
|
|
import functools
|
|
|
|
|
|
|
|
def deprecated(func):
|
|
|
|
"""This is a decorator which can be used to mark functions
|
|
|
|
as deprecated. It will result in a warning being emitted
|
|
|
|
when the function is used."""
|
|
|
|
@functools.wraps(func)
|
|
|
|
def new_func(*args, **kwargs):
|
|
|
|
warnings.simplefilter('always', DeprecationWarning) # turn off filter
|
|
|
|
warnings.warn("Call to deprecated function {}.".format(func.__name__),
|
|
|
|
category=DeprecationWarning,
|
|
|
|
stacklevel=2)
|
|
|
|
warnings.simplefilter('default', DeprecationWarning) # reset filter
|
|
|
|
return func(*args, **kwargs)
|
|
|
|
return new_func
|
2024-07-01 10:25:17 +02:00
|
|
|
|
2024-11-05 16:03:09 +01:00
|
|
|
|
2024-11-05 16:02:58 +01:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2024-08-14 14:07:41 +02:00
|
|
|
def open_file_browser(directory):
|
|
|
|
if sys.platform=='win32':
|
|
|
|
os.startfile(directory)
|
|
|
|
|
|
|
|
elif sys.platform=='darwin':
|
|
|
|
subprocess.Popen(['open', directory])
|
|
|
|
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
subprocess.Popen(['xdg-open', directory])
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
# er, think of something else to try
|
|
|
|
# xdg-open *should* be supported by recent Gnome, KDE, Xfce
|
|
|
|
|
|
|
|
|
2024-07-01 10:25:17 +02:00
|
|
|
# # Evaluate a bezier curve for the parameter 0<=t<=1 along its length
|
|
|
|
# def evaluateBezierPoint(p1, h1, h2, p2, t):
|
|
|
|
# return ((1 - t)**3) * p1 + (3 * t * (1 - t)**2) * h1 + (3 * (t**2) * (1 - t)) * h2 + (t**3) * p2
|
|
|
|
|
|
|
|
|
|
|
|
# # Evaluate the unit tangent on a bezier curve for t
|
|
|
|
# def evaluateBezierTangent(p1, h1, h2, p2, t):
|
|
|
|
# return (
|
|
|
|
# (-3 * (1 - t)**2) * p1 + (-6 * t * (1 - t) + 3 * (1 - t)**2) * h1 +
|
|
|
|
# (-3 * (t**2) + 6 * t * (1 - t)) * h2 + (3 * t**2) * p2
|
|
|
|
# ).normalized()
|
|
|
|
|
|
|
|
# def calculateBezierLength(p1, h1, h2, p2, resolution=20):
|
|
|
|
# step = 1/resolution
|
|
|
|
# previous_p = p1
|
|
|
|
# length = 0
|
|
|
|
# for i in range(0, resolution):
|
|
|
|
# t = (i + 1) * step
|
|
|
|
# p = evaluateBezierPoint(p1, h1, h2, p2, t)
|
|
|
|
# length += p.distance(previous_p)
|
|
|
|
# previous_p = p
|
|
|
|
# return length
|