Has anyone here used Data Oriented Design in Panda3D?

Hey y’all! I have a question.

Based on my current understanding, Object Oriented Programming (OOP) is the most commonly used programming paradigm. However, in numerous use cases, Data Oriented Design (DOD) appears to be significantly more performative. Unity has placed a significant bet on its Data Oriented Technology Design (DOTS) system, with early demonstrations demonstrating significant improvements in game performance using DOTS.

Considering this, I am curious if anyone on this forum has experience creating games in Panda3D using DOD. Is there any available material that showcases the use of DOD in Panda3D game development?

Thank you in advance!

This is the kind of topic I enjoy reading other developers’ responses to. Myself, I tend to use a “procedural programming” approach to the majority of code-design, including in video games.

For a start, Panda3D is not particularly opinionated on what paradigm you choose, though the C++ layer is OOPish as far as I understand it. You can write procedural, OOP, or even, I imagine, Data Oriented Design style. From what I’ve read about Data Oriented Design, it attempts to minimize sources of latency like cache misses by structuring data to flow in the fastest practical way.

When writing shaders, we can execute graphics programs at a low level using GLSL (and soon enough, HLSL once the shaderpipeline branch is merged) . There is a lot which is possible in this domain, and I find the C-like lack of classes in shaders to be a benefit to structuring data in the fastest way. Personally, I fail to see the purpose of classes for many projects, especially the projects small enough to be written by a single dev as are many Panda3D programs.

And to take this a bit further, I believe that the overuse or misuse of classes often increases conceptual complexity overmuch. There has been some talk as of late to even rewrite some introductory Panda3D sample programs to eliminate the class inheritance of ShowBase convention and (return to) writing such minimal examples at “base scope” or function definition scope.

IE

from direct.showbase.ShowBase import ShowBase

base = ShowBase()
base.run()

versus

from direct.showbase.ShowBase import ShowBase


class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)


app = MyApp()
app.run()

The former example program is clearly better, I believe. In terms of writing the fastest code, this is often a matter of the specifics of what you are implementing – though the fundamentals of algorithmic complexity, sorting, seek time, etc will of course still come into play even in the cleverest of organizational paradigms because of physics and how processors work. If you really want bare metal performance you’ll be writing at a lower level than would be comfortable for most designers. However, I’d be happy to read anybody else’s example code which illustrates Data Oriented Design. If we had a sufficient example, I might like to rewrite it in another paradigm and then compare the programs.

This is aside from the main topic of this post, but I will note that I disagree here: while the former example is arguably better in-and-of-itself, a class-based approach will–for me, personally, at least–scale far better than a procedural approach. As the complexity of the program increases, so too does the value of having a clear structure–and for me, classes provide that structure.

Now, as to the main topic of the thread, I’m afraid that I don’t have an answer: I don’t know Data Oriented Design, myself.

But I suppose that I do have two general points to be made here:

First, that different approaches will work for different developers.

As we see above, for Simulan a procedural approach is more intuitive, while for me a class-based approach is more intuitive.

And second, that performance isn’t the be-all and end-all of development: ease of maintenance and congeniality of design are factors worth considering, I feel.

Speaking for myself, I’ll happily take a small loss in performance in exchange for code that’s much easier to maintain, or that is significantly more congenial to work with. (Only more so as those factors can, I daresay, reduce development time and number of bugs.)

(Which, to be clear, is not an argument against Data Oriented Design. After all, as might be drawn from my first point above, it’s entirely plausible that a given developer might find it more intuitive than Object-Oriented Design!)

I think everyone finds design patterns that work well for themselves. When we first started developing FlightGear, one of our core founders introduced the “property tree” as a way to bind C/C++ variables to ascii names (for configure file and data-driven design purposes.) It also introduced some script-like capabilities to plain C/C++ code (without all the hoopla they’ve added to C++ in the last few years.)

I have a fuller explanation with examples here (explaining things are hard and this has fingers into everything so it can be leveraged in a lot of different ways.)

It definitely isn’t an everything for everyone solution and I’m on my 3rd or 4th version of what I use in my own work. As I get more seasoned as a coder, more and more I look for simplicity and brevity in coding.

There are as many opinions on these things as there are coding styles and language/platform preferences, so my job isn’t to win any converts here, but I’m happy to share what I know and what I do and maybe something from this is useful to someone at some point …