Best performance with a lot of collision from objects

I’m writing a small program using Panda3D and its collision detection. In the program I create one thousand or more from objects each with a CollisionSegment. For the few into objects I use the line { Polyset keep descend } in the egg file. Only about 100 Polygons are used for them ll together. When I start the program without the into objects, I have a frame rate of 50 FPS. With the into objects I get only 10 FPS. 10 FPS is too few and when I move the objects it drops to 6 FPS.
So one problem seems to be the inefficent collision detection and maybe the reason is how I create the from objects. So here is the code.

self.FromObjects = []
        for i in range(-5,20):
            for j in range(25,65):
                #Model
                ObjectGeom = loader.loadModel("models/triangle")
                ObjectGeom.setPos(i,j,0.2)
                ObjectGeom.reparentTo(render)
                #CollisionSegment
                ObjectSegment = CollisionSegment()
                ObjectSegment.setPointA(0,0.8,1.5)
                ObjectSegment.setPointB(0,-1,1.5)
                ObjectSegmentCol = CollisionNode('ObjectSegment')
                ObjectSegmentCol.addSolid(ObjectSegment)
                ObjectSegmentCol.setFromCollideMask(BitMask32.bit(0))
                ObjectSegmentCol.setIntoCollideMask(BitMask32.allOff())
                ObjectSegmentColNp = ObjectGeom.attachNewNode(ObjectSegmentCol)
                ObjectSegmentHandler = CollisionHandlerQueue()
                self.cTrav.addCollider(ObjectSegmentColNp, ObjectSegmentHandler)
                
                #put objects in a list
                self.FromObjects.append([ObjectGeom,ObjectSegmentHandler])

So my short question is, how can I get it faster?

heayho.

performance tuning can be quite the topic. but in your case the following advices wold make most sense from my point of view.
use the egg-octree script to optimize your geometry.
when setting 1000nds of positinons each frame python and its loop might already cause quite some slowdown. be sure to use functions like SetPosHpr instead of setPos and setHpr.
use pstats to track down the actual bottlenecks. if you know what’s slow its easier to fix. a look at pstats never hurts.
oh. last but not least

1,000 from objects is far more than Panda’s collision system was designed to handle. (It works best if your number of from objects is fewer than 32.) You might need to devise a different system that doesn’t require so many CollisionSegments. Failing that, you might need to fall back to a different collision system, such as the one supplied with ODE.

David

Thanks for the replies. Well it’s definitely the collision detection that slows down the application. So I read the few stuff about the ODE collision detection in Panda3D. Looks like a worthwhile alternative, but I haven’t understand yet how I can set up some kind of a CollisionSegment (probably a OdeRayGeom), run the collision detection and then look somewhere for the collision entries (in some kind of a CollisionHandlerQueue). My main problem is that I did’t find a way to handle the detected collisions betwenn PointA and PointB of a segment manually. My aim is to return a list with answers for every tested segment if there was a collision or not. Till now it seems to me that ODE wants to handle all automatically. If there is (or will be in 1.6) a way then some example code is always useful.