diff --git a/direct/src/dist/FreezeTool.py b/direct/src/dist/FreezeTool.py index 4390197036..a8d37d07bc 100644 --- a/direct/src/dist/FreezeTool.py +++ b/direct/src/dist/FreezeTool.py @@ -211,7 +211,7 @@ class CompilationEnvironment: self.linkDll = 'link /nologo /DLL /MAP:NUL /FIXED:NO /OPT:REF /INCREMENTAL:NO /LIBPATH:"%(PSDK)s\\lib" /LIBPATH:"%(MSVC)s\\lib%(suffix64)s" /LIBPATH:"%(python)s\\libs" /out:%(basename)s%(dllext)s.pyd %(basename)s.obj' elif self.platform.startswith('osx_'): - # OSX + # macOS proc = self.platform.split('_', 1)[1] if proc == 'i386': self.arch = '-arch i386' @@ -219,6 +219,8 @@ class CompilationEnvironment: self.arch = '-arch ppc' elif proc == 'amd64': self.arch = '-arch x86_64' + elif proc in ('arm64', 'aarch64'): + self.arch = '-arch arm64' self.compileObjExe = "gcc -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s" self.compileObjDll = "gcc -fPIC -c %(arch)s -o %(basename)s.o -O2 -I%(pythonIPath)s %(filename)s" self.linkExe = "gcc %(arch)s -o %(basename)s %(basename)s.o -framework Python" diff --git a/direct/src/gui/OnscreenGeom.py b/direct/src/gui/OnscreenGeom.py index ac4f93a418..5c5efbbc32 100644 --- a/direct/src/gui/OnscreenGeom.py +++ b/direct/src/gui/OnscreenGeom.py @@ -42,8 +42,9 @@ class OnscreenGeom(DirectObject, NodePath): """ # We ARE a node path. Initially, we're an empty node path. NodePath.__init__(self) - if parent == None: - parent = aspect2d + if parent is None: + from direct.showbase import ShowBaseGlobal + parent = ShowBaseGlobal.aspect2d self.setGeom(geom, parent = parent, sort = sort, color = color) diff --git a/direct/src/gui/OnscreenImage.py b/direct/src/gui/OnscreenImage.py index e5a3944178..e6fe258c32 100644 --- a/direct/src/gui/OnscreenImage.py +++ b/direct/src/gui/OnscreenImage.py @@ -48,8 +48,9 @@ class OnscreenImage(DirectObject, NodePath): # We ARE a node path. Initially, we're an empty node path. NodePath.__init__(self) - if parent == None: - parent = aspect2d + if parent is None: + from direct.showbase import ShowBaseGlobal + parent = ShowBaseGlobal.aspect2d self.setImage(image, parent = parent, sort = sort) # Adjust pose diff --git a/direct/src/gui/OnscreenText.py b/direct/src/gui/OnscreenText.py index c26e7033b7..304bb8e800 100644 --- a/direct/src/gui/OnscreenText.py +++ b/direct/src/gui/OnscreenText.py @@ -103,8 +103,9 @@ class OnscreenText(NodePath): direction: this can be set to 'ltr' or 'rtl' to override the direction of the text. """ - if parent == None: - parent = aspect2d + if parent is None: + from direct.showbase import ShowBaseGlobal + parent = ShowBaseGlobal.aspect2d # make a text node textNode = TextNode('') diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 5c7fdcae74..b2a2e92f25 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -187,7 +187,7 @@ def parseopts(args): anything = 0 optimize = "" target = None - target_arch = None + target_archs = [] universal = False clean_build = False for pkg in PkgListGet(): @@ -214,7 +214,7 @@ def parseopts(args): elif (option=="--osxtarget"): OSXTARGET=value.strip() elif (option=="--universal"): universal = True elif (option=="--target"): target = value.strip() - elif (option=="--arch"): target_arch = value.strip() + elif (option=="--arch"): target_archs.append(value.strip()) elif (option=="--nocolor"): DisableColors() elif (option=="--version"): match = re.match(r'^\d+\.\d+(\.\d+)+', value) @@ -273,12 +273,17 @@ def parseopts(args): if (optimize==""): optimize = "3" if OSXTARGET: + parts = OSXTARGET.strip().split('.') try: - maj, min = OSXTARGET.strip().split('.') - OSXTARGET = int(maj), int(min) - assert OSXTARGET[0] >= 10 + assert len(parts) <= 2 + maj = int(parts[0]) + min = 0 + if len(parts) > 1: + min = int(parts[1]) + OSXTARGET = maj, min + assert OSXTARGET >= (10, 4) except: - usage("Invalid setting for OSXTARGET") + usage("Invalid setting for --osxtarget") if OSXTARGET < (10, 9): warn_prefix = "%sERROR:%s " % (GetColor("red"), GetColor()) @@ -293,11 +298,11 @@ def parseopts(args): else: OSXTARGET = None - if target is not None or target_arch is not None: - SetTarget(target, target_arch) + if target is not None or target_archs: + SetTarget(target, target_archs[-1] if target_archs else None) if universal: - if target_arch: + if target_archs: exit("--universal is incompatible with --arch") if OSXTARGET: @@ -311,8 +316,11 @@ def parseopts(args): if osxver >= (11, 0): OSX_ARCHS.append("arm64") - elif HasTargetArch(): - OSX_ARCHS.append(GetTargetArch()) + elif target_archs: + OSX_ARCHS = target_archs + + if 'arm64' in target_archs and OSXTARGET and OSXTARGET < (10, 9): + exit("Must have at least --osxtarget 10.9 when targeting arm64") try: SetOptimize(int(optimize)) @@ -412,6 +420,10 @@ elif target == 'darwin': if osxver < (10, 9): osxver = (10, 9) + if osxver[0] == 11: + # I think Python pins minor version to 0 from macOS 11 onward + osxver = (osxver[0], 0) + arch_tag = None if not OSX_ARCHS: arch_tag = GetTargetArch() @@ -515,7 +527,7 @@ MakeBuildTree() SdkLocateDirectX(STRDXSDKVERSION) SdkLocateMaya() SdkLocateMax() -SdkLocateMacOSX(OSXTARGET) +SdkLocateMacOSX(OSXTARGET, OSX_ARCHS) SdkLocatePython(False) SdkLocateWindows(WINDOWS_SDK) SdkLocateSpeedTree() @@ -788,6 +800,18 @@ if (COMPILER=="GCC"): if GetTarget() != "darwin": PkgDisable("COCOA") + if GetTarget() == 'darwin': + if 'x86_64' not in OSX_ARCHS and 'i386' not in OSX_ARCHS: + # These support only these archs, so don't build them if we're not + # targeting any of the supported archs. + PkgDisable("FMODEX") + PkgDisable("NVIDIACG") + elif (OSX_ARCHS and 'arm64' in OSX_ARCHS) or \ + (OSXTARGET and OSXTARGET >= (10, 14)) or \ + (not OSXTARGET and not os.path.isfile('/usr/lib/libstdc++.6.0.9.dylib')): + # Also, we can't target FMOD Ex with the 10.14 SDK + PkgDisable("FMODEX") + #if (PkgSkip("PYTHON")==0): # IncDirectory("PYTHON", SDK["PYTHON"]) if (GetHost() == "darwin"): @@ -1295,6 +1319,8 @@ def CompileCxx(obj,src,opts): if OSXTARGET is not None: cmd += " -isysroot " + SDK["MACOSX"] cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET) + elif platform.mac_ver()[0].startswith('11.'): + cmd += " -mmacosx-version-min=11.0" # Use libc++ to enable C++11 features. cmd += " -stdlib=libc++" @@ -1814,6 +1840,8 @@ def CompileLink(dll, obj, opts): if OSXTARGET is not None: cmd += " -isysroot " + SDK["MACOSX"] + " -Wl,-syslibroot," + SDK["MACOSX"] cmd += " -mmacosx-version-min=%d.%d" % (OSXTARGET) + elif platform.mac_ver()[0].startswith('11.'): + cmd += " -mmacosx-version-min=11.0" # Use libc++ to enable C++11 features. cmd += " -stdlib=libc++" @@ -2479,8 +2507,19 @@ def WriteConfigSettings(): conf = "/* dtool_config.h. Generated automatically by makepanda.py */\n" for key in sorted(dtool_config.keys()): val = OverrideValue(key, dtool_config[key]) - if (val == 'UNDEF'): conf = conf + "#undef " + key + "\n" - else: conf = conf + "#define " + key + " " + val + "\n" + + if key in ('HAVE_CG', 'HAVE_CGGL', 'HAVE_CGDX9') and val != 'UNDEF': + # These are not available for ARM, period. + conf = conf + "#ifdef __aarch64__\n" + conf = conf + "#undef " + key + "\n" + conf = conf + "#else\n" + conf = conf + "#define " + key + " " + val + "\n" + conf = conf + "#endif\n" + elif val == 'UNDEF': + conf = conf + "#undef " + key + "\n" + else: + conf = conf + "#define " + key + " " + val + "\n" + ConditionalWriteFile(GetOutputDir() + '/include/dtool_config.h', conf) if (PkgSkip("SPEEDTREE")==0): diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 304c88ab3a..4cc7549628 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -2345,10 +2345,17 @@ def SdkLocateWindows(version=None): else: print("Using Windows SDK %s" % (version)) -def SdkLocateMacOSX(osxtarget = None): +def SdkLocateMacOSX(osxtarget = None, archs = []): if (GetHost() != "darwin"): return if (osxtarget != None): - sdkname = "MacOSX%d.%d" % osxtarget + if osxtarget < (11, 0) and 'arm64' in archs: + # Building for arm64 requires the 11.0 SDK, with which we can still + # target 10.9. + assert osxtarget >= (10, 9) + sdkname = "MacOSX11.0" + else: + sdkname = "MacOSX%d.%d" % osxtarget + if (os.path.exists("/Library/Developer/CommandLineTools/SDKs/%s.sdk" % sdkname)): SDK["MACOSX"] = "/Library/Developer/CommandLineTools/SDKs/%s.sdk" % sdkname elif (os.path.exists("/Developer/SDKs/%su.sdk" % sdkname)): @@ -2365,8 +2372,10 @@ def SdkLocateMacOSX(osxtarget = None): handle.close() if (os.path.exists("%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (result, sdkname))): SDK["MACOSX"] = "%s/Platforms/MacOSX.platform/Developer/SDKs/%s.sdk" % (result, sdkname) + elif sdkname == "MacOSX11.0" and os.path.exists("/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk"): + SDK["MACOSX"] = "/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk" else: - exit("Couldn't find any MacOSX SDK for OSX version %s!" % sdkname) + exit("Couldn't find any MacOSX SDK for macOS version %s!" % sdkname) else: SDK["MACOSX"] = "" diff --git a/panda/src/device/evdevInputDevice.cxx b/panda/src/device/evdevInputDevice.cxx index 9407650898..db6285ba19 100644 --- a/panda/src/device/evdevInputDevice.cxx +++ b/panda/src/device/evdevInputDevice.cxx @@ -806,23 +806,33 @@ process_events() { button_changed(_dpad_up_button, events[i].value < 0); button_changed(_dpad_up_button+1, events[i].value > 0); } - nassertd(code >= 0 && (size_t)code < _axis_indices.size()) break; - index = _axis_indices[code]; - if (index >= 0) { - axis_changed(index, events[i].value); + if (code >= 0 && (size_t)code < _axis_indices.size()) { + index = _axis_indices[code]; + if (index >= 0) { + axis_changed(index, events[i].value); + } + } + else if (device_cat.is_debug()) { + device_cat.debug() + << "Ignoring EV_ABS event with unknown code " << code << "\n"; } break; case EV_KEY: - nassertd(code >= 0 && (size_t)code < _button_indices.size()) break; - index = _button_indices[code]; - if (index >= 0) { - button_changed(index, events[i].value != 0); + if (code >= 0 && (size_t)code < _button_indices.size()) { + index = _button_indices[code]; + if (index >= 0) { + button_changed(index, events[i].value != 0); + } + if (code == _ltrigger_code) { + axis_changed(_ltrigger_axis, events[i].value); + } else if (code == _rtrigger_code) { + axis_changed(_ltrigger_axis + 1, events[i].value); + } } - if (code == _ltrigger_code) { - axis_changed(_ltrigger_axis, events[i].value); - } else if (code == _rtrigger_code) { - axis_changed(_ltrigger_axis + 1, events[i].value); + else if (device_cat.is_debug()) { + device_cat.debug() + << "Ignoring EV_KEY event with unknown code " << code << "\n"; } break; diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index e55ea41ec8..6529de2f80 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -1627,6 +1627,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, for (; i < cdata->_num_vertices; ++i) { reader.set_row_unsafe(cdata->_first_vertex + i); + nassertv(!reader.is_at_end()); + LPoint3 vertex = mat.xform_point_general(reader.get_data3()); min_point.set(min(min_point[0], vertex[0]), @@ -1653,6 +1655,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, for (; i < cdata->_num_vertices; ++i) { reader.set_row_unsafe(cdata->_first_vertex + i); + nassertv(!reader.is_at_end()); + const LVecBase3 &vertex = reader.get_data3(); min_point.set(min(min_point[0], vertex[0]), @@ -1696,6 +1700,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, continue; } reader.set_row_unsafe(ii); + nassertv(!reader.is_at_end()); + LPoint3 vertex = mat.xform_point_general(reader.get_data3()); min_point.set(min(min_point[0], vertex[0]), @@ -1728,6 +1734,8 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, continue; } reader.set_row_unsafe(ii); + nassertv(!reader.is_at_end()); + const LVecBase3 &vertex = reader.get_data3(); min_point.set(min(min_point[0], vertex[0]),