~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina6/tina-tools/tinatool/draw/drawPaint_hidden.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  *
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  *
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/draw/drawPaint_hidden.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.4 $
 39  * CVS Id  :  $Id: drawPaint_hidden.c,v 1.4 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  : Legacy TINA
 42  *
 43  * Notes :
 44  *
 45  *********
 46 */
 47 
 48 #if HAVE_CONFIG_H
 49   #include <config.h>
 50 #endif
 51 
 52 #include <stdio.h>
 53 #include <math.h>
 54 #include <stdlib.h>
 55 #include <tina/sys/sysDef.h>
 56 #include <tina/sys/sysPro.h>
 57 #include <tina/math/mathDef.h>
 58 #include <tina/math/mathPro.h>
 59 #include <tina/geometry/geomDef.h>
 60 #include <tina/image/imgGen_get.h>
 61 #include <tinatool/draw/draw_TvDef.h>
 62 #include <tinatool/draw/draw_TvPro.h>
 63 #include <tinatool/draw/draw_PaintDef.h>
 64 #include <tinatool/draw/draw_PaintPro.h>
 65 
 66 #include "drawPaint_hidden.h"
 67 
 68 static Bool show_top = true;
 69 static Bool show_bot = true;
 70 
 71 static int *top_buff;
 72 static int *top_col;
 73 static int *bot_buff;
 74 static int *bot_col;
 75 static int width, height;
 76 
 77 void    tv_terrain_hidden_init(Tv * tv, Bool bot, Bool top)
 78 {
 79     int     i;
 80 
 81     if (tv == NULL)
 82         return;
 83 
 84     if (top_buff != NULL)
 85         ivector_free(top_buff, 0);
 86     if (top_col != NULL)
 87         ivector_free(top_col, 0);
 88     if (bot_buff != NULL)
 89         ivector_free(bot_buff, 0);
 90     if (bot_col != NULL)
 91         ivector_free(bot_col, 0);
 92 
 93     height = tv_get_height(tv);
 94     width = tv_get_width(tv);
 95     top_buff = ivector_alloc(0, width);
 96     top_col = ivector_alloc(0, width);
 97     bot_buff = ivector_alloc(0, width);
 98     bot_col = ivector_alloc(0, width);
 99 
100     for (i = 0; i < width; ++i)
101     {
102         top_buff[i] = height;
103         bot_buff[i] = 0;
104         top_col[i] = bot_col[i] = -1;
105     }
106 
107     show_bot = bot;
108     show_top = top;
109 }
110 
111 static void tv_points_between(Tv * tv, int x, int y1, int y2)
112 {
113     int     i, inc;
114 
115     if (y1 == y2)
116     {
117         tv_pointxy(tv, x, y1);
118         return;
119     }
120     inc = (y1 < y2) ? 1 : -1;
121 
122     for (i = y1 + inc;; i += inc)
123     {
124         tv_pointxy(tv, x, i);
125         if (i == y2)
126             break;
127     }
128 }
129 
130 static void tv_points_between_col(Tv * tv, int x, int y1, int y2, int col)
131 {
132     int     i, inc;
133 
134     tv_set_color(tv, col);
135     (void) tv_set_op(tv, rop_copy);
136     if (y1 == y2)
137         tv_pointxy(tv, x, y1);
138     else
139     {
140         inc = (y1 < y2) ? 1 : -1;
141 
142         for (i = y1 + inc;; i += inc)
143         {
144             tv_pointxy(tv, x, i);
145             if (i == y2)
146                 break;
147         }
148     }
149 }
150 
151 void    tv_hidden_line(Tv * tv, Ipos p1, Ipos p2, Bool fill, int col)
152 {
153     int     x1 = ipos_x(p1), y1 = ipos_y(p1), x2 = ipos_x(p2), y2 = ipos_y(p2);
154     int     i, j;
155     float   grad;
156 
157     if ((x1 < 0 && x2 < 0) || (x1 >= width && x2 >= width) ||
158         (false && y1 < 0 && y2 < 0) || (fill == false && y1 >= width && y2 >= width))
159         return;
160 
161     if (x1 > x2)
162     {
163         SWAP(int, x1, x2);
164         SWAP(int, y1, y2);
165     }
166     if (x1 != x2)
167         grad = ((float) (y2 - y1)) / (x2 - x1);
168 
169     /* make it fit on the screen */
170     if (x1 < 0)
171     {
172         y1 = (x2 == 0) ? y2 : (int)(y1 - x1 * grad);
173         x1 = 0;
174     }
175     if (x2 >= width)
176     {
177         y2 = (x1 == width - 1) ? y1 : (int)(y2 - (x2 + 1 - width) * grad);
178         x2 = width - 1;
179     }
180     /* now display line */
181 
182     if (x2 == x1)
183     {
184         ORDER(int, y1, y2);
185         if (show_top == true && y1 < top_buff[x1])
186         {
187             if (fill && top_col[x1] != -1)
188                 tv_points_between_col(tv, x1, top_buff[x1], y1, col);
189             if (y2 <= top_buff[x1])
190                 tv_points_between(tv, x1, y1, y2);
191             else
192                 tv_points_between(tv, x1, top_buff[x1], y1);
193             top_buff[x1] = y1;
194         }
195         if (show_bot == true && y2 > bot_buff[x1])
196         {
197             if (fill && bot_col[x1] != -1)
198                 tv_points_between_col(tv, x1, bot_buff[x1], y1, col);
199             if (y1 >= bot_buff[x1])
200                 tv_points_between(tv, x1, y1, y2);
201             else
202                 tv_points_between(tv, x1, bot_buff[x1], y2);
203             bot_buff[x1] = y2;
204         }
205         if (fill)
206             top_col[x1] = bot_col[x1] = col;
207         return;
208     }
209     /* compute new horizons and display them */
210 
211     if (show_top == true)
212     {
213         if (y1 < top_buff[x1])
214         {
215             if (fill && top_col[x1] != -1)
216                 tv_points_between_col(tv, x1, top_buff[x1], y1, top_col[x1]);
217             tv_pointxy(tv, x1, y1);
218             top_buff[x1] = y1;
219         }
220         if (fill)
221             top_col[x1] = col;
222 
223         for (i = x1; i < x2; i++)
224         {
225             j = (i + 1 == x2) ? y2 : (int)(y1 + (i + 1 - x1) * grad);
226 
227             if (j < top_buff[i + 1])
228             {
229                 if (fill && top_col[i + 1] != -1)
230                     tv_points_between_col(tv, i + 1, top_buff[i + 1], j, top_col[i + 1]);
231                 top_buff[i + 1] = j;
232             }
233             if (fill)
234                 top_col[i + 1] = col;
235             tv_points_between(tv, i + 1, top_buff[i], top_buff[i + 1]);
236         }
237     }
238     if (show_bot == true)
239     {
240         if (y1 > bot_buff[x1])
241         {
242             if (fill && bot_col[x1] != -1)
243                 tv_points_between_col(tv, x1, bot_buff[x1], y1, bot_col[x1]);
244             tv_pointxy(tv, x1, y1);
245             bot_buff[x1] = y1;
246         }
247         if (fill)
248             bot_col[x1] = col;
249 
250         for (i = x1; i < x2; i++)
251         {
252             j = (i + 1 == x2) ? y2 : (int)(y1 + (i + 1 - x1) * grad);
253             if (j > bot_buff[i + 1])
254             {
255                 if (fill && bot_col[i + 1] != -1)
256                     tv_points_between_col(tv, i + 1, bot_buff[i + 1], j, bot_col[i + 1]);
257                 bot_buff[i + 1] = j;
258             }
259             if (fill)
260                 bot_col[i + 1] = col;
261             tv_points_between(tv, i + 1, bot_buff[i], bot_buff[i + 1]);
262         }
263     }
264 }
265 
266 void    tv_terrain_hidden2(Tv * tv, Ipos ** p, int m, int n, int ir, int ic)
267 /* 2D array of ipos */
268 /* m rows and n cols */
269 /* increments in row and col directions */
270 {
271     Bool    rows_first;
272     int     fx, fy, lx, ly;
273     int     i, j;
274 
275     if (p == NULL || tv == NULL)
276         return;
277 
278     fy = (ir > 0) ? 0 : m - 1;
279     ly = (ir > 0) ? m - 1 : 0;
280     fx = (ic > 0) ? 0 : n - 1;
281     lx = (ic > 0) ? n - 1 : 0;
282 
283     /* determine screen orientation of terrain image */
284 
285     if (ipos_y(p[ly][fx]) == ipos_y(p[fy][fx]))
286         rows_first = true;
287     else if (ipos_y(p[fy][lx]) == ipos_y(p[fy][fx]))
288         rows_first = false;
289     else
290     {
291         Ipos    rvec = {Ipos_id};
292         Ipos    cvec = {Ipos_id};
293         double  rtan, ctan;
294 
295         rvec = ipos_diff(p[ly][fx], p[fy][fx]);
296         rtan = fabs((double) ipos_y(rvec) / ipos_x(rvec));
297         cvec = ipos_diff(p[fy][lx], p[fy][fx]);
298         ctan = fabs((double) ipos_y(cvec) / ipos_x(cvec));
299 
300         rows_first = (rtan > ctan) ? true : false;
301     }
302 
303     if (rows_first == true)
304     {                           /* rows first then cols */
305         for (j = fx; j != lx; j += ic)  /* display bug fix: draw first
306                                          * line twice */
307             tv_hidden_line(tv, p[fy][j], p[fy][j + ic], false, -1);
308         for (i = fy;; i += ir)
309         {
310             for (j = fx; j != lx; j += ic)
311                 tv_hidden_line(tv, p[i][j], p[i][j + ic], false, -1);
312             if (i == ly)
313                 break;
314             for (j = fx;; j += ic)
315             {
316                 tv_hidden_line(tv, p[i][j], p[i + ir][j], false, -1);
317                 if (j == lx)
318                     break;
319             }
320         }
321     } else
322     {                           /* cols first then rows */
323 
324         for (i = fy; i != ly; i += ir)
325             tv_hidden_line(tv, p[i][fx], p[i + ir][fx], false, -1);
326         for (j = fx;; j += ic)
327         {
328             for (i = fy; i != ly; i += ir)
329                 tv_hidden_line(tv, p[i][j], p[i + ir][j], false, -1);
330             if (j == lx)
331                 break;
332             for (i = fy;; i += ir)
333             {
334                 tv_hidden_line(tv, p[i][j], p[i][j + ic], false, -1);
335                 if (i == ly)
336                     break;
337             }
338         }
339     }
340 }
341 
342 static Vec3 vec3_zero_z(Vec3 p)
343 {
344     vec3_z(p) = (float)0.0;
345     return (p);
346 }
347 
348 static void terrain_closest_corner2(Tv * tv, Vec3 ** p, int m, int n, int *piy, int *pix)
349 
350 /* 2D array of ipos */
351 /* m rows and n cols */
352 
353 {
354     float   depth, min_depth;
355     Vec3    c = {Vec3_id};      /* corner location */
356     int     i, j;
357 
358     *piy = 1;                   /* default values */
359     *pix = 1;
360 
361     if (tv == NULL)
362         return;
363 
364     m--;
365     n--;                        /* index last row and col */
366     c = vec3_zero_z(p[0][0]);   /* do not include local variation in
367                                  * height */
368     min_depth = (float)vec3_dot(vec3_diff(c, tv->centre3), tv->ez3);
369     for (i = 0; i < 2; ++i)
370         for (j = 0; j < 2; ++j)
371             if (i != 0 || j != 0)
372             {
373                 c = vec3_zero_z(p[i * m][j * n]);
374                 depth = (float)vec3_dot(vec3_diff(c, tv->centre3), tv->ez3);
375                 if (depth < min_depth)
376                 {
377                     *piy = (i) ? -1 : 1;
378                     *pix = (j) ? -1 : 1;
379                     min_depth = depth;
380                 }
381             }
382 }
383 
384 static void terrain_closest_corner(Tv * tv, Vec3 ** p, int m, int n, int *piy, int *pix)
385 
386 /* 2D array of ipos */
387 /* m rows and n cols */
388 
389 {
390     int     max_y;
391     int     i, j;
392 
393     *piy = 1;                   /* default values */
394     *pix = 1;
395 
396     if (tv == NULL)
397         return;
398 
399     m--;
400     n--;                        /* index last row and col */
401     max_y = ipos_y(tv_proj3(tv, vec3_zero_z(p[0][0])));
402     for (i = 0; i < 2; ++i)
403         for (j = 0; j < 2; ++j)
404             if (i != 0 || j != 0)
405             {
406                 int     y = ipos_y(tv_proj3(tv, vec3_zero_z(p[i * m][j * n])));
407 
408                 if (y > max_y)
409                 {
410                     *piy = (i) ? -1 : 1;
411                     *pix = (j) ? -1 : 1;
412                     max_y = y;
413                 }
414             }
415 }
416 
417 void    tv_terrain3_mask(Tv * tv, Vec3 ** p, char **mask, int m, int n)
418 
419 /* 2D array of x, y, z points */
420 
421 /* m rows and n cols */
422 {
423     int     i, j;
424 
425     if (p == NULL)
426         return;
427 
428     for (i = 0; i < m; ++i)
429         for (j = 0; j < n; ++j)
430         {
431             if (mask != NULL && !mask[i][j])
432                 continue;
433             if (j != n - 1 && (mask == NULL || mask[i][j + 1]))
434                 tv_line3(tv, p[i][j], p[i][j + 1]);
435             if (i != m - 1 && (mask == NULL || mask[i + 1][j]))
436                 tv_line3(tv, p[i][j], p[i + 1][j]);
437         }
438 }
439 
440 void    tv_terrain3(Tv * tv, Vec3 ** p, int m, int n)
441 
442 /* 2D array of x, y, z points */
443 /* m rows and n cols */
444 {
445     int     i, j;
446 
447     if (p == NULL)
448         return;
449 
450     for (i = 0; i < m; ++i)
451         for (j = 0; j < n; ++j)
452         {
453             if (j != n - 1)
454                 tv_line3(tv, p[i][j], p[i][j + 1]);
455             if (i != m - 1)
456                 tv_line3(tv, p[i][j], p[i + 1][j]);
457         }
458 }
459 
460 void    tv_terrain_hidden3(Tv * tv, Vec3 ** p, int m, int n)
461 
462 /* 2D array of ipos */
463 /* m rows and n cols */
464 {
465     Ipos  **ip;
466     int     i, j;
467     int     inc_x, inc_y;
468 
469     if (p == NULL)
470         return;
471 
472     ip = ts_narray_alloc(0, 0, m, n, Ipos);
473 
474     for (i = 0; i < m; ++i)
475         for (j = 0; j < n; ++j)
476             ip[i][j] = tv_proj3(tv, p[i][j]);   /* create an array of
477                                                  * Ipos */
478 
479     terrain_closest_corner2(tv, p, m, n, &inc_y, &inc_x);
480     tv_terrain_hidden2(tv, ip, m, n, inc_y, inc_x);
481     narray_free((char **) ip, 0, 0, m, n, sizeof(Ipos));
482 }
483 
484 /* ARGSUSED Quieten Lint */
485 static int tv_mean_gl(Tv * tv, Imrect * im, Vec3 ** p, int r, int c, int ir, int ic)
486 {
487     double  x = 0, y = 0;
488     int     gl;
489 
490     y = vec3_y(p[r][c]) + vec3_y(p[r + ir][c]) + vec3_y(p[r][c + ic]) + vec3_y(p[r + ir][c + ic]);
491     x = vec3_x(p[r][c]) + vec3_x(p[r + ir][c]) + vec3_x(p[r][c + ic]) + vec3_x(p[r + ir][c + ic]);
492 
493     y /= 4;
494     x /= 4;
495 
496     gl = im_sub_pix(im, y, x);
497 
498     if (gl < 0)
499         gl = 0;
500     if (gl > 255)
501         gl = 255;
502 
503     return (gl);
504 }
505 
506 static Bool use_inclusive_col(Ipos v1, Ipos v2) /* image vectors for
507                                                  * pixel boundry */
508 
509 {
510     float   t1, t2;
511 
512     if (ipos_x(v1) == 0)
513         return (true);          /* it does not matter which colour is
514                                  * used */
515     if (ipos_x(v2) == 0)
516         return ((ipos_y(v2) < 0) ? true : false);
517 
518     if (ipos_y(v1) == 0)
519         return ((ipos_y(v2) < 0) ? true : false);
520     if (ipos_y(v2) == 0)
521     {
522         if (ipos_x(v1) * ipos_x(v2) < 0)        /* oposite x directions */
523             return ((ipos_y(v1) < 0) ? true : false);
524         else
525             return ((ipos_y(v1) < 0) ? false : true);
526     }
527     if (ipos_x(v1) * ipos_x(v2) < 0)    /* oposite x directions */
528         return (true);
529 
530     t1 = (float) ipos_y(v1) / abs(ipos_x(v1));  /* kind of tangent */
531     t2 = (float) ipos_y(v2) / abs(ipos_x(v2));  /* kind of tangent */
532 
533     return ((t1 > t2) ? true : false);
534 }
535 
536 void    tv_terrain_fill3(Tv * tv, Vec3 ** p, int m, int n, Imrect * im)
537 
538 /* 2D array of ipos */
539 /* m rows and n cols */
540 
541 {
542     int     i, j;
543     int     ir, ic;
544     int     fx, fy, lx, ly;
545     Ipos    p1 = {Ipos_id};
546     Ipos    p2 = {Ipos_id};
547     Ipos    p3 = {Ipos_id};
548     Bool    rows_first;
549     int     col;
550 
551     if (tv == NULL || p == NULL)
552         return;
553 
554     tv_save_draw(tv);
555     terrain_closest_corner(tv, p, m, n, &ir, &ic);
556 
557     fy = (ir > 0) ? 0 : m - 1;
558     ly = (ir > 0) ? m - 1 : 0;
559     fx = (ic > 0) ? 0 : n - 1;
560     lx = (ic > 0) ? n - 1 : 0;
561 
562     p1 = tv_proj3(tv, vec3_zero_z(p[fy][fx]));
563     p2 = tv_proj3(tv, vec3_zero_z(p[fy][lx]));
564     p3 = tv_proj3(tv, vec3_zero_z(p[ly][fx]));
565 
566     /* determine screen orientation of terrain image */
567 
568     if (ipos_y(p3) == ipos_y(p1))
569         rows_first = true;
570     else if (ipos_y(p2) == ipos_y(p1))
571         rows_first = false;
572     else
573     {
574         Ipos    rvec = {Ipos_id};
575         Ipos    cvec = {Ipos_id};
576         double  rtan, ctan;
577 
578         rvec = ipos_diff(p3, p1);
579         rtan = fabs((double) ipos_y(rvec) / ipos_x(rvec));
580         cvec = ipos_diff(p2, p1);
581         ctan = fabs((double) ipos_y(cvec) / ipos_x(cvec));
582 
583         rows_first = (rtan > ctan) ? true : false;
584     }
585 
586     rows_first = true;
587     if (rows_first == true)
588     {
589         for (j = fx; j != lx; j += ic)
590         {                       /* fix X display bug */
591             p1 = tv_proj3(tv, p[fy][j]);
592             p2 = tv_proj3(tv, p[fy][j + ic]);
593             tv_hidden_line(tv, p1, p2, false, -1);
594         }
595 
596         for (i = fy; i != ly; i += ir)
597         {
598             for (j = fx; j != lx; j += ic)
599             {
600                 p1 = tv_proj3(tv, p[i][j]);
601                 p2 = tv_proj3(tv, p[i][j + ic]);
602                 p3 = tv_proj3(tv, p[i + ir][j]);
603 
604                 if (i == fy)
605                     col = tv_mean_gl(tv, im, p, i, j, ir, ic);
606                 else if (use_inclusive_col(ipos_diff(p2, p1), ipos_diff(p3, p1)))
607                     col = tv_mean_gl(tv, im, p, i, j, ir, ic);
608                 else
609                     col = tv_mean_gl(tv, im, p, i, j, -ir, ic);
610                 tv_hidden_line(tv, p1, p2, true, col);
611             }
612             for (j = fx;; j += ic)
613             {
614                 p1 = tv_proj3(tv, p[i][j]);
615                 if (j != lx)
616                     p2 = tv_proj3(tv, p[i][j + ic]);
617                 p3 = tv_proj3(tv, p[i + ir][j]);
618 
619                 if (j == lx)
620                     col = tv_mean_gl(tv, im, p, i, j, ir, -ic);
621                 else if (j == fx)
622                     col = tv_mean_gl(tv, im, p, i, j, ir, ic);
623                 else if (use_inclusive_col(ipos_diff(p3, p1), ipos_diff(p2, p1)))
624                     col = tv_mean_gl(tv, im, p, i, j, ir, ic);
625                 else
626                     col = tv_mean_gl(tv, im, p, i, j, ir, -ic);
627                 tv_hidden_line(tv, p1, p3, true, col);
628                 if (j == lx)
629                     break;
630             }
631         }
632         for (j = fx; j != lx; j += ic)
633         {
634             p1 = tv_proj3(tv, p[ly][j]);
635             p2 = tv_proj3(tv, p[ly][j + ic]);
636             tv_hidden_line(tv, p1, p2, true, -1);
637         }
638     } else
639     {
640         for (i = fy; i != ly; i += ir)  /* fix X display bug */
641             tv_hidden_line(tv, tv_proj3(tv, p[i][fx]), tv_proj3(tv, p[i + ir][fx]), false, -1);
642 
643         for (j = fx;; j += ic)
644         {
645             for (i = fy; i != ly; i += ir)
646             {
647                 int     col = (i == ly) ? -1 : tv_mean_gl(tv, im, p, i, j, ir, ic);
648 
649                 tv_hidden_line(tv, tv_proj3(tv, p[i][j]), tv_proj3(tv, p[i + ir][j]), true, col);
650             }
651             if (j == lx)
652                 break;
653             for (i = fy;; i += ir)
654             {
655                 int     col = (i == ly || j == lx) ? -1 : tv_mean_gl(tv, im, p, i, j, ir, ic);
656 
657                 tv_hidden_line(tv, tv_proj3(tv, p[i][j]), tv_proj3(tv, p[i][j + ic]), true, col);
658                 if (i == ly)
659                     break;
660             }
661         }
662     }
663     tv_reset_draw(tv);
664 }
665 
666 void    tv_terrain_skel(Tv * tv, Vec3 ** p, char **mask, int m, int n)
667 
668 /* 2D array of x, y, z points */
669 
670 /* m rows and n cols */
671 {
672     int     r, c;
673     int     ic, ir;
674 
675     if (tv == NULL || p == NULL)
676         return;
677 
678     ir = (m > 8) ? m / 8 : 1;
679     ic = (n > 8) ? n / 8 : 1;
680 
681     for (r = 0; r < m; r += ir)
682     {
683         for (c = 0; c < n; c += ic)
684         {
685             if (mask != NULL && !mask[r][c])
686                 continue;
687             if (r + ir < m && (mask == NULL || mask[r + ir][c]))
688                 tv_line3(tv, p[r][c], p[r + ir][c]);
689             if (c + ic < n && (mask == NULL || mask[r][c + ic]))
690                 tv_line3(tv, p[r][c], p[r][c + ic]);
691         }
692     }
693 }
694 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.