Exemple #1
0
/**
 * This function is used to calcualte if an entity can be seen.
 * Returns the angle in test and true if the entity can be seen, else it returns false
 */
bool IsInView(vec3_t eyes1, vec3_t eyes2, edict_t *bot, edict_t *nmy, int fov, vec3_t test) {
	vec3_t origin;
	float test2;

	if (Traceline(eyes1, eyes2, bot, nmy)) // If the bot can see his enemy
	{
		VectorSubtract(eyes1, eyes2, origin); // Get a nice vector
		CalcAngles(origin, test); // And use it to see in what direction the enemy is
		test2 = test[1] - bot->v.angles[1]; // Another shortcut

		return (test2 > -fov && test2 < fov); // If enemy is in front of the bot so he can see him
	}
	return false;
}
Exemple #2
0
//===========================================================================
int CheckBorders(int *NumNodesUsed, int NumNodes, NODE *Node, int *NumTris, TRI **pTri)
{
	int border;
	int i, j, k0, k1, N;
	float angle[3];
	TRI *Tri;

	N = NumNodesUsed[0];
	Tri = *pTri;
	for(i=0; i<NumTris[0]; i++)
	{
		EdgeOnSide(Tri[i].v,&k0,&border);
		if(border < 0) continue;
		CalcAngles(Node, Tri[i].v, angle);
		k1 = (k0+1) % 3;
		if((angle[k0] < SLIVER_ANGLE) || (angle[k1] < SLIVER_ANGLE))
		{
			j = Bisect(Node, border, Tri[i].v[k0], Tri[i].v[k1]);
			if(j >= 0)
			{
				if(!Node[j].used)    // Shouldn't be used, but...
				{
					NumNodesUsed[0]++;
					Node[j].used++;
				}
			}
		}
	}
	if(NumNodesUsed[0] > N)
	{
		free(*pTri);
		tricall(NumNodes, Node, NumTris, NULL, pTri, "cnzBNPY");
		Tri = *pTri;
	}
	return (NumNodesUsed[0] - N);
}