Import_3ds: Improved distance cue chunk import
[blender-addons.git] / mesh_tissue / config.py
blobe29fdcfb9f412121355fb9033b4c31710c7e4166
1 # SPDX-FileCopyrightText: 2022-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 import bpy
6 from bpy.props import (
7 IntProperty,
8 BoolProperty
11 evaluatedDepsgraph = None
13 class tissuePreferences(bpy.types.AddonPreferences):
14 bl_idname = __package__
16 print_stats : IntProperty(
17 name="Print Stats",
18 description="Print in the console all details about the computing time.",
19 default=1,
20 min=0,
21 max=4
24 use_numba_tess : BoolProperty(
25 name="Numba Tessellate",
26 description="Boost the Tessellation using Numba module. It will be slower during the first execution",
27 default=True
30 def draw(self, context):
32 from .utils_pip import Pip
33 Pip._ensure_user_site_package()
34 layout = self.layout
35 layout.prop(self, "print_stats")
36 import importlib
37 numba_spec = importlib.util.find_spec('numba')
38 found = numba_spec is not None
39 if found:
40 try:
41 import numba
42 layout.label(text='Numba module installed correctly!', icon='INFO')
43 layout.prop(self, "use_numba_tess")
44 except:
45 found = False
46 if not found:
47 layout.label(text='Numba module not installed!', icon='ERROR')
48 layout.label(text='Installing Numba will make Tissue faster', icon='INFO')
49 row = layout.row()
50 row.operator('scene.tissue_install_numba')
51 layout.label(text='Internet connection required. It may take few minutes', icon='URL')
53 class tissue_install_numba(bpy.types.Operator):
54 bl_idname = "scene.tissue_install_numba"
55 bl_label = "Install Numba"
56 bl_description = ("Install Numba python module")
57 bl_options = {'REGISTER'}
59 def execute(self, context):
60 try:
61 from .utils_pip import Pip
62 #Pip.upgrade_pip()
63 Pip.uninstall('llvmlite')
64 Pip.uninstall('numba')
65 Pip.install('llvmlite')
66 Pip.install('numba')
67 from numba import jit, njit, guvectorize, float64, int32, prange
68 bool_numba = True
69 print('Tissue: Numba successfully installed!')
70 self.report({'INFO'}, 'Tissue: Numba successfully installed!')
71 except:
72 print('Tissue: Numba not loaded correctly. Try restarting Blender')
73 return {'FINISHED'}