~ubuntu-branches/ubuntu/trusty/radiance/trusty-proposed

« back to all changes in this revision

Viewing changes to src/rt/rtrace.c

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2011-04-10 11:39:02 UTC
  • mfrom: (1.4.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110410113902-8qs87nswt3esypdt
Tags: 4R0+20110410-1
* [9cf38d99] Refreshing patches.
* [d482db14] CVS HEAD (2011-04-10) (Closes: #565085, LP: #755968)
* [41d6f871] Patch srv/cal/Rmakefile to not depend on common/tiff.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef lint
2
 
static const char       RCSid[] = "$Id: rtrace.c,v 2.64 2010/09/26 15:49:39 greg Exp $";
 
2
static const char       RCSid[] = "$Id: rtrace.c,v 2.65 2011/04/06 00:14:26 greg Exp $";
3
3
#endif
4
4
/*
5
5
 *  rtrace.c - program and variables for individual ray tracing.
53
53
 
54
54
static RAY  thisray;                    /* for our convenience */
55
55
 
56
 
typedef void putf_t(double v);
 
56
typedef void putf_t(RREAL *v, int n);
57
57
static putf_t puta, putd, putf;
58
58
 
59
59
typedef void oputf_t(RAY *r);
494
494
        RAY  *r
495
495
)
496
496
{
497
 
        (*putreal)(r->rorg[0]);
498
 
        (*putreal)(r->rorg[1]);
499
 
        (*putreal)(r->rorg[2]);
 
497
        (*putreal)(r->rorg, 3);
500
498
}
501
499
 
502
500
 
505
503
        RAY  *r
506
504
)
507
505
{
508
 
        (*putreal)(r->rdir[0]);
509
 
        (*putreal)(r->rdir[1]);
510
 
        (*putreal)(r->rdir[2]);
 
506
        (*putreal)(r->rdir, 3);
511
507
}
512
508
 
513
509
 
516
512
        RAY  *r
517
513
)
518
514
{
 
515
        RREAL   cval[3];
 
516
 
519
517
        if (outform == 'c') {
520
518
                COLR  cout;
521
519
                setcolr(cout,   colval(r->rcol,RED),
522
520
                                colval(r->rcol,GRN),
523
521
                                colval(r->rcol,BLU));
524
 
                fwrite((char *)cout, sizeof(cout), 1, stdout);
 
522
                fwrite(cout, sizeof(cout), 1, stdout);
525
523
                return;
526
524
        }
527
 
        (*putreal)(colval(r->rcol,RED));
528
 
        (*putreal)(colval(r->rcol,GRN));
529
 
        (*putreal)(colval(r->rcol,BLU));
 
525
        cval[0] = colval(r->rcol,RED);
 
526
        cval[1] = colval(r->rcol,GRN);
 
527
        cval[2] = colval(r->rcol,BLU);
 
528
        (*putreal)(cval, 3);
530
529
}
531
530
 
532
531
 
535
534
        RAY *r
536
535
)
537
536
{
538
 
        double  contr[3];
 
537
        RREAL   contr[3];
539
538
 
540
539
        raycontrib(contr, r, PRIMARY);
541
540
        multcolor(contr, r->rcol);
542
 
        (*putreal)(contr[RED]);
543
 
        (*putreal)(contr[GRN]);
544
 
        (*putreal)(contr[BLU]);
 
541
        (*putreal)(contr, 3);
545
542
}
546
543
 
547
544
 
550
547
        RAY  *r
551
548
)
552
549
{
553
 
        (*putreal)(r->rt);
 
550
        (*putreal)(&r->rt, 1);
554
551
}
555
552
 
556
553
 
559
556
        RAY  *r
560
557
)
561
558
{
562
 
        (*putreal)(r->rot);
 
559
        (*putreal)(&r->rot, 1);
563
560
}
564
561
 
565
562
 
568
565
        RAY  *r
569
566
)
570
567
{
571
 
        (*putreal)(r->uv[0]);
572
 
        (*putreal)(r->uv[1]);
 
568
        (*putreal)(r->uv, 2);
573
569
}
574
570
 
575
571
 
 
572
static RREAL    vdummy[3] = {0.0, 0.0, 0.0};
 
573
 
 
574
 
