How to calculate needed orthographic film size when toggling between ortho and perspective lenses?

Yes, I agree that I have the same intuition. I’m just not satisfied that I fully understand why I have this intuition, and where the dividing line lies precisely. :slight_smile: When I made the nim bindings, I had to write some code to make this decision (whether a type was a “by-reference” or “by-value” type) automatically, and I could never find some satisfying criteria for deciding this, I ended up special-casing lots of things. Maybe we need some way of tagging these types in the source code, so that the binding generator can do the right thing.

In any case, for vector types it’s obvious, and I will be making sure these methods return a copy instead of a reference.

For what it’s worth, when you get a WindowProperties object from a window, you are getting just a snapshot of its current values; this class is intended to be used by-value in C++.

Yes, this is fair, there is a slight extra price we pay for the extra heap memory allocation. I am not sure how much extra time this will take on top of allocating the Python wrapper object, I’ll have to time it.

I have considered a potential optimization to the bindings, by allocating the storage for the vector as part of the storage for the Python wrapper object, which would not only eliminate the extra allocation, but also reduce the overhead of using vector types in general. This would only work for types that are considered “by-value”, like vector. However, this requires significant changes to the binding generator, so I’m not sure if and when I’ll get around to it.

1 Like

That’s also not very un-intuitive, unlike in the previous example with numbers or list of numbers.
I think the API reference should somehow list what it is returning, so we won’t guess/check for each class method.

I’m not very concerned with performance.
That said, maybe the python wrapper should just return a python list, and let the user determine if they need them to be converted to a Panda3D Vector. A lot of times you don’t need that, you’re just checking the returned value with a hardcoded value to perform some task, you don’t need the values to be in a Panda3D class for that.
And if you need to perform some vector operation on the returned value, you can just have a premade Vector object and just assign the values to it.