Пример #1
0
static void CalcPlane (SlopeWork &slope, secplane_t &plane)
{
	DVector3 pt[3];
	long j;

	slope.x[0] = slope.wal->x;  slope.y[0] = slope.wal->y;
	slope.x[1] = slope.wal2->x; slope.y[1] = slope.wal2->y;
	if (slope.dx == 0)
	{
		slope.x[2] = slope.x[0] + 64;
		slope.y[2] = slope.y[0];
	}
	else
	{
		slope.x[2] = slope.x[0];
		slope.y[2] = slope.y[0] + 64;
	}
	j = DMulScale3 (slope.dx, slope.y[2]-slope.wal->y, -slope.dy, slope.x[2]-slope.wal->x);
	slope.z[2] += Scale (slope.heinum, j, slope.i);

	pt[0] = DVector3(slope.dx, -slope.dy, 0);
	pt[1] = DVector3(slope.x[2] - slope.x[0], slope.y[0] - slope.y[2], (slope.z[2] - slope.z[0]) / 16);
	pt[2] = (pt[0] ^ pt[1]).Unit();

	if ((pt[2][2] < 0 && plane.fC() > 0) || (pt[2][2] > 0 && plane.fC() < 0))
	{
		pt[2] = -pt[2];
	}

	double dist = -pt[2][0] * slope.x[0] * 16 + pt[2][1] * slope.y[0] * 16 - pt[2][2] * slope.z[0];
	plane.set(pt[2][0], pt[2][1], pt[2][2], dist);
}
Пример #2
0
static void CalcPlane (SlopeWork &slope, secplane_t &plane)
{
    FVector3 pt[3];
    long j;

    slope.x[0] = slope.wal->x;
    slope.y[0] = slope.wal->y;
    slope.x[1] = slope.wal2->x;
    slope.y[1] = slope.wal2->y;
    if (slope.dx == 0)
    {
        slope.x[2] = slope.x[0] + 64;
        slope.y[2] = slope.y[0];
    }
    else
    {
        slope.x[2] = slope.x[0];
        slope.y[2] = slope.y[0] + 64;
    }
    j = DMulScale3 (slope.dx, slope.y[2]-slope.wal->y,
                    -slope.dy, slope.x[2]-slope.wal->x);
    slope.z[2] += Scale (slope.heinum, j, slope.i);

    pt[0] = FVector3(slope.dx, -slope.dy, 0);
    pt[1] = FVector3(slope.x[2] - slope.x[0], slope.y[0] - slope.y[2], (slope.z[2] - slope.z[0]) / 16);
    pt[2] = (pt[0] ^ pt[1]).Unit();

    if ((pt[2][2] < 0 && plane.c > 0) || (pt[2][2] > 0 && plane.c < 0))
    {
        pt[2] = -pt[2];
    }

    plane.a = fixed_t(pt[2][0]*65536.f);
    plane.b = fixed_t(pt[2][1]*65536.f);
    plane.c = fixed_t(pt[2][2]*65536.f);
    plane.ic = fixed_t(65536.f/pt[2][2]);
    plane.d = -TMulScale8
              (plane.a, slope.x[0]<<4, plane.b, (-slope.y[0])<<4, plane.c, slope.z[0]);
}