~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/MapObject/mapobject_shade.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#include <string.h>
8
8
 
9
9
#include <libgimp/gimp.h>
 
10
#include <libgimp/gimpui.h>
10
11
 
11
12
#include "mapobject_apply.h"
12
13
#include "mapobject_main.h"
135
136
              imat[0][2] * imat[1][1] * imat[2][3] -
136
137
              imat[1][2] * imat[2][1] * imat[0][3] -
137
138
              imat[2][2] * imat[0][1] * imat[1][3]);
138
 
 
 
139
 
139
140
      det2 = (imat[0][0] * imat[1][3] * imat[2][2] +
140
141
              imat[0][3] * imat[1][2] * imat[2][0] +
141
142
              imat[0][2] * imat[1][0] * imat[2][3] -
142
143
              imat[0][2] * imat[1][3] * imat[2][0] -
143
144
              imat[1][2] * imat[2][3] * imat[0][0] -
144
145
              imat[2][2] * imat[0][3] * imat[1][0]);
145
 
 
 
146
 
146
147
      det3 = (imat[0][0] * imat[1][1] * imat[2][3] +
147
148
              imat[0][1] * imat[1][3] * imat[2][0] +
148
149
              imat[0][3] * imat[1][0] * imat[2][1] -
216
217
          gimp_rgb_clamp (&color);
217
218
        }
218
219
    }
219
 
  
 
220
 
220
221
  if (mapvals.transparent_background == FALSE && color.a < 1.0)
221
222
    {
222
 
      gimp_rgb_composite (&color, &background, 
 
223
      gimp_rgb_composite (&color, &background,
223
224
                          GIMP_RGB_COMPOSITE_BEHIND);
224
225
    }
225
226
 
374
375
 
375
376
          gimp_vector3_sub (&normal, &spos2, &mapvals.position);
376
377
          gimp_vector3_normalize (&normal);
377
 
          sphere_to_image (&normal, &vx, &vy); 
 
378
          sphere_to_image (&normal, &vx, &vy);
378
379
          color2 = get_image_color (vx, vy, &inside);
379
380
 
380
381
          /* Make the normal point inwards */
416
417
          gimp_rgb_clamp (&color);
417
418
        }
418
419
    }
419
 
  
 
420
 
420
421
  if (mapvals.transparent_background == FALSE && color.a < 1.0)
421
422
    {
422
 
      gimp_rgb_composite (&color, &background, 
 
423
      gimp_rgb_composite (&color, &background,
423
424
                          GIMP_RGB_COMPOSITE_BEHIND);
424
425
    }
425
 
  
 
426
 
426
427
  return color;
427
428
}
428
429
 
594
595
{
595
596
  gint   i, j, k;
596
597
  gfloat value;
597
 
  
 
598
 
598
599
#define A(row,col)  a[col*4+row]
599
600
#define B(row,col)  b[col*4+row]
600
601
#define C(row,col)  c[col*4+row]
621
622
ident_mat (gfloat m[16])
622
623
{
623
624
  gint  i, j;
624
 
  
 
625
 
625
626
#define M(row,col)  m[col*4+row]
626
 
  
 
627
 
627
628
  for (i = 0; i < 4; i++)
628
629
    {
629
630
      for (j = 0; j < 4; j++)
659
660
      face_info->s.y = viewp.y + face_info->t * dir.y;
660
661
      face_info->s.z = w;
661
662
 
662
 
      if (face_info->s.x >= -u2 && face_info->s.x <= u2 && 
 
663
      if (face_info->s.x >= -u2 && face_info->s.x <= u2 &&
663
664
          face_info->s.y >= -v2 && face_info->s.y <= v2)
664
665
        {
665
666
          face_info->u = (face_info->s.x + u2) / u;
717
718
    {
718
719
      /* Top: Rotate viewpoint and direction into rectangle's local coordinate system */
719
720
      /* ============================================================================ */
720
 
  
 
721
 
721
722
      rotatemat (90, &axis[0], m);
722
723
      vecmulmat (&v, &viewp, m);
723
724
      vecmulmat (&d, &dir, m);
733
734
 
734
735
          gimp_vector3_set (&face_intersect[i++].n, 0.0, -1.0, 0.0);
735
736
          result = TRUE;
736
 
        } 
 
737
        }
737
738
    }
738
739
 
739
740
  /* Check if we've found the two possible intersection points */
744
745
      /* Bottom: Rotate viewpoint and direction into rectangle's local coordinate system */
745
746
      /* =============================================================================== */
746
747
 
747
 
      rotatemat (90, &axis[0], m);  
 
748
      rotatemat (90, &axis[0], m);
748
749
      vecmulmat (&v, &viewp, m);
749
750
      vecmulmat (&d, &dir, m);
750
751
 
774
775
      /* Left side: Rotate viewpoint and direction into rectangle's local coordinate system */
775
776
      /* ================================================================================== */
776
777
 
777
 
      rotatemat (90, &axis[1], m);  
 
778
      rotatemat (90, &axis[1], m);
778
779
      vecmulmat (&v, &viewp, m);
779
780
      vecmulmat (&d, &dir, m);
780
781
 
782
783
                          v, d, &face_intersect[i]) == TRUE)
783
784
        {
784
785
          face_intersect[i].face = 4;
785
 
    
 
786
 
786
787
          transpose_mat (m);
787
788
          vecmulmat (&tmp, &face_intersect[i].s, m);
788
789
          face_intersect[i].s = tmp;
800
801
      /* Right side: Rotate viewpoint and direction into rectangle's local coordinate system */
801
802
      /* =================================================================================== */
802
803
 
803
 
      rotatemat (90, &axis[1], m);  
 
804
      rotatemat (90, &axis[1], m);
804
805
      vecmulmat (&v, &viewp, m);
805
806
      vecmulmat (&d, &dir, m);
806
807
 
859
860
 
860
861
  /* Compute direction */
861
862
  /* ================= */
862
 
  
 
863
 
863
864
  gimp_vector3_sub (&dir, &p, &vp);
864
865
  gimp_vector3_normalize (&dir);
865
866
 
921
922
                               &mapvals.lightsource.position,
922
923
                               &color,
923
924
                               &mapvals.lightsource.color,
924
 
                               mapvals.lightsource.type);      
 
925
                               mapvals.lightsource.type);
