cl_dll/view.cpp
void V_GetChaseOrigin(float* angles, float* origin, float distance, float* returnvec)
{
	Vector vecEnd;
	Vector forward;
	Vector vecStart;
	pmtrace_t* trace;
	int maxLoops = 8;

	int ignoreent = -1; // first, ignore no entity

	cl_entity_t* ent = NULL;

	// Trace back from the target using the player's view angles
	AngleVectors(angles, forward, NULL, NULL);

	VectorScale(forward, -1, forward);

	VectorCopy(origin, vecStart);

	VectorMA(vecStart, distance, forward, vecEnd);

	while (maxLoops > 0)
	{
		trace = gEngfuncs.PM_TraceLine(vecStart, vecEnd, PM_TRACELINE_PHYSENTSONLY, 2, ignoreent);

		// WARNING! trace->ent is is the number in physent list not the normal entity number

		if (trace->ent <= 0)
			break; // we hit the world or nothing, stop trace

		ent = gEngfuncs.GetEntityByIndex(PM_GetPhysEntInfo(trace->ent));

		if (ent == NULL)
			break;

		// hit non-player solid BSP , stop here
		if (ent->curstate.solid == SOLID_BSP && 0 == ent->player)
			break;

		// if close enought to end pos, stop, otherwise continue trace
		if (Distance(trace->endpos, vecEnd) < 1.0f)
		{
			break;
		}
		else
		{
			ignoreent = trace->ent; // ignore last hit entity
			VectorCopy(trace->endpos, vecStart);
		}

		maxLoops--;
	}

	/*	if ( ent )
	{
		gEngfuncs.Con_Printf("Trace loops %i , entity %i, model %s, solid %i\n",(8-maxLoops),ent->curstate.number, ent->model->name , ent->curstate.solid ); 
	} */

	VectorMA(trace->endpos, 4, trace->plane.normal, returnvec);

	v_lastDistance = Distance(trace->endpos, origin); // real distance without offset
}
// Get the origin of the Observer based around the target's position and angles
Get the origin of the Observer based around the target's position and angles
Get the origin of the Observer based around the target ' s position and angles
void V_GetChaseOrigin(float* angles, float* origin, float distance, float* returnvec)
{
	Vector vecEnd;
	Vector forward;
	Vector vecStart;
	pmtrace_t* trace;
	int maxLoops = 8;
	int ignoreent = -1; 
	cl_entity_t* ent = NULL;
	AngleVectors(angles, forward, NULL, NULL);
	VectorScale(forward, -1, forward);
	VectorCopy(origin, vecStart);
	VectorMA(vecStart, distance, forward, vecEnd);
	while (maxLoops > 0)
	{
		trace = gEngfuncs.PM_TraceLine(vecStart, vecEnd, PM_TRACELINE_PHYSENTSONLY, 2, ignoreent);
		if (trace->ent <= 0)
			break; 
		ent = gEngfuncs.GetEntityByIndex(PM_GetPhysEntInfo(trace->ent));
		if (ent == NULL)
			break;
		if (ent->curstate.solid == SOLID_BSP && 0 == ent->player)
			break;
		if (Distance(trace->endpos, vecEnd) < 1.0f)
		{
			break;
		}
		else
		{
			ignoreent = trace->ent; 
			VectorCopy(trace->endpos, vecStart);
		}
		maxLoops--;
	}
	VectorMA(trace->endpos, 4, trace->plane.normal, returnvec);
	v_lastDistance = Distance(trace->endpos, origin); 
}
void V_GetChaseOrigin ( float * angles , float * origin , float distance , float * returnvec ) { Vector vecEnd ; Vector forward ; Vector vecStart ; pmtrace_t * trace ; int maxLoops = 8 ; int ignoreent = -1 ; cl_entity_t * ent = NULL ; AngleVectors ( angles , forward , NULL , NULL ) ; VectorScale ( forward , -1 , forward ) ; VectorCopy ( origin , vecStart ) ; VectorMA ( vecStart , distance , forward , vecEnd ) ; while ( maxLoops > 0 ) { trace = gEngfuncs . PM_TraceLine ( vecStart , vecEnd , PM_TRACELINE_PHYSENTSONLY , 2 , ignoreent ) ; if ( trace -> ent <= 0 ) break ; ent = gEngfuncs . GetEntityByIndex ( PM_GetPhysEntInfo ( trace -> ent ) ) ; if ( ent == NULL ) break ; if ( ent -> curstate . solid == SOLID_BSP && 0 == ent -> player ) break ; if ( Distance ( trace -> endpos , vecEnd ) < 1.0f ) { break ; } else { ignoreent = trace -> ent ; VectorCopy ( trace -> endpos , vecStart ) ; } maxLoops -- ; } VectorMA ( trace -> endpos , 4 , trace -> plane . normal , returnvec ) ; v_lastDistance = Distance ( trace -> endpos , origin ) ; }
Get the origin of the Observer based around the target's position and angles
Get the origin of the Observer based around the target ' s position and angles
// first, ignore no entity // Trace back from the target using the player's view angles // WARNING! trace->ent is is the number in physent list not the normal entity number // we hit the world or nothing, stop trace // hit non-player solid BSP , stop here // if close enought to end pos, stop, otherwise continue trace // ignore last hit entity /*	if ( ent )
	{
		gEngfuncs.Con_Printf("Trace loops %i , entity %i, model %s, solid %i\n",(8-maxLoops),ent->curstate.number, ent->model->name , ent->curstate.solid ); 
	} */ // real distance without offset