Skip to content

Commit

Permalink
Track projectiles until their demise
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn-ali-goransson committed Apr 30, 2020
1 parent fc41514 commit 11266b0
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions src/display3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,13 +1404,21 @@ static void calcFlagPosScreenCoords(SDWORD *pX, SDWORD *pY, SDWORD *pR, const gl
*pR = radius;
}

struct SMOKETRAIL
{
int projectileId;
};

static std::map<uint32_t, SMOKETRAIL> projectileSmokeTrails;

static void display3DProjectileSmokeTrails(const glm::mat4 &viewMatrix)
{
glm::vec3 pt0;
glm::vec3 pt1;
glm::vec3 pt2;

WEAPON_STATS *psStats;
std::map<uint32_t, SMOKETRAIL> smokeTrailsLeft = projectileSmokeTrails;

Vector3i dv;
Spacetime st;

Expand All @@ -1421,26 +1429,29 @@ static void display3DProjectileSmokeTrails(const glm::mat4 &viewMatrix)
continue;
}

psStats = psObj->psWStats;
/* Reject flame or command since they have interim drawn fx */
if (psStats->weaponSubClass == WSC_FLAME ||
psStats->weaponSubClass == WSC_COMMAND || // || psStats->weaponSubClass == WSC_ENERGY)
psStats->weaponSubClass == WSC_ELECTRONIC ||
psStats->weaponSubClass == WSC_EMP ||
(bMultiPlayer && psStats->weaponSubClass == WSC_LAS_SAT))
{
/* We don't do projectiles from these guys, cos there's an effect instead */
if (psObj->psWStats->weaponSubClass == WSC_FLAME || psObj->psWStats->weaponSubClass == WSC_COMMAND || psObj->psWStats->weaponSubClass == WSC_ELECTRONIC || psObj->psWStats->weaponSubClass == WSC_EMP || (bMultiPlayer && psObj->psWStats->weaponSubClass == WSC_LAS_SAT))
{
continue;
}

st = interpolateObjectSpacetime(psObj, graphicsTime);

if (!clipXYZ(st.pos.x, st.pos.y, st.pos.z, viewMatrix))
{
continue; // somehow crashes the game
continue;
}

for (iIMDShape *pIMD = psStats->pInFlightGraphic; pIMD != nullptr; pIMD = pIMD->next)
if(smokeTrailsLeft.count(psObj->id))
{
smokeTrailsLeft.erase(psObj->id);
}
else
{
printf("Start tracking %i\n", psObj->id);
projectileSmokeTrails[psObj->id] = SMOKETRAIL();
}

for (iIMDShape *pIMD = psObj->psWStats->pInFlightGraphic; pIMD != nullptr; pIMD = pIMD->next)
{
dv.x = st.pos.x - player.p.x;
dv.z = -(st.pos.y - player.p.z);
Expand All @@ -1455,6 +1466,12 @@ static void display3DProjectileSmokeTrails(const glm::mat4 &viewMatrix)
}


for (std::map<uint32_t, SMOKETRAIL>::iterator i = smokeTrailsLeft.begin() ; i != smokeTrailsLeft.end() ; i ++ ) {
printf("Stop tracking %i\n", i->first);
projectileSmokeTrails.erase(i->first);
}





Expand Down

0 comments on commit 11266b0

Please sign in to comment.