| 258 | } |
| 259 | |
| 260 | void Renderer::PrepareElectricity(RenderView& view) |
| 261 | { |
| 262 | if (ElectricityArcs.empty()) |
| 263 | return; |
| 264 | |
| 265 | if (!CheckIfSlotExists(ID_DEFAULT_SPRITES, "Electricity rendering")) |
| 266 | return; |
| 267 | |
| 268 | for (const auto& arc : ElectricityArcs) |
| 269 | { |
| 270 | if (arc.life <= 0) |
| 271 | continue; |
| 272 | |
| 273 | ElectricityKnots[0] = Vector3::Lerp(arc.PrevPos1, arc.pos1, GetInterpolationFactor()); |
| 274 | ElectricityKnots[1] = Vector3::Lerp(arc.PrevPos1, arc.pos1, GetInterpolationFactor()); |
| 275 | ElectricityKnots[2] = Vector3::Lerp(arc.PrevPos2, arc.pos2, GetInterpolationFactor()); |
| 276 | ElectricityKnots[3] = Vector3::Lerp(arc.PrevPos3, arc.pos3, GetInterpolationFactor()); |
| 277 | ElectricityKnots[4] = Vector3::Lerp(arc.PrevPos4, arc.pos4, GetInterpolationFactor()); |
| 278 | ElectricityKnots[5] = Vector3::Lerp(arc.PrevPos4, arc.pos4, GetInterpolationFactor()); |
| 279 | |
| 280 | for (int j = 0; j < ElectricityKnots.size(); j++) |
| 281 | ElectricityKnots[j] -= LaraItem->Pose.Position.ToVector3(); |
| 282 | |
| 283 | CalculateElectricitySpline(arc, ElectricityKnots, ElectricityBuffer); |
| 284 | |
| 285 | if (abs(ElectricityKnots[0].x) <= ELECTRICITY_RANGE_MAX && |
| 286 | abs(ElectricityKnots[0].y) <= ELECTRICITY_RANGE_MAX && |
| 287 | abs(ElectricityKnots[0].z) <= ELECTRICITY_RANGE_MAX) |
| 288 | { |
| 289 | int bufferIndex = 0; |
| 290 | |
| 291 | auto& interpPosArray = ElectricityBuffer; |
| 292 | |
| 293 | for (int s = 0; s < ((arc.segments * 3) - 1); s++) |
| 294 | { |
| 295 | auto origin = (LaraItem->Pose.Position + interpPosArray[bufferIndex]).ToVector3(); |
| 296 | bufferIndex++; |
| 297 | auto target = (LaraItem->Pose.Position + interpPosArray[bufferIndex]).ToVector3(); |
| 298 | |
| 299 | auto center = (origin + target) / 2; |
| 300 | auto dir = target - origin; |
| 301 | dir.Normalize(); |
| 302 | |
| 303 | byte r, g, b; |
| 304 | if (arc.life >= 16) |
| 305 | { |
| 306 | r = arc.r; |
| 307 | g = arc.g; |
| 308 | b = arc.b; |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | r = (arc.life * arc.r) / 16; |
| 313 | g = (arc.life * arc.g) / 16; |
| 314 | b = (arc.life * arc.b) / 16; |
| 315 | } |
| 316 | |
| 317 |
nothing calls this directly
no test coverage detected