-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Support old Blender (version 2.80 to 4.1) again
- Loading branch information
Showing
27 changed files
with
4,391 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# <pep8-80 compliant> | ||
|
||
# ##### 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 ##### | ||
|
||
|
||
NOT_SUPPORTED = False | ||
|
||
if "bpy" in locals(): | ||
import importlib | ||
# pylint: disable=E0601 | ||
# pylint: disable=E0602 | ||
if compat.check_version(2, 79, 0) == 0: | ||
importlib.reload(v279) | ||
elif compat.check_version(2, 80, 0) == 0: | ||
importlib.reload(v280) | ||
elif compat.check_version(2, 81, 0) == 0: | ||
importlib.reload(v281) | ||
elif compat.check_version(2, 82, 0) == 0: | ||
importlib.reload(v282) | ||
elif compat.check_version(2, 83, 0) == 0: | ||
importlib.reload(v283) | ||
elif compat.check_version(2, 90, 0) == 0: | ||
importlib.reload(v290) | ||
elif compat.check_version(2, 91, 0) == 0: | ||
importlib.reload(v291) | ||
elif compat.check_version(2, 92, 0) == 0: | ||
importlib.reload(v292) | ||
elif compat.check_version(2, 93, 0) == 0: | ||
importlib.reload(v293) | ||
elif compat.check_version(3, 0, 0) == 0: | ||
importlib.reload(v30) | ||
elif compat.check_version(3, 1, 0) == 0: | ||
importlib.reload(v31) | ||
elif compat.check_version(3, 2, 0) == 0: | ||
importlib.reload(v32) | ||
elif compat.check_version(3, 3, 0) == 0: | ||
importlib.reload(v33) | ||
elif compat.check_version(3, 4, 0) == 0: | ||
importlib.reload(v34) | ||
elif compat.check_version(3, 5, 0) == 0: | ||
importlib.reload(v35) | ||
elif compat.check_version(3, 6, 0) == 0: | ||
importlib.reload(v36) | ||
elif compat.check_version(4, 0, 0) == 0: | ||
importlib.reload(v40) | ||
elif compat.check_version(4, 1, 0) == 0: | ||
importlib.reload(v41) | ||
else: | ||
importlib.reload(v41) | ||
NOT_SUPPORTED = True | ||
else: | ||
import bpy | ||
from ..utils import compatibility as compat | ||
if compat.check_version(2, 79, 0) == 0: | ||
from .v279 import * | ||
elif compat.check_version(2, 80, 0) == 0: | ||
from .v280 import * | ||
elif compat.check_version(2, 81, 0) == 0: | ||
from .v281 import * | ||
elif compat.check_version(2, 82, 0) == 0: | ||
from .v282 import * | ||
elif compat.check_version(2, 83, 0) == 0: | ||
from .v283 import * | ||
elif compat.check_version(2, 90, 0) == 0: | ||
from .v290 import * | ||
elif compat.check_version(2, 91, 0) == 0: | ||
from .v291 import * | ||
elif compat.check_version(2, 92, 0) == 0: | ||
from .v292 import * | ||
elif compat.check_version(2, 93, 0) == 0: | ||
from .v293 import * | ||
elif compat.check_version(3, 0, 0) == 0: | ||
from .v30 import * | ||
elif compat.check_version(3, 1, 0) == 0: | ||
from .v31 import * | ||
elif compat.check_version(3, 2, 0) == 0: | ||
from .v32 import * | ||
elif compat.check_version(3, 3, 0) == 0: | ||
from .v33 import * | ||
elif compat.check_version(3, 4, 0) == 0: | ||
from .v34 import * | ||
elif compat.check_version(3, 5, 0) == 0: | ||
from .v35 import * | ||
elif compat.check_version(3, 6, 0) == 0: | ||
from .v36 import * | ||
elif compat.check_version(4, 0, 0) == 0: | ||
from .v40 import * | ||
elif compat.check_version(4, 1, 0) == 0: | ||
from .v41 import * | ||
else: | ||
from .v41 import * | ||
NOT_SUPPORTED = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
from ctypes import ( | ||
c_void_p, c_char, c_short, c_int, c_int8, | ||
addressof, cast, pointer, | ||
Structure, | ||
POINTER, | ||
) | ||
|
||
|
||
class Link(Structure): | ||
"""Defined in source/blender/makesdna/DNA_listBase.h""" | ||
|
||
|
||
# pylint: disable=W0212 | ||
Link._fields_ = [ | ||
("next", POINTER(Link)), # struct Link | ||
("prev", POINTER(Link)), # struct Link | ||
] | ||
|
||
|
||
class ListBase(Structure): | ||
# pylint: disable=W0201 | ||
"""Defined in source/blender/makesdna/DNA_listBase.h""" | ||
|
||
def remove(self, vlink): | ||
"""Ref: BLI_remlink""" | ||
|
||
link = vlink | ||
if not vlink: | ||
return | ||
|
||
if link.next: | ||
link.next.contents.prev = link.prev | ||
if link.prev: | ||
link.prev.contents.next = link.next | ||
|
||
if self.last == addressof(link): | ||
self.last = cast(link.prev, c_void_p) | ||
if self.first == addressof(link): | ||
self.first = cast(link.next, c_void_p) | ||
|
||
def find(self, number): | ||
"""Ref: BLI_findlink""" | ||
|
||
link = None | ||
if number >= 0: | ||
link = cast(c_void_p(self.first), POINTER(Link)) | ||
while link and number != 0: | ||
number -= 1 | ||
link = link.contents.next | ||
return link.contents if link else None | ||
|
||
def insert_after(self, vprevlink, vnewlink): | ||
"""Ref: BLI_insertlinkafter""" | ||
|
||
prevlink = vprevlink | ||
newlink = vnewlink | ||
|
||
if not newlink: | ||
return | ||
|
||
def gen_ptr(link): | ||
if isinstance(link, (int, type(None))): | ||
return cast(c_void_p(link), POINTER(Link)) | ||
else: | ||
return pointer(link) | ||
|
||
if not self.first: | ||
self.first = self.last = addressof(newlink) | ||
return | ||
|
||
if not prevlink: | ||
newlink.prev = None | ||
newlink.next = gen_ptr(self.first) | ||
newlink.next.contents.prev = gen_ptr(newlink) | ||
self.first = addressof(newlink) | ||
return | ||
|
||
if self.last == addressof(prevlink): | ||
self.last = addressof(newlink) | ||
|
||
newlink.next = prevlink.next | ||
newlink.prev = gen_ptr(prevlink) | ||
prevlink.next = gen_ptr(newlink) | ||
if newlink.next: | ||
newlink.next.prev = gen_ptr(newlink) | ||
|
||
|
||
# pylint: disable=W0212 | ||
ListBase._fields_ = [ | ||
("first", c_void_p), | ||
("last", c_void_p), | ||
] | ||
|
||
|
||
# pylint: disable=C0103 | ||
class wmWindow(Structure): | ||
"""Defined in source/blender/makesdna/DNA_windowmanager_types.h""" | ||
|
||
|
||
# pylint: disable=W0212 | ||
wmWindow._fields_ = [ | ||
("next", POINTER(wmWindow)), | ||
("prev", POINTER(wmWindow)), | ||
|
||
("ghostwin", c_void_p), | ||
|
||
("screen", c_void_p), # struct bScreen | ||
("newscreen", c_void_p), # struct bScreen | ||
("screenname", c_char * 64), | ||
|
||
("posx", c_short), | ||
("posy", c_short), | ||
("sizex", c_short), | ||
("sizey", c_short), | ||
("windowstate", c_short), | ||
("monitor", c_short), | ||
("active", c_short), | ||
("cursor", c_short), | ||
("lastcursor", c_short), | ||
("modalcursor", c_short), | ||
("grabcursor", c_short), | ||
("addmousemove", c_short), | ||
("multisamples", c_short), | ||
("pad", c_short * 3), | ||
|
||
("winid", c_int), | ||
|
||
("lock_pie_event", c_short), | ||
("last_pie_event", c_short), | ||
|
||
("eventstate", c_void_p), # struct wmEvent | ||
|
||
("curswin", c_void_p), # struct wmSubWindow | ||
|
||
("tweak", c_void_p), # struct wmGesture | ||
|
||
("ime_data", c_void_p), # struct wmIMEData | ||
|
||
("drawmethod", c_int), | ||
("drawfail", c_int), | ||
("drawdata", ListBase), | ||
|
||
("queue", ListBase), | ||
("handlers", ListBase), | ||
("modalhandlers", ListBase), | ||
|
||
("subwindows", ListBase), | ||
("gesture", ListBase), | ||
|
||
("stereo3d_format", c_void_p), # struct Stereo3dFormat | ||
] | ||
|
||
|
||
# pylint: disable=C0103 | ||
class wmOperator(Structure): | ||
"""Defined in source/blender/makesdna/DNA_windowmanager_types.h""" | ||
|
||
|
||
# pylint: disable=W0212 | ||
wmOperator._fields_ = [ | ||
("next", POINTER(wmOperator)), | ||
("prev", POINTER(wmOperator)), | ||
|
||
("idname", c_char * 64), | ||
("properties", c_void_p), # IDProperty | ||
|
||
("type", c_void_p), # struct wmOperatorType | ||
("customdata", c_void_p), | ||
("py_instance", c_void_p), | ||
|
||
("ptr", c_void_p), # struct PointerRNA | ||
("reports", c_void_p), # struct ReportList | ||
|
||
("macro", ListBase), | ||
("opm", POINTER(wmOperator)), | ||
("layout", c_void_p), # struct uiLayout | ||
("flag", c_short), | ||
("_pad", c_short * 3), | ||
] | ||
|
||
|
||
# pylint: disable=C0103 | ||
class wmEventHandler(Structure): | ||
"""Defined in source/blender/windowmanager/wm_event_system.h""" | ||
|
||
|
||
# pylint: disable=W0212 | ||
wmEventHandler._fields_ = [ | ||
# from struct wmEventHandler | ||
("next", POINTER(wmEventHandler)), | ||
("prev", POINTER(wmEventHandler)), | ||
|
||
("type", c_int8), # enum eWM_EventHandlerType | ||
("flag", c_char), | ||
|
||
("keymap", c_void_p), # struct wmKeyMap | ||
("bblocal", c_void_p), # struct rcti | ||
("bbwin", c_void_p), # struct rcti | ||
|
||
# from struct wmEventHandler_Op | ||
("op", POINTER(wmOperator)), | ||
] |
Oops, something went wrong.