576
575
static void
577
576
oputp(                          /* print point */
578
577
        RAY  *r
579
578
)
580
579
{
581
 
        if (r->rot < FHUGE) {
582
 
                (*putreal)(r->rop[0]);
583
 
                (*putreal)(r->rop[1]);
584
 
                (*putreal)(r->rop[2]);
585
 
        } else {
586
 
                (*putreal)(0.0);
587
 
                (*putreal)(0.0);
588
 
                (*putreal)(0.0);
589
 
        }
 
580
        if (r->rot < FHUGE)
 
581
                (*putreal)(r->rop, 3);
 
582
        else
 
583
                (*putreal)(vdummy, 3);
590
584
}
591
585
 
592
586
 
595
589
        RAY  *r
596
590
)
597
591
{
598
 
        if (r->rot < FHUGE) {
599
 
                (*putreal)(r->ron[0]);
600
 
                (*putreal)(r->ron[1]);
601
 
                (*putreal)(r->ron[2]);
602
 
        } else {
603
 
                (*putreal)(0.0);
604
 
                (*putreal)(0.0);
605
 
                (*putreal)(0.0);
606
 
        }
 
592
        if (r->rot < FHUGE)
 
593
                (*putreal)(r->ron, 3);
 
594
        else
 
595
                (*putreal)(vdummy, 3);
607
596
}
608
597
 
609
598
 
615
604
        FVECT  pnorm;
616
605
 
617
606
        if (r->rot >= FHUGE) {
618
 
                (*putreal)(0.0);
619
 
                (*putreal)(0.0);
620
 
                (*putreal)(0.0);
 
607
                (*putreal)(vdummy, 3);
621
608
                return;
622
609
        }
623
610
        raynormal(pnorm, r);
624
 
        (*putreal)(pnorm[0]);
625
 
        (*putreal)(pnorm[1]);
626
 
        (*putreal)(pnorm[2]);
 
611
        (*putreal)(pnorm, 3);
627
612
}
628
613
 
629
614
 
645
630
        RAY  *r
646
631
)
647
632
{
648
 
        (*putreal)(r->rweight);
 
633
        RREAL   rwt = r->rweight;
 
634
        
 
635
        (*putreal)(&rwt, 1);
649
636
}
650
637
 
651
638
 
654
641
        RAY  *r
655
642
)
656
643
{
657
 
        double  contr[3];
 
644
        RREAL   contr[3];
658
645
 
659
646
        raycontrib(contr, r, PRIMARY);
660
 
        (*putreal)(contr[RED]);
661
 
        (*putreal)(contr[GRN]);
662
 
        (*putreal)(contr[BLU]);
 
647
        (*putreal)(contr, 3);
663
648
}
664
649
 
665
650
 
707
692
 
708
693
 
709
694
static void
710
 
puta(                           /* print ascii value */
711
 
        double  v
 
695
puta(                           /* print ascii value(s) */
 
696
        RREAL *v, int n
712
697
)
713
698
{
714
 
        printf("%e\t", v);
715
 
}
716
 
 
717
 
 
718
 
static void
719
 
putd(v)                         /* print binary double */
720
 
double  v;
721
 
{
722
 
        fwrite((char *)&v, sizeof(v), 1, stdout);
723
 
}
724
 
 
725
 
 
726
 
static void
727
 
putf(v)                         /* print binary float */
728
 
double  v;
729
 
{
730
 
        float f = v;
731
 
 
732
 
        fwrite((char *)&f, sizeof(f), 1, stdout);
 
699
        if (n == 3) {
 
700
                printf("%e\t%e\t%e\t", v[0], v[1], v[2]);
 
701
                return;
 
702
        }
 
703
        while (n--)
 
704
                printf("%e\t", *v++);
 
705
}
 
706
 
 
707
 
 
708
static void
 
709
putd(RREAL *v, int n)           /* print binary double(s) */
 
710
{
 
711
        if (sizeof(RREAL) != sizeof(double))
 
712
                error(INTERNAL, "code error in putd()");
 
713
        fwrite(v, sizeof(RREAL), n, stdout);
 
714
}
 
715
 
 
716
 
 
717
static void
 
718
putf(RREAL *v, int n)           /* print binary float(s) */
 
719
{
 
720
        float   fa[3];
 
721
        int     i;
 
722
 
 
723
        if (n > 3)
 
724
                error(INTERNAL, "code error in putf()");
 
725
        for (i = n; i--; )
 
726
                fa[i] = v[i];
 
727
        fwrite(fa, sizeof(float), n, stdout);
733
728
}