-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
123 lines (102 loc) · 3.84 KB
/
Copy path__init__.py
File metadata and controls
123 lines (102 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
"""
# support reloading
if "bpy" in locals():
import importlib
if "calculation" in locals():
importlib.reload(calculation)
if "operators" in locals():
importlib.reload(operators)
if "panels" in locals():
importlib.reload(panels)
if "properties" in locals():
importlib.reload(properties)
if "opengl" in locals():
importlib.reload(opengl)
"""
import bpy
from bpy.props import PointerProperty
from . import calculation, operators, panels, properties
# print("Solar System Simulator: Successfully imported all submodules")
# =============================================================================
# Registration
# =============================================================================
classes = (
operators.SCENE_OT_add_sim_time_fcurve,
operators.OBJECT_OT_sssim_to_fcurve,
operators.OBJECT_OT_sssim_clear_fcurve,
operators.SCENE_OT_update_sssim_drivers,
operators.OBJECT_OT_add_orbit_curve,
operators.OBJECT_OT_sssim_create_center,
operators.OBJECT_OT_sssim_create_planet,
operators.OBJECT_OT_sssim_create_surface,
operators.OBJECT_OT_sssim_bake_all,
operators.OBJECT_OT_sssim_bake_clear,
panels.SSSIM_PT_object,
panels.SSSIM_PT_orbit,
panels.SSSIM_PT_rotation,
panels.SSSIM_PT_surface,
panels.SSSIM_PT_calculation,
panels.SSSIM_PT_scene,
panels.SSSIM_PT_tools,
properties.SSSIMObject,
properties.SSSIMOrbit,
properties.SSSIMRotation,
properties.SSSIMCalculation,
properties.SSSIMSurface,
properties.SSSIMScene,
)
def register():
for cla in classes:
bpy.utils.register_class(cla)
obj = bpy.types.Object
obj.sssim_obj = PointerProperty(type=properties.SSSIMObject)
obj.sssim_orbit = PointerProperty(type=properties.SSSIMOrbit)
obj.sssim_rotation = PointerProperty(type=properties.SSSIMRotation)
obj.sssim_calc = PointerProperty(type=properties.SSSIMCalculation)
obj.sssim_surface = PointerProperty(type=properties.SSSIMSurface)
bpy.types.Scene.sssim_scn = PointerProperty(type=properties.SSSIMScene)
# add custom drivers for the location and rotation to driver namespace
drv = bpy.app.driver_namespace
drv["eval_planet_orbit"] = calculation.eval_planet_orbit
drv["eval_planet_rotation"] = calculation.eval_planet_rotation
bpy.types.PHYSICS_PT_add.append(panels.physics_panel)
def unregister():
bpy.types.PHYSICS_PT_add.remove(panels.physics_panel)
# remove the drivers if any
drv = bpy.app.driver_namespace
if "eval_planet_orbit" in drv:
del drv["eval_planet_orbit"]
if "eval_planet_rotation" in drv:
del drv["eval_planet_rotation"]
# remove drawing callbacks in all scenes
for scn in bpy.data.scenes:
scn.sssim_scn.draw_orbit = False
obj = bpy.types.Object
del obj.sssim_obj
del obj.sssim_orbit
del obj.sssim_rotation
del obj.sssim_calc
del obj.sssim_surface
del bpy.types.Scene.sssim_scn
for cla in classes:
bpy.utils.unregister_class(cla)
if __name__ == "__main__":
register()