| 101 | } |
| 102 | |
| 103 | void Streamer::Extend(const Vector3& pos, const Vector3& dir, short orient, const Color& colorStart, const Color& colorEnd, |
| 104 | float width, float life, float vel, float expRate, short rot, unsigned int segmentCount) |
| 105 | { |
| 106 | constexpr auto FADE_IN_COEFF = 3.0f; |
| 107 | |
| 108 | auto& segment = GetSegment(); |
| 109 | |
| 110 | // Avoid creating "clipped" streamers by clamping max life according to max segment count. |
| 111 | int lifeMax = (int)std::min(round(life * FPS), (float)SEGMENT_COUNT_MAX); |
| 112 | |
| 113 | float alpha = (float(segmentCount * SEGMENT_SPAWN_INTERVAL_TIME) / (float)lifeMax) * FADE_IN_COEFF; |
| 114 | float opacityMax = EaseInOutSine(colorEnd.w, colorStart.w, alpha); |
| 115 | |
| 116 | segment.Orientation = AxisAngle(dir, orient); |
| 117 | segment.Color = |
| 118 | segment.ColorStart = Vector4(colorStart.x, colorStart.y, colorStart.z, opacityMax); |
| 119 | segment.ColorEnd = colorEnd; |
| 120 | segment.Life = |
| 121 | segment.LifeMax = lifeMax; |
| 122 | segment.Velocity = vel; |
| 123 | segment.ExpRate = expRate; |
| 124 | segment.Rotation = rot; |
| 125 | segment.InitializeVertices(pos, width); |
| 126 | } |
| 127 | |
| 128 | void Streamer::Update() |
| 129 | { |
no test coverage detected