bool PointStarVlist::BeginDrawState (const QVector &center, const Vector & velocity, const Vector & torque, bool roll, bool yawpitch, int whichTexture) {
    UpdateGraphics();
    static bool StarStreaks=XMLSupport::parse_bool(vs_config->getVariable("graphics","star_streaks","false"));
    GFXColorMaterial(AMBIENT|DIFFUSE);
    bool ret=false;
    if (StarStreaks) {
        Matrix rollMatrix;
        static float velstreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_scale","5"));
        static float minstreak= XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_min","1"));
        static float fov_smoothing=XMLSupport::parse_float(vs_config->getVariable("graphics","warp.fovlink.smoothing",".4"));
        float fov_smoot = pow(double(fov_smoothing),GetElapsedTime());
        Vector vel (-velocity*velstreakscale);
        float speed = vel.Magnitude();

        if ((smoothstreak>=minstreak||vel.MagnitudeSquared()>=minstreak*minstreak)&&(speed>1.0e-7)) {
            ret=true;
            vel*=1./speed;
            speed = fov_smoot*speed + (1-fov_smoot)*smoothstreak;

            if (speed<minstreak) speed=minstreak;
            static float streakcap  = XMLSupport::parse_float (vs_config->getVariable ("graphics","velocity_star_streak_max","100"));
            if (speed>streakcap) {
                speed=streakcap;
            }
            vel=vel*speed;
            smoothstreak=speed;
            GFXColorVertex * v = vlist->BeginMutate(0)->colors;
            int numvertices = vlist->GetNumVertices();

            static float torquestreakscale= XMLSupport::parse_float (vs_config->getVariable ("graphics","torque_star_streak_scale","1"));
            for (int j=0; j<numvertices-1; j+=2) {
                int i=j;
//				if (SlowStarStreaks)
//					i=((rand()%numvertices)/2)*2;
                Vector vpoint (v[i+1].x,v[i+1].y,v[i+1].z);
                Vector recenter =(vpoint-center.Cast());
                if (roll) {
                    RotateAxisAngle(rollMatrix,torque,torque.Magnitude()*torquestreakscale*.003);
                    vpoint = Transform(rollMatrix,recenter)+center.Cast();
                }
                v[i].x=vpoint.i-vel.i;
                v[i].y=vpoint.j-vel.j;
                v[i].z=vpoint.k-vel.k;
//				static float NumSlowStarStreaks=XMLSupport::parse_float(vs_config->getVariable("graphics","num_star_streaks",".05"));
//				if (SlowStarStreaks&&j<NumSlowStarStreaks*numvertices)
//					break;
            }
            vlist->EndMutate();
        }
    }
    if (ret) {
        vlist->LoadDrawState();
        vlist->BeginDrawState();
    } else {
        nonstretchvlist->LoadDrawState();
        nonstretchvlist->BeginDrawState();
    }
    return ret;
}
void AUDListener (const QVector & pos, const Vector & vel) {
#ifdef HAVE_AL
  mylistener.pos = pos.Cast();
  mylistener.vel = vel;
  if (g_game.sound_enabled) {

  if (usepositional)
	alListener3f (AL_POSITION, scalepos*pos.i,scalepos*pos.j,scalepos*pos.k);
  if (usedoppler)
	alListener3f (AL_VELOCITY, scalevel*vel.i,scalevel*vel.j,scalevel*vel.k);
  }
  //  printf ("(%f,%f,%f) <%f %f %f>\n",pos.i,pos.j,pos.k,vel.i,vel.j,vel.k);
#endif
}
static float dockingdistance (Unit* port, Unit * un) {
	vector<DockingPorts>::const_iterator i =port->GetImageInformation().dockingports.begin();
	vector<DockingPorts>::const_iterator end =port->GetImageInformation().dockingports.end();
	QVector pos (InvTransform (port->cumulative_transformation_matrix,un->Position()));
	float mag=FLT_MAX;
	for (;i!=end;++i) {
		float tmag =(pos.Cast()-(*i).pos).Magnitude()-un->rSize()-(*i).radius;
		if (tmag < mag)
			mag=tmag;
	}
	if (mag==FLT_MAX)
		return UnitUtil::getDistance(port,un);
	return mag;
}