AssertionError

AssertionError: !is_empty() at line 2399 of panda/src/pgraph/nodePath.cxx

Trying to figure out the problem that’s causing this error that I’m getting. Does this have to do with panda, or is it with my code? Any way to fix this?

An empty nodepath is like a null pointer - it’s a nodepath that doesn’t reference any node at all. There are a lot of methods that return nodepaths, and some of those can return empty nodepaths from time to time. For example, the method “find” searches the scene graph for a node, and returns a nodepath. But if it doesn’t find anything, it returns an empty nodepath. I think maybe loadModel can return an empty nodepath - for example, if you try to load a model but the file isn’t found.

There are a lot of methods that accept a nodepath as a parameter, but they don’t have any use for an empty nodepath. They contain “asserts” that check to make sure you don’t accidentally pass an empty nodepath in.

So that’s what’s happened to you. You called a method that you expected to return the nodepath of a 3D model, and it returned an empty nodepath instead. Then, you called another method passing it what you thought was the nodepath of that 3D model, but in fact was the empty nodepath, and it complained about it.

You’re right, I did do that, and the code is working now that I fixed it :smiley:. Thank you very much for pointing out the problem. I thought that since it was referencing a panda source file it might have been something on that end, but now I know for future reference to not be so naive. :wink:

Edit: This is what I was calling

nodePath.setLightOff(priority)

I simply removed this (lol, nice fix right…) and the error doesn’t occur.

This is the complete error:

Assertion failed: 
DirectStart: Starting the game.
Warning: DirectNotify: category 'Interval' already exists
!is_empty() at line 2399 of panda/src/pgraph/nodePath.cxx
Traceback (most recent call last):
  File "main.py", line 10, in <module>
    import direct.directbase.DirectStart
  File "C:\Panda3D-1.5.0\direct\src\directbase\DirectStart.py", line 4, in <module>
    ShowBase.ShowBase()
  File "C:\Panda3D-1.5.0\direct\src\showbase\ShowBase.py", line 375, in __init__
    self.__doStartDirect()
  File "C:\Panda3D-1.5.0\direct\src\showbase\ShowBase.py", line 2227, in __doStartDirect
    self.startDirect(fWantDirect = fDirect, fWantTk = fTk)
  File "C:\Panda3D-1.5.0\direct\src\showbase\ShowBase.py", line 2211, in startDirect
    from direct.directtools import DirectSession
  File "C:\Panda3D-1.5.0\direct\src\directtools\DirectSession.py", line 1081, in <module>
    __builtins__['direct'] = base.direct = DirectSession()
  File "C:\Panda3D-1.5.0\direct\src\directtools\DirectSession.py", line 73, in __init__
    useDirectRenderStyle(self.selectedNPReadout)
  File "C:\Panda3D-1.5.0\direct\src\directtools\DirectUtil.py", line 62, in useDirectRenderStyle
    nodePath.setLightOff(priority)
AssertionError: !is_empty() at line 2399 of panda/src/pgraph/nodePath.cxx

Just figured I’d post this. Not really sure why, but it may come in handy in future searches…
[/code]