add virtools material basically
This commit is contained in:
38
bbp_ng/UTIL_functions.py
Normal file
38
bbp_ng/UTIL_functions.py
Normal file
@ -0,0 +1,38 @@
|
||||
import math
|
||||
|
||||
class BBPException(Exception):
|
||||
"""
|
||||
The exception thrown by Ballance Blender Plugin
|
||||
"""
|
||||
pass
|
||||
|
||||
def clamp_float(v: float, min_val: float, max_val: float) -> float:
|
||||
"""!
|
||||
@brief Clamp a float value
|
||||
|
||||
@param v[in] The value need to be clamp.
|
||||
@param min_val[in] The allowed minium value, including self.
|
||||
@param max_val[in] The allowed maxium value, including self.
|
||||
@return Clamped value.
|
||||
"""
|
||||
if (max_val < min_val): raise BBPException("Invalid range of clamp_float().")
|
||||
|
||||
if (v < min_val): return min_val
|
||||
elif (v > max_val): return max_val
|
||||
else: return v
|
||||
|
||||
def clamp_int(v: int, min_val: int, max_val: int) -> int:
|
||||
"""!
|
||||
@brief Clamp a int value
|
||||
|
||||
@param v[in] The value need to be clamp.
|
||||
@param min_val[in] The allowed minium value, including self.
|
||||
@param max_val[in] The allowed maxium value, including self.
|
||||
@return Clamped value.
|
||||
"""
|
||||
if (max_val < min_val): raise BBPException("Invalid range of clamp_int().")
|
||||
|
||||
if (v < min_val): return min_val
|
||||
elif (v > max_val): return max_val
|
||||
else: return v
|
||||
|
Reference in New Issue
Block a user