// pulling of other particles
void pulling (particle * suck)
{
	rsVec diff;
	float pulldistsquared;
	float pullconst = (1.0f - suck->life) * 0.01f * elapsedTime;

	std::list < particle >::iterator puller = particles.begin ();
	while (puller != particles.end ()) {
		diff = suck->xyz - puller->xyz;
		pulldistsquared = diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2];
		if (pulldistsquared < 250000.0f && pulldistsquared != 0.0f && puller->type != SUCKER) {
			diff.normalize ();
			puller->vel += diff * ((250000.0f - pulldistsquared) * pullconst);
		}

		puller++;
	}
}

// pushing of other particles
void pushing (particle * shock)
{
	rsVec diff;
	float pushdistsquared;
	float pushconst = (1.0f - shock->life) * 0.002f * elapsedTime;

	std::list < particle >::iterator pusher = particles.begin ();
	while (pusher != particles.end ()) {
		diff = pusher->xyz - shock->xyz;
		pushdistsquared = diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2];
		if (pushdistsquared < 640000.0f && pushdistsquared != 0.0f && pusher->type != SHOCKWAVE) {
			diff.normalize ();
			pusher->vel += diff * ((640000.0f - pushdistsquared) * pushconst);
		}

		pusher++;
	}
}

// vertical stretching of other particles (x, z sucking; y pushing)
void stretching (particle * stretch)
{
	rsVec diff;
	float stretchdistsquared, temp;
	float stretchconst = (1.0f - stretch->life) * 0.002f * elapsedTime;

	std::list < particle >::iterator stretcher = particles.begin ();
	while (stretcher != particles.end ()) {
		diff = stretch->xyz - stretcher->xyz;
		stretchdistsquared = diff[0] * diff[0] + diff[1] * diff[1] + diff[2] * diff[2];
		if (stretchdistsquared < 640000.0f && stretchdistsquared != 0.0f && stretcher->type != STRETCHER) {
			diff.normalize ();
			temp = (640000.0f - stretchdistsquared) * stretchconst;
			stretcher->vel[0] += diff[0] * temp * 5.0f;
			stretcher->vel[1] -= diff[1] * temp;
			stretcher->vel[2] += diff[2] * temp * 5.0f;
		}

		stretcher++;
	}
}
