Esempio n. 1
0
/*
================
CM_CreateNewFloatPlane
================
*/
static int CM_CreateNewFloatPlane(vec4_t plane)
{
#ifndef USE_HASHING

	// add a new plane
	if(numPlanes == SHADER_MAX_TRIANGLES) {
		Com_Error(ERR_DROP, "CM_FindPlane: SHADER_MAX_TRIANGLES");
	}

	Vector4Copy(plane, planes[numPlanes].plane);
	planes[numPlanes].signbits = CM_SignbitsForNormal(plane);

	numPlanes++;

	return numPlanes - 1;
#else

	cPlane_t *p;

	// create a new plane
	if(numPlanes == SHADER_MAX_TRIANGLES) {
		Com_Error(ERR_DROP, "CM_FindPlane: SHADER_MAX_TRIANGLES");
	}

	p = &planes[numPlanes];
	Vector4Copy(plane, p->plane);

	p->signbits = CM_SignbitsForNormal(plane);

	numPlanes++;

	CM_AddPlaneToHash(p);
	return numPlanes - 1;
#endif
}
Esempio n. 2
0
/*
==================
CM_FindPlane2
==================
*/
static int CM_FindPlane2( float plane[ 4 ], int *flipped )
{
	int i;

	// see if the points are close enough to an existing plane
	for ( i = 0; i < numPlanes; i++ )
	{
		if ( CM_PlaneEqual( &planes[ i ], plane, flipped ) )
		{
			return i;
		}
	}

	// add a new plane
	if ( numPlanes == MAX_PATCH_PLANES )
	{
		Com_Error( ERR_DROP, "CM_FindPlane2: MAX_PATCH_PLANES" );
	}

	Vector4Copy( plane, planes[ numPlanes ].plane );
	planes[ numPlanes ].signbits = CM_SignbitsForNormal( plane );

	numPlanes++;

	*flipped = qfalse;

	return numPlanes - 1;
}
Esempio n. 3
0
/*
==================
CM_FindPlane
==================
*/
static int CM_FindPlane( float *p1, float *p2, float *p3 )
{
	float plane[ 4 ];
	int   i;
	float d;

	if ( !CM_PlaneFromPoints( plane, p1, p2, p3 ) )
	{
		return -1;
	}

	// see if the points are close enough to an existing plane
	for ( i = 0; i < numPlanes; i++ )
	{
		if ( DotProduct( plane, planes[ i ].plane ) < 0 )
		{
			continue; // allow backwards planes?
		}

		d = DotProduct( p1, planes[ i ].plane ) - planes[ i ].plane[ 3 ];

		if ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON )
		{
			continue;
		}

		d = DotProduct( p2, planes[ i ].plane ) - planes[ i ].plane[ 3 ];

		if ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON )
		{
			continue;
		}

		d = DotProduct( p3, planes[ i ].plane ) - planes[ i ].plane[ 3 ];

		if ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON )
		{
			continue;
		}

		// found it
		return i;
	}

	// add a new plane
	if ( numPlanes == MAX_PATCH_PLANES )
	{
		Com_Error( ERR_DROP, "MAX_PATCH_PLANES" );
	}

	Vector4Copy( plane, planes[ numPlanes ].plane );
	planes[ numPlanes ].signbits = CM_SignbitsForNormal( plane );

	numPlanes++;

	return numPlanes - 1;
}
Esempio n. 4
0
/*
==================
CM_FindPlane
==================
*/
static int CM_FindPlane( bfixed *p1, bfixed *p2, bfixed *p3 ) {
	planeDef_t plane;
	int		i;
	bfixed	d;

	if ( !CM_PlaneFromPoints( plane, p1, p2, p3 ) ) {
		return -1;
	}

	// see if the points are close enough to an existing plane
	for ( i = 0 ; i < numPlanes ; i++ ) {
		if ( FIXED_VEC3DOT( plane.normal, planes[i].pd.normal ) < AFIXED_0 ) {
			continue;	// allow backwards planes?
		}

		d = FIXED_VEC3DOT( p1, planes[i].pd.normal ) - planes[i].pd.dist;
		if ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON ) {
			continue;
		}

		d = FIXED_VEC3DOT( p2, planes[i].pd.normal ) - planes[i].pd.dist;
		if ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON ) {
			continue;
		}

		d = FIXED_VEC3DOT( p3, planes[i].pd.normal ) - planes[i].pd.dist;
		if ( d < -PLANE_TRI_EPSILON || d > PLANE_TRI_EPSILON ) {
			continue;
		}

		// found it
		return i;
	}

	// add a new plane
	if ( numPlanes == MAX_PATCH_PLANES ) {
		Com_Error( ERR_DROP, "MAX_PATCH_PLANES" );
	}

	planes[numPlanes].pd=plane;
	planes[numPlanes].signbits = CM_SignbitsForNormal( plane.normal );

	numPlanes++;

	return numPlanes-1;
}
Esempio n. 5
0
/*
================
CM_CreateNewFloatPlane
================
*/
static int CM_CreateNewFloatPlane( vec4_t plane )
{
	cPlane_t *p; //, temp;

	// create a new plane
	if ( numPlanes == SHADER_MAX_TRIANGLES )
	{
		Sys::Drop( "CM_FindPlane: SHADER_MAX_TRIANGLES" );
	}

	p = &planes[ numPlanes ];
	Vector4Copy( plane, p->plane );

	p->signbits = CM_SignbitsForNormal( plane );

	numPlanes++;

	CM_AddPlaneToHash( p );
	return numPlanes - 1;
}
Esempio n. 6
0
/*
==================
CM_FindPlane2
==================
*/
int CM_FindPlane2(planeDef_t &plane, int *flipped) {
	int i;

	// see if the points are close enough to an existing plane
	for ( i = 0 ; i < numPlanes ; i++ ) {
		if (CM_PlaneEqual(&planes[i], plane, flipped)) return i;
	}

	// add a new plane
	if ( numPlanes == MAX_PATCH_PLANES ) {
		Com_Error( ERR_DROP, "MAX_PATCH_PLANES" );
	}

	planes[numPlanes].pd=plane;
	planes[numPlanes].signbits = CM_SignbitsForNormal( plane.normal );

	numPlanes++;

	*flipped = qfalse;

	return numPlanes-1;
}