Page 1 of 1

DrawOnMiniMap, for CEGs and Weapons

Posted: 05 Apr 2008, 00:25
by Argh
Boolean. If 0, then the CEG / Weapon is not drawn on the Minimap.

Sounds minor, but it's really not, with increasingly-large numbers of CEGs being used to do stuff that's purely FX, and not explosions. Yet Spring handles all CEGs as if they were explosion events, and displays them on the Minimap, using a lot of CPU time that could be better-used elsewhere, imo.

Re: DrawOnMiniMap, for CEGs and Weapons

Posted: 05 Apr 2008, 01:26
by FLOZi
hmm, +1.

Probably one of those things I could do myself if i find the time.

Re: DrawOnMiniMap, for CEGs and Weapons

Posted: 05 Apr 2008, 01:31
by lurker
What was the traditional name for this again?

Re: DrawOnMiniMap, for CEGs and Weapons

Posted: 05 Apr 2008, 05:08
by Argh
The relevant code is in UI / MiniMap.cpp.

Seems that the problem is that no distinction was made between CEGs and various weapon projectiles there... same goes for PartPieceProjectiles (oh, yeah, we need to see a little blip for a flying PeeWee leg... not) and other crap. Meh, this section of the code is giant... just cutting out all of the non-weapon projectiles would probably make a big difference in CPU usage, frankly.

Re: DrawOnMiniMap, for CEGs and Weapons

Posted: 05 Apr 2008, 05:15
by Argh
Here's the offending section...

Code: Select all

Projectile_List::iterator psi;
	for(psi = ph->ps.begin(); psi != ph->ps.end(); ++psi) {
		CProjectile* p=*psi;
		if((p->owner && (p->owner->allyteam == gu->myAllyTeam)) ||
		loshandler->InLos(p, gu->myAllyTeam) || gu->spectatingFullView) {
			if (dynamic_cast<CGeoThermSmokeProjectile*>(p)) {
			} else if (dynamic_cast<CGfxProjectile*>(p)) {//Nano-piece
				glBegin(GL_POINTS);
				glColor4f(0,1,0,0.1);
				glVertexf3(p->pos);
				glEnd();
			} else if (dynamic_cast<CBeamLaserProjectile*>(p)) {
				glBegin(GL_LINES);
				glColor4f(((CBeamLaserProjectile*)p)->kocolstart[0]/255.0,((CBeamLaserProjectile*)p)->kocolstart[1]/255.0,((CBeamLaserProjectile*)p)->kocolstart[2]/255.0,1);
				glVertexf3(((CBeamLaserProjectile*)p)->startPos);
				glVertexf3(((CBeamLaserProjectile*)p)->endPos);
				glEnd();
			} else if (dynamic_cast<CLargeBeamLaserProjectile*>(p)) {
				glBegin(GL_LINES);
				glColor4f(((CLargeBeamLaserProjectile*)p)->kocolstart[0]/255.0,((CLargeBeamLaserProjectile*)p)->kocolstart[1]/255.0,((CLargeBeamLaserProjectile*)p)->kocolstart[2]/255.0,1);
				glVertexf3(((CLargeBeamLaserProjectile*)p)->startPos);
				glVertexf3(((CLargeBeamLaserProjectile*)p)->endPos);
				glEnd();
			} else if (dynamic_cast<CLightingProjectile*>(p)) {
				glBegin(GL_LINES);
				glColor4f(((CLightingProjectile*)p)->color[0],((CLightingProjectile*)p)->color[1],((CLightingProjectile*)p)->color[2],1);
				glVertexf3(((CLightingProjectile*)p)->pos);
				glVertexf3(((CLightingProjectile*)p)->endPos);
				glEnd();
			} else if (dynamic_cast<CPieceProjectile*>(p)) {
				glBegin(GL_POINTS);
				glColor4f(1,0,0,1);
				glVertexf3(p->pos);
				glEnd();
			} else if (dynamic_cast<CWreckProjectile*>(p)) {
				glBegin(GL_POINTS);
				glColor4f(1,0,0,0.5);
				glVertexf3(p->pos);
				glEnd();
			} else if (dynamic_cast<CWeaponProjectile*>(p)) {
				glBegin(GL_POINTS);
				glColor4f(1,1,0,1);
				glVertexf3(p->pos);
				glEnd();
			} else {
				glBegin(GL_POINTS);
				glColor4f(1,1,1,0.1/*0.0002f*(width+height)*/);
				glVertexf3(p->pos);
				glEnd();
			}
		}
	}
Looks like the main solution is to remove the CEG-class stuff (CWeaponProjectile, probably going to require other changes there, too) the useless particle trails behind ships (CGfxProjectile) Piece projectiles (CPieceProjectile) and (CGeoThermSmokeProjectile)...

Meh, no wonder stuff's slowing down so much, at the high end, this has to iterate through thousands of "projectiles" and get their locations every iteration... it's more than enough to just see a few points that accelerate away from a dead Unit and fade out when it dies, or something, along with real weapon projectiles, which should not include CSimpleParticleSystem events, smoke, etc...

Re: DrawOnMiniMap, for CEGs and Weapons

Posted: 05 Apr 2008, 05:57
by Vadi
Argh wrote:The relevant code is in UI / MiniMap.cpp.

Seems that the problem is that no distinction was made between CEGs and various weapon projectiles there... same goes for PartPieceProjectiles (oh, yeah, we need to see a little blip for a flying PeeWee leg... not) and other crap. Meh, this section of the code is giant... just cutting out all of the non-weapon projectiles would probably make a big difference in CPU usage, frankly.
I love how the large plasma projectiles show up on the minimap, but a peewee leg is a bit of an overkill :lol:

Re: DrawOnMiniMap, for CEGs and Weapons

Posted: 05 Apr 2008, 06:03
by Argh
Yeah, I'm not saying, "don't draw weapons", or even "don't draw itty bitty explosions", I'm saying, "don't query thousands of Projectiles all the time, and draw thousands of overlapping gl.point objects all the time, when it's really not necessary and could be done with a tenth of the points to convey the same information".

Re: DrawOnMiniMap, for CEGs and Weapons

Posted: 21 Apr 2008, 08:51
by Argh
BTW, I torture-tested this a bit...

Basically, it costs 20% of current framerate, to draw all this stuff on the Minimap. Seriously! Between that and the AirLosMip stuff I found, meh, we could make Spring perform far better by fixing this stuff.