Commit Graph

12176 Commits

Author SHA1 Message Date
rdb 2c5cebe7e0 display: Fix shader gen regression for more than 2 lights 2024-08-23 14:20:20 +02:00
rdb 76ffef38d1 display: Allow passing whole state into dispatch_compute()
This is mainly useful for unit testing
2024-08-23 12:34:57 +02:00
rdb babd3a070d display: Fix docstring formatting 2024-08-22 15:52:48 +02:00
rdb 712300c9f1 Fix prebuilt bison cxx files includes to work with CMake build
Change makepanda to generate without the .yxx extension so that the include name is generated properly
2024-08-13 00:01:35 +02:00
rdb 4ca495d828 CMake: Add separate BUILD_TOOLS option to build binaries
This is separate from BUILD_PANDATOOL, which builds the pandatool tree
2024-08-12 16:39:20 +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 23124dac07 x11: Fix missing _net_wm_name field due to bad merge 2024-08-07 23:39:20 +02: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 122453811d glgsg: Fix clear of offscreen buffer if back buffers requested 2024-06-30 11:53:17 +02:00
rdb a655784d8d x11: attempt to fix UTF-8 window titles (see #209) 2024-05-16 20:30:27 +02:00
rdb adb9242885 glgsg: Fix faulty auto-merge 2024-05-14 23:19:46 +02:00
rdb b6515c881c Merge branch 'release/1.10.x' 2024-05-14 22:47:08 +02:00
rdb 2436a06527 glgsg: Better error when invalid ShaderPtrSpec type is encountered 2024-05-14 22:45:01 +02:00
Wizzerinus 3ffcce2cc2 add getPlayMode() for actor and anim interface 2024-05-14 11:06:06 +02:00
Disyer a9206041d9 ffmpeg: Use ch_layout in favor of removed channel_layout and channels
Closes #1641
2024-04-08 13:32:51 +02:00
rdb 5da013e2e9 text: Properly handle surrogate pairs in text on Windows
Fixes #1629
2024-04-08 12:12:00 +02:00
rdb 2adc167f26 windisplay: Fix regression related to fullscreen switching
Fixes #1594
2024-04-08 11:29:43 +02: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 33cef0aca3 pgraph: Disable non-working `__traverse__()` on NodePath 2024-03-29 17:15:43 +01:00
rdb 1213d95560 Merge branch 'release/1.10.x' 2024-03-28 01:17:52 +01:00
rdb 0e2a706ec8 audio: Fix changing sound time not working on macOS
Fixes #1607
2024-03-27 12:02:12 +01:00
rdb 237d27dfd9 text: Error instead of crash when glyph does not fit into page
Fixes #1626
2024-03-27 10:59:52 +01:00
rdb 8ea2301d16 pgui: Fix PGEntry::get_cursor_Y()
It returned the Y position, which is always 0.0, instead of the Z position.

Fixes #1633
2024-03-27 10:22:54 +01:00
rdb 06e72b5d7d text: Add docstring for `set_text_color()`
Fixes #1621
2024-03-27 10:06:39 +01:00
rdb 6f6cbf318e Merge branch 'release/1.10.x' 2024-03-26 17:08:52 +01:00
rdb 655aa49d81 putil: Remove outdated TypedWritable template files
See #1630
2024-03-18 02:39:51 +01:00
rdb 40b824bdcc general: Consistently name all bam factory functions make_from_bam
See discussion in #1630
2024-03-18 02:38:41 +01:00
rdb d4a3b9bfcd glgsg: Fix docstring typo 2024-03-15 12:47:21 +01:00
rdb f7cca55e14 pnmimagetypes: Fix double return statement in bmp.h
Fixes #1628

[skip ci]
2024-03-12 17:28:05 +01:00
rdb af27a9523c Merge branch 'release/1.10.x' 2024-03-12 15:39:16 +01:00
rdb c4adc17d55 display: Fix assorted unreachable code warnings 2024-03-12 15:30:32 +01:00
rdb bfe1c95d29 pgraph: Python wrappers for TransformState getters no longer return reference to temporary
Fixes #1625
2024-03-12 15:29:54 +01:00
rdb 92db1840f9 net: Prepare to split these classes out into panda3d.net module
See #1466 - these classes are still part of panda3d.core as of 1.11, but they should really be imported from panda3d.net (they can be imported from either place in 1.11).  A future release will remove them from panda3d.core entirely.
2024-03-02 13:41:23 +01:00
rdb 09fc5b73d7 glgsg: Fix regressions with fog shader inputs in GLSL 2024-02-11 22:57:18 +01:00
darktohka b049c891d1 ext: Use different names for each gen_next method 2024-02-10 23:49:28 +01:00
rdb 3303bac902 x11: Fix error message when xf86dga extension is not found
[skip ci]
2024-02-09 15:06:27 +01:00
Maxwell Dreytser d8775fa01e Fix unguarded python-specific headers. 2024-02-02 19:45:28 +01:00
Maxwell Dreytser 6dc274e38d Remove .I files from _IGATEEXT. 2024-02-02 19:45:28 +01:00
rdb 73360393df Switch use of Py_INCREF to new Py_NewRef function
This is more idiomatic, simplifies the code, makes it easier to port to eg. HPy later on, and makes it easier to use the limited ABI (where it can be optimized to a tail call) later on

A polyfill is provided for compatibility with Python versions 3.8 and 3.9
2024-01-29 17:57:53 +01:00
rdb f1f15a92a4 task: Fix refcount leak when assigning attribute of task object
Regression on 1.11
2024-01-29 16:03:43 +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 b49dbaca2b Report errors if calls to `close()` fail 2024-01-25 12:33:20 +01:00
rdb 0dad38d089 text: Enable text-use-harfbuzz by default, if compiled in
See #1591
2024-01-23 16:47:50 +01:00
rdb 23772c4722 text: Support explicit direction even with harfbuzz disabled
Fixes #1591
2024-01-23 16:45:39 +01:00
rdb ca9b5dd44a glgsg: Fix for when `p3d_Color` is set to vec4 type
Fixes #1601
2024-01-23 15:42:13 +01:00
rdb 39d964c4bb glgsg: Don't set immutable flag for buffer textures (regression)
Fixes #1602
2024-01-23 15:37:07 +01:00
rdb 9517ffb320 Merge branch 'release/1.10.x' 2024-01-08 21:10:17 +01:00
kamgha fe63dee524 Assorted docstring fixes
Closes #1588
2024-01-08 19:53:46 +01:00