925
926
 
926
927
          gimp_rgb_clamp (&color);
927
928
 
940
941
                                &mapvals.lightsource.position,
941
942
                                &color2,
942
943
                                &mapvals.lightsource.color,
943
 
                                mapvals.lightsource.type);      
 
944
                                mapvals.lightsource.type);
944
945
 
945
946
          gimp_rgb_clamp (&color2);
946
947
 
947
948
          if (mapvals.transparent_background == FALSE && color2.a < 1.0)
948
949
            {
949
 
              gimp_rgb_composite (&color2, &background, 
 
950
              gimp_rgb_composite (&color2, &background,
950
951
                                  GIMP_RGB_COMPOSITE_BEHIND);
951
952
            }
952
953
 
964
965
                               &mapvals.lightsource.position,
965
966
                               &color,
966
967
                               &mapvals.lightsource.color,
967
 
                               mapvals.lightsource.type);      
 
968
                               mapvals.lightsource.type);
968
969
 
969
970
          gimp_rgb_clamp (&color);
970
971
        }
1036
1037
 
1037
1038
      if (f != 0.0)
1038
1039
        {
1039
 
          result = TRUE;      
1040
 
    
 
1040
          result = TRUE;
 
1041
 
1041
1042
          face_intersect[0].t = (-b+e)/f;
1042
1043
          face_intersect[1].t = (-b-e)/f;
1043
 
    
 
1044
 
1044
1045
          if (face_intersect[0].t>face_intersect[1].t)
1045
1046
            {
1046
1047
              tmp = face_intersect[0].t;
1047
1048
              face_intersect[0].t = face_intersect[1].t;
1048
1049
              face_intersect[1].t = tmp;
1049
1050
            }
1050
 
          
 
1051
 
1051
1052
          for (i = 0; i < 2; i++)
1052
1053
            {
1053
1054
              face_intersect[i].s.x = vp.x + face_intersect[i].t * dir.x;
1065
1066
 
1066
1067
              /* Mark hitpoint as on the cylinder hull */
1067
1068
              /* ===================================== */
1068
 
              
 
1069
 
1069
1070
              face_intersect[i].face = 0;
1070
1071
 
1071
1072
              /* Check if we're completely off the cylinder axis */
1072
1073
              /* =============================================== */
1073
 
    
 
1074
 
1074
1075
              if (face_intersect[i].s.y>l || face_intersect[i].s.y<-l)
1075
1076
                {
1076
1077
                  /* Check if we've hit a cap */
1077
1078
                  /* ======================== */
1078
 
    
 
1079
 
1079
1080
                  if (face_intersect[i].s.y>l)
1080
1081
                    {
1081
1082
                      if (intersect_circle(vp,dir,l,&face_intersect[i])==FALSE)
1114
1115
{
1115
1116
  GimpRGB  color;
1116
1117
  gint    inside;
1117
 
  
 
1118
 
1118
1119
  if (face == 0)
1119
1120
    color = get_image_color (u, v, &inside);
1120
1121
  else
1200
1201
                               &mapvals.lightsource.position,
1201
1202
                               &color,
1202
1203
                               &mapvals.lightsource.color,
1203
 
                               mapvals.lightsource.type);      
1204
 
    
 
1204
                               mapvals.lightsource.type);
 
1205
 
1205
1206
          gimp_rgb_clamp (&color);
1206
1207
 
1207
1208
          color2 = get_cylinder_color (face_intersect[1].face,
1225
1226
 
1226
1227
          if (mapvals.transparent_background == FALSE && color2.a < 1.0)
1227
1228
            {
1228
 
              gimp_rgb_composite (&color2, &background, 
 
1229
              gimp_rgb_composite (&color2, &background,
1229
1230
                                  GIMP_RGB_COMPOSITE_BEHIND);
1230
1231
            }
1231
1232
 
1253
1254
      if (mapvals.transparent_background == TRUE)
1254
1255
        gimp_rgb_set_alpha (&color, 0.0);
1255
1256
    }
1256
 
  
 
1257
 
1257
1258
  return color;
1258
1259
}