Comments (5)
After further testing, it seems it could be a reference count issue, when directly retrieving the transform matrix, the received matrix is singular :
print(self.instance.get_net_transform().get_mat())
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
But if i store the net transform state in a temporary variable, the matrix is fine :
transform = self.instance.get_net_transform()
print(transform.get_mat())2.38188 5.41052 -2.34575 0
-5.89714 2.18533 -0.947458 0
6.36e-09 2.52986 5.83519 0
-24.9978 4.72253 -1.26191e-06 1
from panda3d.
Is this with the transform cache disabled?
The problem is that TransformState accessors return a const reference to the fields therein, which is bound to the lifetime of the TransformState, which may go out of scope. This is a general issue in the Python API at the moment.
(A related issue was with MouseWatcher::get_mouse()
, which used to return a reference to a Point2 that would "magically update" when the mouse moved, causing a lot of user confusion. This was finally changed in 76b9df0.)
Possible ways to solve this include:
- Interrogate always makes a copy of any const reference return value.
- We add some clever mechanism to interrogate so that a reference to the TransformState is stored on the returned PyObject, so it is kept alive.
- We change the return value to an LMatrix4 copy, just for this one method.
I think 3 means we're just going to see this issue pop up somewhere else soon.
While 2 is clever, interrogate can't strictly speaking know for sure what the lifetime of a return value is meant to be bound to, without . We could add a special keyword to add to a method that tells Interrogate to do this, but it sounds difficult.
I'd be inclined to go with option 1, even though this could break existing code. We'll have to analyze whether there are cases where this doesn't make sense, but generally, I think this is what Python users expect.
from panda3d.
Is this with the transform cache disabled?
Yes indeed, I forgot to mention that crucial fact
While 2 is clever, interrogate can't strictly speaking know for sure what the lifetime of a return value is meant to be bound to, without . We could add a special keyword to add to a method that tells Interrogate to do this, but it sounds difficult.
This probably sounds naive, but can't the temporary returned PyObject keep a reference to the TransformState and automatically release that reference when it is garbage collected by the Python engine ?
from panda3d.
That's what I suggested with 2, but how does interrogate know that the returned reference is supposed to be bound to the lifetime of the TransformState, and not bound to the lifetime of some other object? It would need to look into the method and see that it's returning a member rather than a member of something else. Or we would need to tag the method with some special keyword.
Or, maybe we just assume this is the case, and accept that it's not a perfect solution? Still, I feel that having objects being able to arbitrarily preserve the lifetime of other objects could also cause unintuitive behaviour for users, perhaps even memory leaks and reference cycles (in the case of classes like NodePath).
from panda3d.
I pushed an interim fix that makes interrogate think that these methods return temporaries, so that it is forced to make a copy. This is not breaking compatibility for this specific case since TransformStates are immutable anyway.
We still need a good fix for the general case.
from panda3d.
Related Issues (20)
- Reimplement core functionality of DIRECT in C++ codebase HOT 1
- Cppparser preprocessor do not expand macros with arguments correctly HOT 94
- bam_model_extensions changes external path references in distributions
- FSM object has no attribute 'notifier' in requestNext/requestPrev
- Importing Pyrender with Panda3D results in the code not processing HOT 1
- Triangulator running out of memory HOT 1
- Interrogate limitations
- PandAI website link in the manual is broken, navmesh converter source "BlenderMeshGen.py" is lost. HOT 1
- DirectEntry with both backgroundFocus=1 and overflow=1 leave hanging events after being destroyed, causing a segmentation fault HOT 2
- Generated interrogate wrapper is not deterministic on macOS HOT 1
- PNMImage.flip() documentation doesn't match method, can't transpose with x/y mirror HOT 2
- Type Definition for functions and methods HOT 2
- Actor Animation Problem HOT 2
- Bam cache should remember loader used
- PStats: Scrubbing Through Flame-Charts
- Implement Khronos' reference PBR tone mapping operator HOT 3
- `Python 3.12.3`: No found distribution for panda3d HOT 3
- More Filters in Common Filters
- Issues using makewheel with CMake
- Is this license a BSD one or a different one? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panda3d.