convert line ends
[canaan.git] / prj / tech / libsrc / r3d / xfrmclip.c
blob1d7b6abbf4f47627fb393f9c0b84328d33f5c932
1 /*
2 * $Source: x:/prj/tech/libsrc/r3d/RCS/xfrmclip.c $
3 * $Revision: 1.7 $
4 * $Author: KEVIN $
5 * $Date: 1996/10/29 12:44:59 $
7 * Transform and projection definitions for clipping space
9 */
12 #include <xfrmtab.h>
13 #include <_xfrm.h>
14 #include <clipcon_.h>
15 #include <matrix.h>
17 extern void r3_clipspace_code_points(int, r3s_point *); // HACK HACK HACK
19 // go through and transform all the points.
20 // note that this also works for projection space, and
21 // unscaled space, but not linear, I think.
22 void r3_rotate_block_clip(int n, r3s_point *dst, mxs_vector *src)
24 uchar *cur, *last;
26 TEST_IN_BLOCK("r3_rotate_block_clip");
28 cur = (uchar *)(&(dst->p));
29 last = cur + n * r3d_glob.cur_stride;
31 while (cur < last) {
32 mx_trans_mul_vec((mxs_vector *)cur, X2TRANS(&cx.o2c), src++);
33 cur += r3d_glob.cur_stride;
36 if (r3d_clip_mode == R3_CLIP)
37 r3_clipspace_code_points(n, dst);
40 // This is only for clipped
41 void r3_project_block_clip(int n, r3s_point *p_list)
43 uchar *cur, *last;
45 TEST_IN_BLOCK("r3_project_block_clip");
47 cur = (uchar *)p_list;
48 last = cur + n * r3d_glob.cur_stride;
50 while (cur < last) {
51 r3s_point *p = (r3s_point *)cur;
52 double w;
54 cur += r3d_glob.cur_stride;
56 w = 1.0/p->p.z; // w is 1/z;
58 p->grp.sx = (int)((p->p.x * w * r3d_glob.x_prj) + r3d_glob.x_off);
59 p->grp.sy = (int)((p->p.y * w * r3d_glob.y_prj) + r3d_glob.y_off);
60 p->grp.w = w;
64 r3s_xform_tab r3d_xform_tab_clip = {
65 r3_rotate_block_clip,
66 r3_project_block_clip