Cannot call CollisionRay.setFromLens() on a const object.

Hi all,

I just downloaded the new version 1.4.0, and, while running my app, besides noticing some nice improvements, e.g. fullscreen, i also noticed a bug.

On this line:

self.picker.node().getSolid(0).setFromLens(base.camNode,mpos.getX(),mpos.getY())

(where self.picker is a nodepath to a collisionnode, with a ray added as solid)
I get this error:

Traceback (most recent call last):
  File "/home/pro-rsoft/docs/Programmeren/Programs/heartseed/trunk/main/src/main.py", line 113, in ?
    run()
  File "/usr/share/panda3d/direct/src/showbase/ShowBase.py", line 2176, in run
    self.taskMgr.run()
  File "/usr/share/panda3d/direct/src/task/Task.py", line 930, in run
    self.step()
  File "/usr/share/panda3d/direct/src/task/Task.py", line 862, in step
    self.__stepThroughList(taskPriList)
  File "/usr/share/panda3d/direct/src/task/Task.py", line 764, in __stepThroughList
    ret = self.__executeTask(task)
  File "/usr/share/panda3d/direct/src/task/Task.py", line 684, in __executeTask
    ret = task(*task.extraArgs)
  File "/usr/share/panda3d/direct/src/showbase/EventManager.py", line 47, in eventLoopTask
    self.doEvents()
  File "/usr/share/panda3d/direct/src/showbase/EventManager.py", line 41, in doEvents
    self.processEvent(self.eventQueue.dequeueEvent())
  File "/usr/share/panda3d/direct/src/showbase/EventManager.py", line 100, in processEvent
    messenger.send(eventName)
  File "/usr/share/panda3d/direct/src/showbase/Messenger.py", line 240, in send
    method (*(extraArgs + sentArgs))
  File "/home/pro-rsoft/docs/Programmeren/Programs/heartseed/trunk/main/src/heartseed/keybindings.py", line 49, in __translator
    messenger.send(control)
  File "/usr/share/panda3d/direct/src/showbase/Messenger.py", line 240, in send
    method (*(extraArgs + sentArgs))
  File "/home/pro-rsoft/docs/Programmeren/Programs/heartseed/trunk/main/src/heartseed/playerControl.py", line 124, in OnClick
    self.picker.node().getSolid(0).setFromLens(base.camNode,mpos.getX(),mpos.getY())
TypeError: Cannot call CollisionRay.setFromLens() on a const object.

A sidenote: I installed using the deb package and can’t find ppython. Is it removed or so?

Nope, this isn’t actually a bug; this is an incorrect usage. You should instead use:

self.picker.node().modifySolid(0).setFromLens(base.camNode,mpos.getX(),mpos.getY())

This is because getSolid() returns a const reference to the CollisionSolid, while modifySolid() returns a modifiable reference. The reason we have the two different methods is so Panda can know whether to update its internal caches in case you change the CollisionSolid (as you certainly are doing in this example).

David

With regard to the side note: the ‘ppython’ command is no longer needed. Just use ‘python’. Same on windows, BTW.

Thanks to both of you! It works fine now.

I had thought that the original reason for ‘ppython’ was so that the panda packaged version of python wouldn’t conflict if I already had a different standalone version of python installed. Is this not supported anymore? I would still like to have my regular python and panda both on my path.

Bb2 - if that’s all you’re worried about, just rename python.exe to mypython.exe.