convert line ends
[canaan.git] / prj / tech / libsrc / r3d / clipclip.c
blobc60bb6691aa74ec2fd35de9378abff757b41ca6e
1 // $Header: x:/prj/tech/libsrc/r3d/RCS/clipclip.c 1.9 1996/10/29 12:44:47 KEVIN Exp $
3 // clipping is:
4 // off the right is y < -x
5 // off the left is y > x
6 // off the top is z > x
7 // off the bottom is z < -x
9 // clipspace clipping
11 #include <r3ds.h>
12 #include <clip_.h>
13 #include <clipcon_.h>
14 #include <clipoff.h>
15 #include <_test.h>
17 void r3_clipspace_code_points(int n, r3s_point *src)
19 uchar *cur, *last;
20 mxs_real nearxxx = r3d_near_plane;
22 TEST_IN_BLOCK("r3_clipspace_code_points");
24 cur = (uchar *)src;
25 last = cur + n * r3d_glob.cur_stride;
27 while (cur < last) {
28 r3s_point *p = (r3s_point *)cur;
29 int code = 0;
30 mxs_real z = p->p.z;
32 cur += r3d_glob.cur_stride;
34 if (p->p.x > z) code = R3C_OFF_RIGHT; else code = R3C_NONE;
35 if (p->p.x < -z) code |= R3C_OFF_LEFT;
37 if (p->p.y < -z) code |= R3C_OFF_TOP;
38 if (p->p.y > z) code |= R3C_OFF_BOTTOM;
40 if (z < nearxxx) code |= R3C_BEHIND;
42 p->ccodes = code;
45 if (r3d_num_planes)
46 r3_std_code_points(n, src);