void Plugin::InsertAvatars (QString& body) { int index = AvatarRX_.indexIn (body); QRegExp notBehind ("Recommended by "); QRegExp behind("Reply by "); while (index >= 0) { if (IsBehind (body, index, "Recommended by ")) { index = AvatarRX_.indexIn (body, index + 1); continue; } bool needNewLine = IsBehind (body, index, "Reply by ") || IsBehind (body, index, "Private message from "); const QString& avatar = QString ("%1<img style='float:left;margin-right:4px' " "width='32px' " "height='32px' " "src='http://api.juick.com/avatar?uname=%2&size=32'>") .arg (needNewLine ? "<br />" : "") .arg (AvatarRX_.cap (1)); body.insert (index, avatar); index = AvatarRX_.indexIn (body, index + avatar.length () + AvatarRX_.matchedLength ()); } }
/** * Returns values indicating whether the ownship state will pass in front of or behind the intruder (from a horizontal perspective) * @param so ownship position * @param vo ownship velocity * @param si intruder position * @param vi intruder velocity * @return 1 if ownship will pass in front (or collide, from a horizontal sense), -1 if ownship will pass behind, 0 if divergent or parallel */ int VectFuns::passingDirection(const Vect3& so, const Velocity& vo, const Vect3& si, const Velocity& vi) { double toi = timeOfIntersection(so,vo,si,vi); double tii = timeOfIntersection(si,vi,so,vo); // these values may have opposite sign! //fpln("toi="+toi); //fpln("int = "+ intersection(so,vo,si,vi)); if (ISNAN(toi) || toi < 0 || tii < 0) return 0; Vect3 so3 = so.linear(vo, toi); Vect3 si3 = si.linear(vi, toi); //fpln("so3="+so3); //fpln("si3="+si3); if (behind(so3.vect2(), si3.vect2(), vi.vect2())) return -1; return 1; }
static void updateCameraAcceleration(UBYTE update) { Vector3i concern = swapYZ(trackingCamera.target->pos); Vector2i behind(0, 0); /* Irrelevant for normal radar tracking */ bool bFlying = false; /* This is where we check what it is we're tracking. Were we to track a building or location - this is where it'd be set up */ /* If we're tracking a droid, then we need to track slightly in front of it in order that the droid appears down the screen a bit. This means that we need to find an offset point from it relative to it's present direction */ if (trackingCamera.target->type == OBJ_DROID) { const int angle = 90 - abs((player.r.x/182) % 90); const DROID *psDroid = (DROID*)trackingCamera.target; const PROPULSION_STATS *psPropStats = &asPropulsionStats[psDroid->asBits[COMP_PROPULSION].nStat]; if (psPropStats->propulsionType == PROPULSION_TYPE_LIFT) { bFlying = true; } /* Present direction is important */ if (getNumDroidsSelected() > 2) { unsigned group = trackingCamera.target->selected ? GROUP_SELECTED : trackingCamera.target->group; uint16_t multiAngle = getAverageTrackAngle(group, true); getTrackingConcerns(&concern.x, &concern.y, &concern.z, group, true); behind = iSinCosR(multiAngle, CAM_DEFAULT_OFFSET); } else { behind = iSinCosR(trackingCamera.target->rot.direction, CAM_DEFAULT_OFFSET); } concern.y += angle*5; } Vector3i realPos = concern - Vector3i(-behind.x, 0, -behind.y); Vector3f separation = realPos - trackingCamera.position; Vector3f acceleration; if (!bFlying) { acceleration = separation*ACCEL_CONSTANT - trackingCamera.velocity*VELOCITY_CONSTANT; } else { separation.y /= 2.0f; acceleration = separation*(ACCEL_CONSTANT*4) - trackingCamera.velocity*(VELOCITY_CONSTANT*2); } if (update & X_UPDATE) { /* Need to update acceleration along x axis */ trackingCamera.acceleration.x = acceleration.x; } if (update & Y_UPDATE) { /* Need to update acceleration along y axis */ trackingCamera.acceleration.y = acceleration.y; } if (update & Z_UPDATE) { /* Need to update acceleration along z axis */ trackingCamera.acceleration.z = acceleration.z; } }