Exemplo n.º 1
0
//===========================================================================
// returns the ground face the given point is above in the given area
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
aas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point)
{
	int i, facenum;
	vec3_t up = {0, 0, 1};
	vec3_t normal;
	aas_area_t *area;
	aas_face_t *face;

	if (!aasworld.loaded) return NULL;

	area = &aasworld.areas[areanum];
	for (i = 0; i < area->numfaces; i++)
	{
		facenum = aasworld.faceindex[area->firstface + i];
		face = &aasworld.faces[abs(facenum)];
		//if this is a ground face
		if (face->faceflags & FACE_GROUND)
		{
			//get the up or down normal
			if (aasworld.planes[face->planenum].normal[2] < 0) VectorNegate(up, normal);
			else VectorCopy(up, normal);
			//check if the point is in the face
			if (AAS_InsideFace(face, normal, point, 0.01f)) return face;
		} //end if
	} //end for
	return NULL;
} //end of the function AAS_AreaGroundFace
Exemplo n.º 2
0
//===========================================================================
// returns the face the trace end position is situated in
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
aas_face_t *AAS_TraceEndFace( aas_trace_t *trace ) {
	int i, facenum;
	aas_area_t *area;
	aas_face_t *face, *firstface = NULL;

	if ( !( *aasworld ).loaded ) {
		return NULL;
	}

	//if started in solid no face was hit
	if ( trace->startsolid ) {
		return NULL;
	}
	//trace->lastarea is the last area the trace was in
	area = &( *aasworld ).areas[trace->lastarea];
	//check which face the trace.endpos was in
	for ( i = 0; i < area->numfaces; i++ )
	{
		facenum = ( *aasworld ).faceindex[area->firstface + i];
		face = &( *aasworld ).faces[abs( facenum )];
		//if the face is in the same plane as the trace end point
		if ( ( face->planenum & ~1 ) == ( trace->planenum & ~1 ) ) {
			//firstface is used for optimization, if theres only one
			//face in the plane then it has to be the good one
			//if there are more faces in the same plane then always
			//check the one with the fewest edges first
/*			if (firstface)
			{
				if (firstface->numedges < face->numedges)
				{
					if (AAS_InsideFace(firstface,
						(*aasworld).planes[face->planenum].normal, trace->endpos))
					{
						return firstface;
					} //end if
					firstface = face;
				} //end if
				else
				{
					if (AAS_InsideFace(face,
						(*aasworld).planes[face->planenum].normal, trace->endpos))
					{
						return face;
					} //end if
				} //end else
			} //end if
			else
			{
				firstface = face;
			} //end else*/
			if ( AAS_InsideFace( face,
								 ( *aasworld ).planes[face->planenum].normal, trace->endpos, 0.01 ) ) {
				return face;
			}
		} //end if
	} //end for
	return firstface;
} //end of the function AAS_TraceEndFace