Page 1 of 1

Speed problems with lots of primitives

Posted: Fri Jun 22, 2007 4:27 pm
by cvf
Hello, I need to use a 50x50 grid os small spheres in my program, but it makes Irrlicht go extremelly slow... here it is the code I use:

Code: Select all

	for (int y = 0; y < 50; y++)
	{
		for (int x = 0; x < 50; x++)
		{
			scene::ISceneNode* DotSceneNode = smgr->addSphereSceneNode(.5, 8, NULL, IDFILTER, 
															core::vector3df(6*x,6*y,0));
			DotSceneNode->getMaterial(0).AmbientColor.set(128, 0, 0, 255);
		}
	}
You can put it in the the Terrain example to see how slow it goes...
Does anyone have an idea of why is so slow? What am I doing wrong to get this slow speed? What can I do to improve it?
I cannot join all the geometry in one only object, as later I need to select each sphere individually...

Thanks in advance!

Hugo

Posted: Fri Jun 22, 2007 6:37 pm
by Jallen
50x50 is 2500...
so say theres 100 verticies in each sphere.
that means that there will be 250000 verticies on the screen at once.
To be honest i dont think that that number of verticies should cause any slow down, its pretty low really.
Try a different renderer and see if thats the problem, or perhaps your rendering some kind of effect by accident? :?

Posted: Fri Jun 22, 2007 9:24 pm
by arras
It can. Try loading your 2500 primitives as one object and you see. Problem is not number of vertices, problem is number of objects. Each needs to be culled, rendered and I dont know what else individualy.

When I was working on my terrain class I wanted to keep each tile as separate meshbuffer. 50 x 50 such tiles caused my computer to halt. And tile have just two vertices. When I loaded those tiles as one mesh buffer everything was fine.

Posted: Fri Jun 22, 2007 11:31 pm
by vitek
I think it is the number of draw calls that are being made. You've got 2500 draw calls, each with about 64 vertices. That is not going to be very efficient. Consider also that the vertex data is sent to the graphics card for every draw, which makes this even more slow.

Travis