1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef _TRACE_RAY_H
#define _TRACE_RAY_H
#include <vector>
class float3;
class CUnit;
class CFeature;
class CWeapon;
class CPlasmaRepulser;
class CSolidObject;
struct CollisionQuery;
namespace Collision {
enum {
NOENEMIES = 1,
NOFRIENDLIES = 2,
NOFEATURES = 4,
NONEUTRALS = 8,
NOGROUND = 16,
NOCLOAKED = 32,
BOOLEAN = 64, // skip further tests after the first collision (unused)
NOUNITS = NOENEMIES | NOFRIENDLIES | NONEUTRALS
};
}
namespace TraceRay {
struct SShieldDist {
CPlasmaRepulser* rep;
float dist;
};
// TODO: extend with allyTeam param s.t. we can add Collision::NO{LOS,RADAR}, etc.
float TraceRay(
const float3& start,
const float3& dir,
float length,
int avoidFlags,
const CUnit* owner,
CUnit*& hitUnit,
CFeature*& hitFeature,
CollisionQuery* hitColQuery = 0x0
);
void TraceRayShields(
const CWeapon* emitter,
const float3& start,
const float3& dir,
float length,
std::vector<SShieldDist>& hitShields
);
float GuiTraceRay(
const float3& start,
const float3& dir,
const float length,
const CUnit* exclude,
const CUnit*& hitUnit,
const CFeature*& hitFeature,
bool useRadar,
bool groundOnly = false,
bool ignoreWater = true
);
/**
* @return true if there is an object (allied/neutral unit, feature)
* within the firing cone of \<owner\> (that might be hit)
*/
bool TestCone(
const float3& from,
const float3& dir,
float length,
float spread,
int allyteam,
int avoidFlags,
CUnit* owner);
/**
* @return true if there is an object (allied/neutral unit, feature)
* within the firing trajectory of \<owner\> (that might be hit)
*/
bool TestTrajectoryCone(
const float3& from,
const float3& dir,
float length,
float linear,
float quadratic,
float spread,
int allyteam,
int avoidFlags,
CUnit* owner);
}
#endif // _TRACE_RAY_H
|