Commit Graph

418 Commits

Author SHA1 Message Date
rdb 99225dfaef shader: Unify ShaderPtrSpec and ShaderMatSpec mechanisms 2024-08-23 16:29:42 +02:00
rdb dfc85b8a68 tests: Make shadowViewMatrix test less sensitive 2024-08-23 16:28:10 +02:00
rdb a8ca06ea47 tests: Don't fail Dial test if tkinter failed to import 2024-08-23 14:20:38 +02:00
rdb e2ad8f2a2f tests: Test additional properties of light source struct 2024-08-23 14:20:35 +02:00
rdb d5d0b80dd3 tests: Add unit tests for GLSL light, material, fog structs 2024-08-23 12:35:01 +02:00
John C. Allwein 21b39da65d pythonTask: fix refcount leak of non-panda Future::done
A missing Py_DECREF on the future's "done" method
caused both the bound method and the underlying
self instance of the future to be leaked when
awaiting non-panda futures (such as _asyncio.Future).

This change includes a simple new test addition
to catch this in the future.
2024-08-08 21:51:03 -06:00
rdb ad57762e9f Merge branch 'release/1.10.x' 2024-08-07 22:34:08 +02:00
rdb 8c8cbeea98 linmath: For repr, use as much precision as needed for roundtrip
Will use as few digits as is necessary to ensure that round-tripping the same number with pstrtod will result in the same vector.  This prevents eg. 3.3 formatting as 3.29999995 while still ensuring that two floats that are not equal (other than nan) are guaranteed to have a different string representation.

Uses a hacky pftoa function that can be abandoned as soon as we adopt C++17, which has to_chars that does what we need

Fixes #1671
2024-08-07 17:24:11 +02:00
rdb b6ec48b27c Fix invalid metadata version 2.0 (should be 2.1) 2024-05-28 22:28:37 +02:00
rdb 96e2e7d357 tests: Remove testing for AssertionError
This crashes with `assert-abort` and doesn't work with release builds
2024-03-29 20:57:36 +01:00
rdb e5bd00f91f task: Implement garbage collector support for PythonTask
This adds persistent wrapper support (introduced by the previous commit) to PythonTask, which makes it possible for reference cycles involving tasks to be found and destroyed.

The major caveat is that it always creates a reference cycle.  This can be broken automatically if there is no more Python reference to it by the time the last C++ reference is dropped, but the other way around requires the garbage collector.

For tasks, I think this it is generally the case that the last reference is in C++, since tasks are usually created and then handed off to the C++ task manager, and for applications that don't want to rely on the GC, it is easy to work around.  If this turns out to be a problem, though, we can add a special garbage collection pass to the task manager.
2024-03-29 20:51:45 +01:00
rdb 38692dd525 interrogate: Support subclassing C++ objects from Python
This change enables persistent Python wrapper objects for Python subclasses of typed, reference counted C++ objects.  That means that these objects will store a reference to `self` on the C++ object, and interrogate will always return that instead of making a new Python wrapper every time it is returned from C++.

Practically, this means that you could subclass eg. PandaNode, Event, Fog, what have you, and store these in the scene graph - the Python data in the subclass will be retained and Panda will return your subclass when you ask for the object back rather than creating a new wrapper object without your original data.

To do this, Interrogate generates a proxy class inheriting from the C++ type with additional room to store a `self` pointer and a TypeHandle (which is returned by an overridden `get_type()`).  This TypeHandle is automatically created by registering the Python subclass with the typing system.  The proxy class is only used when the constructor detects that it's constructing for a subtype, so that regular uses of the C++ type are not affected by this mechanism.

