Performance Issue: Increasing Time in "cTrav"?

Bumping–does anyone have any insight into how I might be getting those PandaNodes showing up in cTrav, given the above…?

It could be possible, that you see the Panda Nodes in pstats because the traverser visits these Nodes during the traversal (I am not sure, its just an assumption). To verify you could add some additional entries around your collision object in your egg File and check if the number of Panda Nodes increase in the pstats output.

Thank you for the suggestion. :slight_smile:

Still, that doesn’t seem to fit with what rdb said, above–in that post it was indicated that the entries corresponded to collision with visible geometry.

I could try the test that you suggest–but I’d be worried that I was seeing more nodes under “pstats” simply because more nodes are being collided with…

I think you just need to do a test scene. Where to test bodies and visible geometry, how PStats will behave in each case.

It is necessary to find out in which cases an involuntary collision occurs.

Hmm… You may be right. I think that I may have tried that previously, but even if so, I should perhaps try again, and if called for, with more combinations of factors…

[edit]
Okay, you were quite right–that was a good idea.

Here below then is a simple program:

  • It adds one CollisionPlane, and two CollisionSpheres.
    • The spheres are “from”-objects, with a “from”-mask of “1” and an “into”-mask of “0”
    • The plane is an “into”-object, with a “from”-mask of “0” and an “into”-mask of “1”.
  • The spheres and plane are all just attached to “render”.
  • Collision is handled by a simple CollisionTraverser assigned to “cTrav” and a CollisionHandlerEvent.
  • None are placed in collision with any other, and none move.

from panda3d.core import loadPrcFile, loadPrcFileData
loadPrcFileData("", "want-pstats #t")

from panda3d.core import loadPrcFile, loadPrcFileData
from direct.showbase.ShowBase import ShowBase

from panda3d.core import Vec3, Vec4, Point3, Plane, CollisionSphere, CollisionPlane, CollisionHandlerEvent, CollisionTraverser, CollisionNode

import math

from panda3d import __version__ as pandaVersion
print (pandaVersion)

import sys
print (sys.version)

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

        self.win.setClearColor(Vec4(0, 0, 0, 1))

        self.cTrav = CollisionTraverser()
        self.handler = CollisionHandlerEvent()

        plane = Plane(Vec3(1, 0, 0), Point3(0, 0, 0))
        shape = CollisionPlane(plane)
        wall = CollisionNode("wall")
        wall.addSolid(shape)
        wall.setIntoCollideMask(1)
        wall.setFromCollideMask(0)
        wallNP = render.attachNewNode(wall)
        wallNP.setPos(-15, 50, 0)
        wallNP.show()

        collider = CollisionNode("bullet")
        shape = CollisionSphere(0, 0, 0, 1)
        collider.addSolid(shape)
        collider.setIntoCollideMask(0)
        collider.setFromCollideMask(1)
        collisionNP = render.attachNewNode(collider)
        collisionNP.setPos(15, 50, 0)
        collisionNP.show()
        self.cTrav.addCollider(collisionNP, self.handler)

        collider = CollisionNode("bullet2")
        shape = CollisionSphere(0, 0, 0, 1)
        collider.addSolid(shape)
        collider.setIntoCollideMask(0)
        collider.setFromCollideMask(1)
        collisionNP = render.attachNewNode(collider)
        collisionNP.setPos(10, 50, 0)
        collisionNP.show()
        self.cTrav.addCollider(collisionNP, self.handler)


app = Game()
app.run()

And yet even with this simple program I’m seeing PandaNodes under “CollisionVolumes”. Four, to be precise. o_0
Screenshot from 2022-08-08 21-33-43

Commenting out one of the spheres brings the number of PandaNodes down to two, so the latter do seem to be associated with the former…

Likewise, if none of the objects are added to the traverser, regardless of bitmasks (and thus there are no “from”-objects), then no objects appear under “Collision Volumes”, whether CollisionNode or PandaNode.

I’ve tried removing the calls to “show()” that allow the colliders to be seen (thinking that PandaNodes are perhaps being added to visualise the colliders), but that doesn’t appear to have any effect.

Note that the code above doesn’t add any PandaNodes–only CollisionNodes. And at that, only three, two of which are “from”-objects.

So where are these four “PandaNodes” coming from…? o_0

Perhaps you need to look into the sources of the collision to understand where this is coming from.

I don’t quite understand what’s going on here yet…

ADD:
Hmm, then it’s strange why PandaNode doesn’t occur when creating a Plane…

Hmm… Searching that code for “PandaNode”, I do note that two PandaNodes–in keeping with there being two per “from” CollisionNode in the output–are potentially created for visualisation purposes.

However, that is at odds with the issue still being present when visualisation is not enabled. Furthermore, one of those nodes should only be present when “respect previous transform” is enabled, and playing with that setting in “cTrav” seems to have no effect.

It looks to me like it’s less related to CollisionSphere as opposed to CollisionPlane, and more related to the fact that the spheres are added to the traverser as potential “from”-objects…

Perhaps a method .show() simply displays what was previously generated and was hidden up to this point. I think this is a problem with inheriting the debugging geometry from the collision node. I don’t have any ideas.

It’s possible, indeed.

Thank you for your input nevertheless! You have helped, I think. :slight_smile:

Right now I’m hoping that rdb will chime in at some point.

[edit]

Something occurs to me: Across various tests, I’ve seen specific entries in the PStats “Collision Volume” graph for CollisionCapsules and (I think) CollisionPolygons–but never for CollisionSpheres, CollisionRays, etc., that I recall.

However, a quick look at some of Panda’s code doesn’t reveal an obvious discrepancy–they all seem to define PStats collectors, and I see references to others where I see references to the CollisionCapsule collector…

So it’s possible that at least some of the “PandaNodes” are, in fact, things like CollisionSpheres and so on.

This is most odd. o_0

Sorry for putting you on the wrong foot, PandaNode in CollisionVolumes is the number of nodes that Panda does a check for based on the bounding volume (which it first checks before checking other things). So it will check render, then a sub-node of render, etc. until reaching a node with a collide mask. However, it should not test branches of the scene graph that do not contain any collision masks. If you are seeing that, then that is a bug.

Aaaah, I see!

It’s not a problem, and thank you for so clarifying–that is a relief, then! :slight_smile: