Skip to content

Commit

Permalink
Change appearance of tracers
Browse files Browse the repository at this point in the history
  • Loading branch information
yvt committed Jan 8, 2017
1 parent e07e826 commit 6d6e55b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
1 change: 0 additions & 1 deletion Sources/Client/Client_LocalEnts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "PaletteView.h"
#include "ParticleSpriteEntity.h"
#include "SmokeSpriteEntity.h"
#include "Tracer.h"

#include "GameMap.h"
#include "Grenade.h"
Expand Down
41 changes: 25 additions & 16 deletions Sources/Client/Tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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() {}
Expand Down

0 comments on commit 6d6e55b

Please sign in to comment.