From 6d6e55b7f8d947c5ad030bea7344ee72ee818c58 Mon Sep 17 00:00:00 2001 From: yvt Date: Mon, 9 Jan 2017 03:45:37 +0900 Subject: [PATCH] Change appearance of tracers --- Sources/Client/Client_LocalEnts.cpp | 1 - Sources/Client/Tracer.cpp | 41 ++++++++++++++++++----------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Sources/Client/Client_LocalEnts.cpp b/Sources/Client/Client_LocalEnts.cpp index e4e8c03a3..249fb00ff 100644 --- a/Sources/Client/Client_LocalEnts.cpp +++ b/Sources/Client/Client_LocalEnts.cpp @@ -44,7 +44,6 @@ #include "PaletteView.h" #include "ParticleSpriteEntity.h" #include "SmokeSpriteEntity.h" -#include "Tracer.h" #include "GameMap.h" #include "Grenade.h" diff --git a/Sources/Client/Tracer.cpp b/Sources/Client/Tracer.cpp index 14ecdc607..26ff9eba5 100644 --- a/Sources/Client/Tracer.cpp +++ b/Sources/Client/Tracer.cpp @@ -17,10 +17,12 @@ namespace spades { dir = (p2 - p1).Normalize(); length = (p2 - p1).GetLength(); - const float maxTimeSpread = 1.f / 60.f; - const float shutterTime = .3f / 60.f; + velocity *= 0.5f; // make it slower for visual effect - visibleLength = shutterTime * bulletVel; + const float maxTimeSpread = 1.0f / 30.f; + const float shutterTime = 1.0f / 30.f; + + visibleLength = shutterTime * velocity; curDistance = -visibleLength; curDistance += maxTimeSpread * GetRandom(); @@ -41,20 +43,27 @@ namespace spades { } void Tracer::Render3D() { - float startDist = curDistance; - float endDist = curDistance + visibleLength; - startDist = std::max(startDist, 0.f); - endDist = std::min(endDist, length); - if (startDist >= endDist) { - return; - } + for (float step = 0.0f; step <= 1.0f; step += 0.1f) { + float startDist = curDistance; + float endDist = curDistance + visibleLength; + + float midDist = (startDist + endDist) * 0.5f; + startDist = Mix(startDist, midDist, step); + endDist = Mix(endDist, midDist, step); - Vector3 pos1 = startPos + dir * startDist; - Vector3 pos2 = startPos + dir * endDist; - IRenderer *r = client->GetRenderer(); - Vector4 col = {1.f, .6f, .2f, 0.f}; - r->SetColorAlphaPremultiplied(col * 1.3f); - r->AddLongSprite(image, pos1, pos2, .05f); + startDist = std::max(startDist, 0.f); + endDist = std::min(endDist, length); + if (startDist >= endDist) { + continue; + } + + Vector3 pos1 = startPos + dir * startDist; + Vector3 pos2 = startPos + dir * endDist; + IRenderer *r = client->GetRenderer(); + Vector4 col = {1.f, .6f, .2f, 0.f}; + r->SetColorAlphaPremultiplied(col * 0.4f); + r->AddLongSprite(image, pos1, pos2, .05f); + } } Tracer::~Tracer() {}