(The registration with the typing system could use some improvement.  There's no regard for namespacing right now, in particular.  Furthermore, we could move the registration to an `__init_subclass__()` method, with parameters to specify an existing TypeHandle or to customize the type name.)

This creates a reference cycle, which must be cleared somehow.  One way this happens is by overriding `unref()` in the proxy, which checks that if the Python and C++ reference counts are both 1, this must be the circular reference, and then it breaks the cycle.  Note that this will _only_ work if all other Python references have been cleared before the last C++ reference goes away.  For the other case, we need to rely on Python's garbage collector, so these classes also implement tp_traverse and tp_clear.

This commit also therefore re-enables Python garbage collector support (ie. defining `__traverse__()`), which was previously disabled due to the problems caused by multiple Python wrappers referring to the same C++ object.  To avoid these problems, Panda will only cooperate with Python's GC if the C++ reference count is 1, in which case we can trivially prove that the last reference must be from the Python wrapper.  Note that this explains why we need persistent wrappers for traversal to work--if there are multiple Python wrappers pointing to the C++ object, and they are all participating in a reference cycle, the reference count cannot be 1, and cycle detection does not work.  By default, the GC is only enabled for Python subclasses, but a class may define `__traverse__()` in order to opt-in, keeping the previous limitation in mind.

There is a second mechanism introduced by this commit: classes may define a public `__self__` member of type `PyObject *` if they want to use persistent objects even if they aren't being subclassed.  This allows these classes to participate in Python's GC and avoid the situation above.

The cycle detection is implemented for PandaNode's Python tags, but this is very incomplete, since the traversal doesn't recurse into children and it won't work if there is more than one wrapper object that is part of a cycle, since PandaNode by default doesn't use persistent wrappers.  This problem may need more attention later.

Fixes #1410
2024-03-29 20:51:34 +01:00
rdb b605e1240c tests: Add unit test to check new panda3d.net module 2024-03-02 13:41:23 +01:00
rdb 84ed141b2a Squash merge webgl-port branch into master
Adds support for emscripten as a build target / platform, and adds a WebGL renderer back-end
2024-01-25 15:37:38 +01:00
rdb ecc1e30ef6 Merge branch 'release/1.10.x' 2024-01-23 16:56:38 +01:00
rdb 8c74919a8b dgui: Make copy of mutable default value
Fixes #1587
2024-01-23 14:51:44 +01:00
rdb 9145b6c729 Merge branch 'release/1.10.x' 2024-01-04 16:36:03 +01:00
rdb edf4b7d448 tests: Also skip Cg unit tests on arm64 reporting as aarch64
[skip ci]
2023-10-22 12:24:33 +02:00
rdb 4bdf85348f tests: Don't expect mypy to be on the system PATH 2023-10-22 10:39:41 +02:00
WMOkiishi 0380a60e58
tests: Fix mypy test (#1551) 2023-10-22 10:34:46 +02:00
rdb 277460061e Merge branch 'release/1.10.x' 2023-10-15 23:02:47 +02:00
rdb 3059f8f76b tests: Add site.py file for deploy-stub test 2023-10-15 16:23:02 +02:00
rdb cb7f25f59c tests: Fix an issue running tests with some Python 3.4 setups 2023-10-15 16:21:30 +02:00
rdb 479774477b tests: Compat w/ older pytest by using tmpdir instead of tmp_path 2023-10-15 14:48:01 +02:00
rdb a6ab238abc Merge branch 'release/1.10.x' into incoming 2023-10-14 21:35:00 +02:00
rdb 1db6dbc166 tests: Don't cache loaded test model 2023-10-14 21:24:22 +02:00
rdb 476374b814 tests: Don't run tkpanels.Placer test without Tk already inited
Necessary for being able to run test suite on macOS
2023-10-14 20:07:35 +02:00
rdb f9c213fcbb tests: Run runtime executable generated by FreezeTool test 2023-10-14 17:35:16 +02:00
rdb b2465c3b38 tests: Fix running tests on Windows and with Python 2.7 2023-10-14 17:31:35 +02:00
rdb 972c0009ac workflow: Add setuptools as requirement when testing Python 3.12 2023-10-14 11:29:02 +02:00
rdb c1c035d5c9 showbase: Switch Loader entry point detection to importlib.metadata
Only in Python 3.8 and up, where this module is available, otherwise it falls back to pkg_resources

Add unit test for custom entry point loaders
2023-10-14 11:27:46 +02:00
rdb f24a18f45e tests: Add unit test for `Freezer.generateRuntimeFromStub` 2023-10-14 09:55:37 +02:00
rdb e01cb590de Merge branch 'release/1.10.x' 2023-10-13 23:24:48 +02:00
WMOkiishi 098fe634a5
task: Annotate core functions (#1548) 2023-10-13 21:20:20 +02:00
rdb 2a5228b05f Fix compatibility with Python 3.12 by removing use of imp module
Some modules (such as VFSImporter, and various modules in direct.p3d that depend on it) are still unavailable.
2023-10-13 13:21:34 +02:00
rdb 225b577ccd tests: Skip Cg tests on arm64 machines 2023-10-13 10:55:17 +02:00
Mitchell Stokes 893f5ce492 Fix assert on Py_SIZE(long) when using Python 3.12
Starting with Python 3.12, passing a PyLong into Py_SIZE() triggers an
assertion. PyLong (and the whole C API) is transitioning to be more
opaque and expose fewer implementation details.
2023-10-13 10:54:33 +02:00
WMOkiishi 1ca0e3f1ea
directnotify: annotate types (#1527) 2023-10-09 09:46:32 +02:00
Christopher He cbfd8f4545
collide: Add CollisionHeightfield solid (#691) 2023-08-05 21:14:52 +02:00
rdb c203b0f786 tests: Don't require tkinter to be able to run test suite 2023-08-05 10:29:32 +02:00
WMOkiishi 32edfa43fd direct: Get direct to pass a mypy check
Closes #1476
2023-08-04 14:31:44 +02:00
rdb f80cd08993 Remove support for EOL Python versions 3.6 and 3.7 2023-08-04 14:20:59 +02:00
rdb a68ecb9765 Merge branch 'release/1.10.x' 2023-08-04 14:07:41 +02:00
rdb 3f3819e7fa tests: Further expand on tools tests 2023-08-03 13:21:38 +02:00
rdb 4537540820 tests: Look for tools in proper location without relying on PATH 2023-08-02 16:45:40 +02:00
rdb 1cb2554c48 tests: Test that tools run when testing wheels
Intended to catch issues like #1504
2023-08-02 16:36:04 +02:00
WMOkiishi f7f3179a89 Move test code from across `direct` to proper test modules
Closes #1480
2023-08-02 08:37:51 +02:00
rdb 115a716a7d Implement support for custom TypedWritable subclasses in Python
Fixes #1495
2023-07-26 19:55:40 +02:00
rdb f3d51fd72c tests: Don't rely on png being available for TexturePool tests
Instead, use SGI image format, support for which is generally enabled in Panda
2023-02-24 23:01:40 +01:00
rdb 868a4eac47 tests: Fix test_imports_panda3d for frozen/embedded panda3d package 2023-02-24 22:39:55 +01:00
rdb 82a79acdd5 tests: Fix OverflowError in test_format_arrays on 32-bit
This is actually a bug in interrogate - it's converting an unsigned size_t via Py_ssize_t, which is not correct.  However, it's a bunch of trouble to fix that.

Cherry-picked from 84ada4d66b
2023-02-24 22:07:38 +01:00
rdb 6860c7776b tests: Fix unit test suite when building without physics or net 2023-02-23 00:20:53 +01:00
rdb 86ceade7b3 tests: Skip encrypt_string test when building without OpenSSL 2023-02-22 23:31:32 +01:00
rdb 84ada4d66b tests: Fix OverflowError in test_format_arrays on 32-bit
This is actually a bug in interrogate - it's converting an unsigned size_t via Py_ssize_t, which is not correct.  However, it's a bunch of trouble to fix that.
2023-02-22 23:29:37 +01:00
rdb 2e21cf87e4 tests: Skip test_task_cancel_waiting() test if no threads enabled 2023-02-22 23:18:23 +01:00
rdb a63bbba4c1 tests: Add HashVal md5 unit test that doesn't rely on hashlib 2023-02-22 21:55:26 +01:00
rdb 11c7d38ce4 tests: Remove executable permissions from test_property.py
[skip ci]
2023-02-22 18:20:39 +01:00
rdb 35348fd74a express: Do not rely on OpenSSL for MD5 hash support
These hashes are used in various places in the Panda codebase (for integrity checks, not for crypto), so using an internal implementation allows retaining this functionality when building Panda without OpenSSL.

Based on the following public domain implementation:
https://github.com/B-Con/crypto-algorithms
2023-02-22 16:47:14 +01:00
rdb 5d63c7e898 Merge branch 'release/1.10.x' 2023-02-20 19:27:58 +01:00
rdb 2e7dc9e4f4 tests: Add unit test for GeomVertexFormat arrays list 2023-02-20 19:05:37 +01:00
Timothy Paustian 50de135641
task: Fix re-adding task object removing extraArgs (#1132)
Fixes #1097
2023-02-13 10:58:02 +01:00
git2323 518d4777fa
do not prefer framebuffer configs with excessive multisamples (#1456)
Co-authored-by: user1 <user1@user1.org>
2023-02-12 23:04:46 +00:00
Rishabh Tewari dcd2aa83d4 tests: Added video and audio tests
Closes #663
2023-02-07 18:08:32 +01:00
rdb fed5865645 tests: Add unit tests for #1105 2023-02-07 12:24:54 +01:00
rdb 92185bcb28 Merge branch 'release/1.10.x' 2022-12-19 16:42:29 +01:00
rdb 896346b99f gobj: Implement `copy.deepcopy()` for Texture class
Actually ensures that the underlying RAM images are really fully unique.
2022-12-19 16:22:33 +01:00
rdb e67cd74725 express: Implement `copy.deepcopy()` for PointerToArray
It actually makes a unique copy of the underlying array.
2022-12-19 16:22:00 +01:00
rdb 7a55c723ba Merge branch 'release/1.10.x' 2022-12-04 19:28:03 +01:00
rdb 41f0c9d48d pgraph: Support None as second arg of replace_texture/replace_material
This removes the relevant texture or material
2022-12-04 19:24:04 +01:00
rdb d621df47ac prc: Fix bf-cbc encryption/decryption regression with OpenSSL 3.0
Loads the legacy provider to continue supporting this algorithm
2022-12-04 19:22:26 +01:00
rdb e961ea99ac Merge branch 'release/1.10.x' 2022-11-13 12:10:38 +01:00
rdb 0220a43ce0 shader: Fix support for `#pragma include <example.glsl>` in GLSL 2022-11-09 17:20:11 +01:00
rdb 63017864ab pgraph: Support any number of attribs in `RenderState::make()` in Python 2022-11-07 18:17:48 +01:00
rdb 4c58eb3382 tests: Replace use of deprecated imp module in test_imports 2022-10-31 23:21:54 +01:00
rdb 316b0009ae Merge branch 'release/1.10.x' 2022-10-31 23:10:39 +01:00
rdb 4c6df54d6f tests: Fix failing window unit test on macOS
Fixes #804 (together with previous commit 979f194f49)
2022-10-29 18:47:15 +02:00
rdb 979f194f49 tests: Load either 120 or 150 GLSL shaders depending on capabilities
Addresses part of #804
2022-10-29 18:46:59 +02:00
rdb a111bb4442 tests: skip auto-shader tests if Cg shaders are not supported
Backport of 57b0be8647
2022-10-29 18:16:58 +02:00
rdb 2a0da59dae tests: Add more tests for sphere-into-box 2022-10-05 14:55:46 +02:00
Derzsi Dániel d79709f004
express: Add support for bytes multifile encryption passwords (#1334) 2022-07-20 22:50:06 +02:00
rdb 20334cce05 Merge branch 'release/1.10.x' 2022-06-29 19:09:59 +02:00
Stephen A. Imhoff 33691d72ec bullet: Fix assertion when reconstructing BulletConvexHullShape from bam
Fixes #1251
Closes #1252
2022-06-29 17:06:19 +02:00
rdb 4df8c86590 tests: Add unit test for PandaNode prev_transform tracking mechanism 2022-02-24 11:43:44 +01:00
rdb 5695d1a719 tests: Add separate unit test for AsyncFuture.wait() with timeout
Since it's using a different implementation than the no-timeout version now
2022-02-24 11:43:11 +01:00
rdb a33fcab8da tests: Switch from deprecated ConditionVarFull to ConditionVar 2022-02-22 15:22:10 +01:00
rdb 7a2a83572c Merge branch 'release/1.10.x' 2022-01-05 08:50:11 +01:00
rdb d65ca1edd6 pgraph: Fix nodes with same key but diff value getting flattened
This was a regression from 69b3468b2c
2022-01-05 08:14:08 +01:00
rdb 60c5589671 pgraph: Optimize handling/checking of identity/invalid transforms 2021-11-16 17:30:36 +01:00
rdb a4ea476cce linmath: Implement read-only buffer protocol support for vectors
Fixes #1194
2021-10-27 10:53:35 +02:00
rdb 0ae8d8f315 tests: Robustify depth range test case 2021-08-31 14:02:49 +02:00
rdb 53741ffa13 pgraph: Implement new DepthBiasAttrib to replace DepthOffsetAttrib
Fixes #1157
2021-08-26 10:47:07 +02:00
rdb 280175f267 display: Support specifying depth range on DisplayRegion
See https://discourse.panda3d.org/t/depthoffsetattrib-z-range-composition-order/27943/4
2021-08-26 10:42:25 +02:00
rdb c293ad3da2 Merge branch 'release/1.10.x' 2021-08-03 20:19:15 +02:00
rdb f30019af13 tests: xfail vector floor division tests on Windows
Can't figure this one out for now.
2021-08-03 15:49:11 +02:00
rdb f27e9b2a86 linmath: Add __rmul__ operator for left scalar multiplication
Fixes #1048
2021-07-05 14:16:55 +02:00
rdb 199b797d72 Merge branch 'release/1.10.x' 2021-06-01 11:50:12 +02:00
rdb 5804c663a9 tests: Backport unit test fix from c0d3491223 2021-06-01 11:47:19 +02:00
rdb 2386e80448 linmath: Backport support for floor division to 1.10
Backport of 8944737844

(Also fixes return type of `__pow__` to always be derived class)
2021-06-01 10:45:56 +02:00
rdb 4e0e945279 linmath: Backport round(), floor(), ceil() support for vectors
See #821
2021-06-01 10:23:58 +02:00
rdb 5ef1b44455 event: cancel future being awaited when cancelling coroutine task
Fixes #1136
2021-04-18 17:05:00 +02:00