Example #1
0
/*
 * Sv_Trace
 *
 * Moves the given box volume through the world from start to end.
 *
 * The skipped edict, and edicts owned by him, are explicitly not checked.
 * This prevents players from clipping against their own projectiles, etc.
 */
c_trace_t Sv_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end,
		g_edict_t *skip, int contentmask) {

	sv_trace_t trace;

	memset(&trace, 0, sizeof(sv_trace_t));

	if (!mins)
		mins = vec3_origin;
	if (!maxs)
		maxs = vec3_origin;

	// clip to world
	trace.trace = Cm_BoxTrace(start, end, mins, maxs, 0, contentmask);
	trace.trace.ent = svs.game->edicts;

	if (trace.trace.fraction == 0)
		return trace.trace; // blocked by the world

	trace.start = start;
	trace.end = end;
	trace.mins = mins;
	trace.maxs = maxs;
	trace.skip = skip;
	trace.contentmask = contentmask;

	// create the bounding box of the entire move
	Sv_TraceBounds(&trace);

	// clip to other solid entities
	Sv_ClipTraceToEntities(&trace);

	return trace.trace;
}
Example #2
0
/*
 * @brief Client-side collision model tracing. This is the reciprocal of
 * Sv_Trace.
 *
 * @param skip An optional entity number for which all tests are skipped. Pass
 * 0 for none, because entity 0 is the world, which we always test.
 */
cm_trace_t Cl_Trace(const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs,
		const uint16_t skip, const int32_t contents) {

	cl_trace_t trace;

	memset(&trace, 0, sizeof(trace));

	if (!mins)
		mins = vec3_origin;
	if (!maxs)
		maxs = vec3_origin;

	// clip to world
	trace.trace = Cm_BoxTrace(start, end, mins, maxs, 0, contents);
	if (trace.trace.fraction < 1.0) {
		trace.trace.ent = (struct g_entity_s *) (intptr_t) -1;

		if (trace.trace.start_solid) { // blocked entirely
			return trace.trace;
		}
	}

	trace.start = start;
	trace.end = end;
	trace.mins = mins;
	trace.maxs = maxs;
	trace.skip = skip;
	trace.contents = contents;

	Cl_ClipTraceToEntities(&trace);

	return trace.trace;
}
Example #3
0
/*
 * Cl_Trace
 */
static c_trace_t Cl_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end) {
	c_trace_t t;

	// check against world
	t = Cm_BoxTrace(start, end, mins, maxs, 0, MASK_PLAYER_SOLID);
	if (t.fraction < 1.0)
		t.ent = (struct g_edict_s *) 1;

	// check all other solid models
	Cl_ClipMoveToEntities(start, mins, maxs, end, &t);

	return t;
}
Example #4
0
/**
 * @brief Moves the given box volume through the world from start to end.
 *
 * The skipped edict, and edicts owned by him, are explicitly not checked.
 * This prevents players from clipping against their own projectiles, etc.
 */
cm_trace_t Sv_Trace(const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs,
                    const g_entity_t *skip, const int32_t contents) {

	sv_trace_t trace;

	memset(&trace, 0, sizeof(trace));

	if (!mins) {
		mins = vec3_origin;
	}
	if (!maxs) {
		maxs = vec3_origin;
	}

	// clip to world
	trace.trace = Cm_BoxTrace(start, end, mins, maxs, 0, contents);
	if (trace.trace.fraction < 1.0) {
		trace.trace.ent = svs.game->entities;

		if (trace.trace.start_solid) { // blocked entirely
			return trace.trace;
		}
	}

	trace.start = start;
	trace.end = end;
	trace.mins = mins;
	trace.maxs = maxs;
	trace.skip = skip;
	trace.contents = contents;

	// create the bounding box of the entire move
	Cm_TraceBounds(start, end, mins, maxs, trace.box_mins, trace.box_maxs);

	// clip to other solid entities
	Sv_ClipTraceToEntities(&trace);

	return trace.trace;
}