I was updating my game to the latest Panda3D (from GitHub, bleeding edge). But whenever I loaded a specific class, Panda3D crashed. No info at all with spam enabled. I pinpointed it to the following line:
FSM.__init__(self, name)
I tried to init a single FSM class, and it worked. I realized that PandaNode and FSM weren’t working together.
Consider the following example:
from panda3d.core import PandaNode
from direct.fsm.FSM import FSM
class Test(PandaNode, FSM):
def __init__(self):
PandaNode.__init__(self, 'Test')
FSM.__init__(self, 'Test')
Test()
Running the code leaves me with this traceback (don’t mind the first two calls): i.imgur.com/rLkJ2Fq.png
But if I switch the order… (This was my case, when P3D just simply crashed):
from panda3d.core import PandaNode
from direct.fsm.FSM import FSM
class Test(FSM, PandaNode):
def __init__(self):
FSM.__init__(self, 'Test')
PandaNode.__init__(self, 'Test')
Test()
It’s worth noting that my previous Panda3D build was compiled on November 18 2015, it was working fine back then.
I’m trying out a different combination of C++ and Python class, when I have results, I’ll update this post
edit: Yeah, initing a Python class first and then a C++ class crashes the game. As for the other way around, PandaNode and FSM still don’t like each other. That’s my main concern, the
I’ll try a few different builds in a few days. Since we have a clear test case we should probably collect data from other environments first, before recommending an entire architecture change as a debugging step. The issue may be in platform specific builds, or an environment specific issue.
The issue is that FSM defines a field self.state that conflicts with PandaNode which has a member called .state.
Is there a particular reason why you need a class to inherit from PandaNode and FSM? It seems a bit odd that you would use multiple base classes in this way.
It actually was originally written this way. I encountered this issue when I was attempting to upgrade from Panda3D 1.9.0 (yes, that old). Looks like I’m going to have to pull out the FSM from the class and make it just a variable. (self.fsm)
It might be better to inherit from FSM (which is required for the request methods to work), and to use composition for the PandaNode (which is a better idea anyway, because of the caveats with inheriting from C++ classes).