Esempio n. 1
0
/*
===================
CM_SetBorderInward
===================
*/
static void CM_SetBorderInward(cFacet_t* facet, cTriangleSoup_t* triSoup, int i, int which) {
    int k, l;
    float* points[4];
    int numPoints;

    switch (which) {
        case 0:
            points[0] = triSoup->points[i][0];
            points[1] = triSoup->points[i][1];
            points[2] = triSoup->points[i][2];
            numPoints = 3;
            break;

        case 1:
            points[0] = triSoup->points[i][2];
            points[1] = triSoup->points[i][1];
            points[2] = triSoup->points[i][0];
            numPoints = 3;
            break;

        default:
            Sys::Error("CM_SetBorderInward: bad parameter %i", which);
    }

    for (k = 0; k < facet->numBorders; k++) {
        int front, back;

        front = 0;
        back = 0;

        for (l = 0; l < numPoints; l++) {
            int side;

            side = CM_PointOnPlaneSide(points[l], facet->borderPlanes[k]);

            if (side == SIDE_FRONT) {
                front++;
            }

            if (side == SIDE_BACK) {
                back++;
            }
        }

        if (front && !back) {
            facet->borderInward[k] = true;
        } else if (back && !front) {
            facet->borderInward[k] = false;
        } else if (!front && !back) {
            // flat side border
            facet->borderPlanes[k] = -1;
        } else {
            // bisecting side border
            cmLog.Debug("WARNING: CM_SetBorderInward: mixed plane sides\n");
            facet->borderInward[k] = false;
        }
    }
}
Esempio n. 2
0
/*
===================
CM_SetBorderInward
===================
*/
static void CM_SetBorderInward( cfacet_t *facet, cTriangleSoup_t *triSoup, int i, int which )
{
	float	*points[4];
	int	k, l, numPoints;

	switch( which )
	{
	case 0:
		points[0] = triSoup->points[i][0];
		points[1] = triSoup->points[i][1];
		points[2] = triSoup->points[i][2];
		numPoints = 3;
		break;
	case 1:
		points[0] = triSoup->points[i][2];
		points[1] = triSoup->points[i][1];
		points[2] = triSoup->points[i][0];
		numPoints = 3;
		break;
	default:
		Host_Error( "CM_SetBorderInward: bad parameter %i\n", which );
		numPoints = 0;
		break;
	}

	for( k = 0; k < facet->numBorders; k++ )
	{
		int	front, back;

		front = 0;
		back = 0;

		for( l = 0; l < numPoints; l++ )
		{
			int	side;

			side = CM_PointOnPlaneSide( points[l], facet->borderPlanes[k] );
			if( side == SIDE_FRONT ) front++;
			if( side == SIDE_BACK ) back++;
		}

		if( front && !back ) facet->borderInward[k] = true;
		else if( back && !front ) facet->borderInward[k] = false;
		else if( !front && !back ) facet->borderPlanes[k] = -1; // flat side border
		else
		{
			// bisecting side border
			MsgDev( D_WARN, "CM_SetBorderInward: mixed plane sides\n" );
			facet->borderInward[k] = false;
		}
	}
}
Esempio n. 3
0
/*
===================
CM_SetBorderInward
===================
*/
static void CM_SetBorderInward( facet_t *facet, cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID_SIZE][2],
								int i, int j, int which ) {
	int k, l;
	float   *points[4];
	int numPoints;

	switch ( which ) {
	case - 1:
		points[0] = grid->points[i][j];
		points[1] = grid->points[i + 1][j];
		points[2] = grid->points[i + 1][j + 1];
		points[3] = grid->points[i][j + 1];
		numPoints = 4;
		break;
	case 0:
		points[0] = grid->points[i][j];
		points[1] = grid->points[i + 1][j];
		points[2] = grid->points[i + 1][j + 1];
		numPoints = 3;
		break;
	case 1:
		points[0] = grid->points[i + 1][j + 1];
		points[1] = grid->points[i][j + 1];
		points[2] = grid->points[i][j];
		numPoints = 3;
		break;
	default:
		Com_Error( ERR_FATAL, "CM_SetBorderInward: bad parameter" );
		numPoints = 0;
		break;
	}

	for ( k = 0 ; k < facet->numBorders ; k++ ) {
		int front, back;

		front = 0;
		back = 0;

		for ( l = 0 ; l < numPoints ; l++ ) {
			int side;

			side = CM_PointOnPlaneSide( points[l], facet->borderPlanes[k] );
			if ( side == SIDE_FRONT ) {
				front++;
			}
			if ( side == SIDE_BACK ) {
				back++;
			}
		}

		if ( front && !back ) {
			facet->borderInward[k] = qtrue;
		} else if ( back && !front ) {
			facet->borderInward[k] = qfalse;
		} else if ( !front && !back ) {
			// flat side border
			facet->borderPlanes[k] = -1;
		} else {
			// bisecting side border
			Com_DPrintf( "WARNING: CM_SetBorderInward: mixed plane sides\n" );
			facet->borderInward[k] = qfalse;
			if ( !debugBlock ) {
				debugBlock = qtrue;
				VectorCopy( grid->points[i][j], debugBlockPoints[0] );
				VectorCopy( grid->points[i + 1][j], debugBlockPoints[1] );
				VectorCopy( grid->points[i + 1][j + 1], debugBlockPoints[2] );
				VectorCopy( grid->points[i][j + 1], debugBlockPoints[3] );
			}
		}
	}
}