Commit Graph

394 Commits

Author SHA1 Message Date
rdb e4e5d75df7 tests: Fix mypy, Windows test failures 2025-07-28 22:47:16 +02:00
rdb bd4b3dd1a7 showbase: Rewrite VFSImporter for newer Python import system
Fixes #1718
2025-07-28 20:35:00 +02:00
rdb e57c71d8e4 event: Change result of AsyncFuture gather() to return list
Better matches asyncio gather

See #1738
2025-07-28 15:43:12 +02:00
rdb 9a2da04573 Merge branch 'release/1.10.x' 2025-07-28 15:41:08 +02:00
rdb 5bc9b70e86 event: Make cancel() for regular tasks work like remove()
Fixes #1741
2025-07-28 15:18:03 +02:00
rdb 41e4cf5d11 event: Fix `await gather()` returning first item instead of tuple
Fixes #1738
2025-07-28 14:58:42 +02:00
WMOkiishi 8de98592ca
showbase: Annotate basic `Loader` methods (#1723) 2025-02-19 18:59:19 +01:00
rdb 6452907b64 Improvements for env handling with node.js and emscripten
- Initializes the environment so that getenv et al works properly
- No longer calls JS functions at static init time; the JS preamble will
  pass the right env vars to ExecutionEnvironment
- Sets the binary name to the path of the .js file
2025-02-03 18:06:30 +01:00
rdb f188c8a028 tests: Use approx comparison for test_depth_bias 2025-01-30 11:38:17 +01:00
rdb 1281875cbc linmath: Fix degenerate case in decompose_matrix
Regression in 583f7366db
2025-01-29 17:05:16 +01:00
rdb 3833866801 display: Add method to synchronously download SSBO contents 2025-01-25 18:08:54 +01:00
rdb e43dc87df5 Fix unit test failures on Python 3.13 2024-12-14 15:25:03 +01:00
rdb 5e05049725 collide: Add custom owner field to CollisionNode
This stores a weakref to a custom Python object, useful for being able to look up the game object corresponding to a particular collision node in an event without the downsides of Python tags

Fixes #1703
2024-12-14 12:48:24 +01:00
rdb d173086a6f putil: Fix SparseArray get_lowest_on_bit and get_lowest_off_bit 2024-11-14 20:09:29 +01:00
rdb c3326fa0da tests: Fix node check for other envs 2024-11-06 11:09:50 +01:00
rdb 221d35d3a6 Allow running test suite with emscripten via node.js 2024-11-04 18:40:30 +01:00
rdb 1a4ca179a9 tests: Properly skip Pmw tests when tkinter is not present 2024-11-04 13:19:38 +01:00
rdb 957c4b9bce Merge branch 'release/1.10.x' into master 2024-10-30 18:40:32 +01:00
rdb 6d54aee0c7 Remove runtime dependency on interrogatedb 2024-10-30 17:46:26 +01:00
rdb 6010c711c0 tests: Add bin dir to PATH when running FreezeTool test 2024-10-30 14:14:25 +01:00
rdb fd7da1908f tests: Fix test suite with 3.13t build
[skip ci]
2024-10-29 16:45:08 +01:00
rdb 583f7366db linmath: Significant perf optimizations for decompose_matrix 2024-10-19 13:17:19 +02:00
rdb 14f3cb0e40 tests: Add unit test for static property 2024-09-19 20:25:45 +02:00
John C. Allwein e7604cb163 event: fix result refcount leak when awaiting AsyncFuture
Raising the StopIteration exception left the underlying
result with an elevated refcount which prevented it from
being cleaned up.
2024-09-14 15:59:05 -06:00
John C. Allwein cfe3885c0e
event: use the persistent python wrapper when appending task object (#1681) 2024-09-14 20:25:08 +02:00
rdb fc394e4c59 glgsg: Pass in osg_FrameNumber input via ShaderMatSpec mechanism 2024-08-23 21:08:50 +02:00
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