Faster way to render circles

from pandac.PandaModules import Vec4
from pandac.PandaModules import LineSegs
import direct.directbase.DirectStart
from panda3d.core import GeomNode
import math
cos=math.cos
sin=math.sin
pi=math.pi

base.disableMouse( )
base.camera.setPos( 0, 0, 50)
base.camera.lookAt( 0, 0, 0 )

num=700
red=0
g=0
b=1
r=.25
rO=10
numO=50
for i in range(0,numO):
	xO=cos((2*pi*i)/numO)*rO
	yO=sin((2*pi*i)/numO)*rO
	for m in range(0,num):
			x1=cos((2*pi*m)/num)*r+xO
			x2=cos((2*pi*(m+1))/num)*r+xO
			y1=sin((2*pi*m)/num)*r+yO
			y2=sin((2*pi*(m+1))/num)*r+yO
			segs = LineSegs( )
			segs.setThickness( 0.0001 )
			segs.setColor(red,g,b)
			#if m==min:	
				#segs.setColor(1,0,0)
			#if m==0:
				#segs.setColor(0,1,0)
			segs.moveTo(x1,y1,0 )
			segs.drawTo( x2,y2,0 )
			f=segs.create( )
			render.attachNewNode( f )
base.setBackgroundColor(0, 0, 0)
base.run()

Is there a method to draw circles and render them faster than using LineSegs?

It depends on what you want to achieve and how configurable it should get. Probably the fastest way would be to create the circles outside of panda, either as a pre-modeled 3d model or simply 2d sprite image and then load and place them. If you want to create the circles within panda, you could try to create them asynchronously or not use the lineSegs class but the geom classes like this which is much faster:

from pandac.PandaModules import Vec4
from pandac.PandaModules import LineSegs
import direct.directbase.DirectStart
from panda3d.core import GeomNode, GeomVertexFormat, GeomVertexData, GeomVertexWriter, Geom, GeomLinestrips
import math
cos=math.cos
sin=math.sin
pi=math.pi

base.disableMouse( )
base.camera.setPos( 0, 0, 50)
base.camera.lookAt( 0, 0, 0 )
base.setBackgroundColor(0, 0, 0)

num=700
red=0
g=0
b=1
r=.25
rO=10
numO=50

v = GeomVertexFormat.getV3()

for i in range(0,numO):
    xO=cos((2*pi*i)/numO)*rO
    yO=sin((2*pi*i)/numO)*rO
    vdata = GeomVertexData("circ", v, Geom.UHStatic)
    vdata.set_num_rows(num*2)
    vertex = GeomVertexWriter(vdata, "vertex")
    prim = GeomLinestrips(Geom.UHStatic)
    for m in range(0,num):
        x1=cos((2*pi*m)/num)*r+xO
        x2=cos((2*pi*(m+1))/num)*r+xO
        y1=sin((2*pi*m)/num)*r+yO
        y2=sin((2*pi*(m+1))/num)*r+yO

        vertex.add_data3f(x1,y1,0)
        vertex.add_data3f(x2,y2,0)
    prim.add_consecutive_vertices(0, num*2)
    prim.close_primitive()
    geom = Geom(vdata)
    geom.add_primitive(prim)
     
    node = GeomNode('circle-{}'.format(i))
    node.addGeom(geom)
     
    np = render.attachNewNode(node)
    np.set_render_mode_thickness(1)
    np.set_color(red,g,b)
    base.graphics_engine.renderFrame()

base.run()

Right on, I’ll check it out when I get home tonight

Yea that is definately alot faster, I appreciate your reply