v20i021: sipp2.0 - a library for 3D graphics, Patch02

Inge Wallin ingwa at isy.liu.se
Wed May 29 12:49:50 AEST 1991


Submitted-by: Inge Wallin <ingwa at isy.liu.se>
Posting-number: Volume 20, Issue 21
Archive-name: sipp2.0/patch02
Patch-To: sipp2.0: Volume 16, Issue 5-10

The following context diff brings SIPP, the Simple polygon processor
to version 2.0.2.  The diff fixes a bug which sometimes caused
polygons to erroneously be marked as facing from the viewer although
they in reality were not.

The patch can also be fetched by anonymous ftp from isy.liu.se
(130.236.1.3) in the subdirectory pub/sipp.

	/Inge and Jonas

                         O /         \ O
------------------------- X snip snip X ------------------------------
                         O \         / O

Common subdirectories: sipp-2.0.1/demo and sipp-2.0.2/demo
Common subdirectories: sipp-2.0.1/doc and sipp-2.0.2/doc
Common subdirectories: sipp-2.0.1/libsipp and sipp-2.0.2/libsipp
diff -c -r sipp-2.0.1/libsipp/geometric.c sipp-2.0.2/libsipp/geometric.c
*** sipp-2.0.1/libsipp/geometric.c	Mon May 27 22:52:57 1991
--- sipp-2.0.2/libsipp/geometric.c	Mon May 27 22:40:51 1991
***************
*** 103,108 ****
--- 103,114 ----
      
      cosang = cos(ang);
      sinang = sin(ang);
+     if (fabs(cosang) < 1.0e-15) {
+         cosang = 0.0;
+     }
+     if (fabs(sinang) < 1.0e-15) {
+         sinang = 0.0;
+     }
      for (i = 0; i < 4; ++i) {
  	tmp = mat->mat[i][1];
  	mat->mat[i][1] = mat->mat[i][1] * cosang
***************
*** 136,141 ****
--- 142,153 ----
      
      cosang = cos(ang);
      sinang = sin(ang);
+     if (fabs(cosang) < 1.0e-15) {
+         cosang = 0.0;
+     }
+     if (fabs(sinang) < 1.0e-15) {
+         sinang = 0.0;
+     }
      for (i = 0; i < 4; ++i) {
  	tmp = mat->mat[i][0];
  	mat->mat[i][0] = mat->mat[i][0] * cosang
***************
*** 169,174 ****
--- 181,192 ----
      
      cosang = cos(ang);
      sinang = sin(ang);
+     if (fabs(cosang) < 1.0e-15) {
+         cosang = 0.0;
+     }
+     if (fabs(sinang) < 1.0e-15) {
+         sinang = 0.0;
+     }
      for (i = 0; i < 4; ++i) {
  	tmp = mat->mat[i][0];
  	mat->mat[i][0] = mat->mat[i][0] * cosang
Only in sipp-2.0.2/libsipp: patchlevel.h
diff -c -r sipp-2.0.1/libsipp/sipp.c sipp-2.0.2/libsipp/sipp.c
*** sipp-2.0.1/libsipp/sipp.c	Mon May 27 22:52:59 1991
--- sipp-2.0.2/libsipp/sipp.c	Mon May 27 22:47:00 1991
***************
*** 19,24 ****
--- 19,28 ----
   *
   * Revision history:
   *
+  * 910527  Ver. 2.0.2. A major bug in traverse_object_tree() fixed.
+  *         The invers transformation of the eyepoint was not correct, 
+  *         causing polygons erroneously to be marked as backfacing.
+  *
   * 910412  Ver. 2.0.1. Some minor bugfixes. Division by zero in
   *         create_edges() if an edge was horizontal in both x and y.
   *         Free-list became corrupted since the y_bucket was freed
***************
*** 89,95 ****
  #include <geometric.h>
  
  
! #define VERSION "2.0.1"
  
  #define ZCLIPF 100.0        /* Magic number used when defining hither & yon */
  
--- 93,99 ----
  #include <geometric.h>
  
  
! #define VERSION "2.0.2"
  
  #define ZCLIPF 100.0        /* Magic number used when defining hither & yon */
  
***************
*** 1850,1855 ****
--- 1854,1861 ----
      Polygon *polyref;
      Vector   eyepoint, tmp;
      double   loc_view_mat[4][4];
+     double   m[3][4], dtmp;
+     int      i, j;
  
  
      if (object == NULL) {
***************
*** 1873,1884 ****
          tmp.x -= curr_mat.mat[3][0];
          tmp.y -= curr_mat.mat[3][1];
          tmp.z -= curr_mat.mat[3][2];
!         eyepoint.x = (tmp.x * curr_mat.mat[0][0] + tmp.y * curr_mat.mat[0][1]
!                       + tmp.z * curr_mat.mat[0][2]);
!         eyepoint.y = (tmp.x * curr_mat.mat[1][0] + tmp.y * curr_mat.mat[1][1]
!                       + tmp.z * curr_mat.mat[1][2]);
!         eyepoint.z = (tmp.x * curr_mat.mat[2][0] + tmp.y * curr_mat.mat[2][1]
!                       + tmp.z * curr_mat.mat[2][2]);
  
          for (surfref = objref->surfaces; surfref != NULL; 
               surfref = surfref->next) {
--- 1879,1926 ----
          tmp.x -= curr_mat.mat[3][0];
          tmp.y -= curr_mat.mat[3][1];
          tmp.z -= curr_mat.mat[3][2];
!         m[0][0] = curr_mat.mat[0][0] ; m[0][1] = curr_mat.mat[1][0];
!         m[0][2] = curr_mat.mat[2][0] ; m[0][3] = tmp.x;
!         m[1][0] = curr_mat.mat[0][1] ; m[1][1] = curr_mat.mat[1][1];
!         m[1][2] = curr_mat.mat[2][1] ; m[1][3] = tmp.y;
!         m[2][0] = curr_mat.mat[0][2] ; m[2][1] = curr_mat.mat[1][2];
!         m[2][2] = curr_mat.mat[2][2] ; m[2][3] = tmp.z;
! 
!         if (m[0][0] == 0.0) {
!             if (m[1][0] != 0.0)
!                 j = 1;
!             else
!                 j = 2;
!             for (i = 0; i < 4; i++) {
!                 dtmp     = m[0][i];
!                 m[0][i] = m[j][i];
!                 m[j][i] = dtmp;
!             }
!         }
!         
!         for (j = 1; j < 3; j++) {
!             m[j][0] /= (-m[0][0]);
!             for (i = 1; i < 4; i++)
!                 m[j][i] += m[0][i] * m[j][0];
!         }
!         
!         if (m[1][1] == 0.0)
!             for (i = 1; i < 4; i++) {
!                 dtmp     = m[1][i];
!                 m[1][i] = m[2][i];
!                 m[2][i] = dtmp;
!             }
!         
!         if (m[1][1] != 0.0) {
!             m[2][1] /= (-m[1][1]);
!             m[2][2] += m[1][2] * m[2][1];
!             m[2][3] += m[1][3] * m[2][1];
!         }
!         
!         eyepoint.z = m[2][3] / m[2][2];
!         eyepoint.y = (m[1][3] - eyepoint.z * m[1][2]) / m[1][1];
!         eyepoint.x = (m[0][3] - eyepoint.z * m[0][2] 
!                       - eyepoint.y * m[0][1]) / m[0][0];
  
          for (surfref = objref->surfaces; surfref != NULL; 
               surfref = surfref->next) {


exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent at sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent at uunet.uu.net.



More information about the Comp.sources.misc mailing list