CollisionRay.setFromLens() Seems To Lag My Game

I am using a CollisionRay to detect collisions when clicking objects. Relevant code is below:

clickNode=CollisionNode("clickRay");
clickNP = base.camera.attachNewNode(clickNode);
clickNode.setFromCollideMask(GeomNode.getDefaultCollideMask());
self.clickerRay = CollisionRay();
clickNode.addSolid(self.clickerRay);
base.cTrav.addCollider(clickNP, self.collHandEvent);
def MouseClicked(self):
        if(self.clickState == self.clickEnum["Normal"]):
            if base.mouseWatcherNode.hasMouse():
                mpos=base.mouseWatcherNode.getMouse();
                self.clickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY());
                
                base.cTrav.traverse(render);
                
                #assume for simplicity's sake that myHandler is a CollisionHandlerQueue
                if self.collHandEvent.getNumEntries() > 0:
                    base.eventManager.DeselectObject();
                    self.collHandEvent.sortEntries() #this is so we get the closest object
                    pickedObj=self.collHandEvent.getEntry(0).getIntoNodePath();
                    pickedObj=pickedObj.findNetTag("Clickable");
                    if(not pickedObj.isEmpty()):
                        base.eventManager.HandleEvent(pickedObj.getName(), "Click");
                else:
                    base.eventManager.DeselectObject();

The game seems to run alright until I click for the first time and then I can notice an obvious frame rate reduction. I commented the line of code out that calls the ‘setFromLens’ method and the lagging did not occur. Is there anything that I should be careful about when using setFromLens which could cause performance issues?

That happen to me my 1st time I tried and use it. Not really awake to you look at your code in detail but you can look how I have mine setup to get an idea on how to use it.

discourse.panda3d.org/viewtopic.php?t=5732

You’ll notice I used findnettag, to settup a tage just add this to your model your trying to click.

(model you click on).setTag('myObjectTag', 1)

Also note if you have any collision on the camera you’ll need to use this to turn it off from the inside.

cnodePath.node().setIntoCollideMask(BitMask32.allOff())