Speed problems with lots of primitives

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
cvf
Posts: 7
Joined: Wed May 16, 2007 12:39 pm

Speed problems with lots of primitives

Post 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
Jallen
Posts: 46
Joined: Tue Jun 19, 2007 5:28 pm
Location: Hampshire, England

Post 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? :?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post 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.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
Post Reply