
As most may know, loaded .egg files are cached in the model pool (panda3d.core.ModelPool), which means subsequent loads reuse the same geometry, thus saving memory. However, the same doesn’t happen for generated geometry (either using the Geom or EggData approaches).
At first I was worried that this fact would discourage people from using procedurally-generated models, fearing there was no way for such geometry to be cached. However, after some discussion on Discord, it was pointed out to me that as long as I reuse the Geom, there would be no significant extra memory usage for subsequent replicas.
That was encouraging and I decided to do a small experiment in order to observe this.
This repository represents such experiment, including discussion and results/conclusions and explains how to run each of the included scenarios: GitHub - KennedyRichard/procgenmemtest: Small Panda3D experiment comparing memory usage when reusing procedurally-generated models
The code is in the public domain and is all plain Python code that relies solely on Panda3D and the standard library to generate UV sphere geometry for the different scenarios in the experiment.
Scenarios A, A1, B and B1 are for testing memory usage of different methods (manually, by checking your own task manager, etc.), and scenario X, depicted in the GIF at the top of this post, is just a playground where users can define and display a UV sphere with given arguments (optionally saving it as an .egg file as well).
This discussions was created just to leave a permanent record for people interested in this kind of thing and to allow people to share feedback/observations, if desired. The code might be useful to some as well. The geometry generation in particular was made with the goal of striking a good balance between memory efficiency, avoiding needless calculations and good Pythonic design/code.
Anyway, whenever a good discussion pops up on Discord, I feel compelled to sooner or later record it in a more perennial format, like this forum, so that it is not lost to the ephemerality of the Discord timeline. Discord is great for chatting and real-time support, but horrible for organizing/indexing knowledge and supporting long deep discussions (although that doesn’t stop us from engaging in long deep discussions there as well from time to time
).