]> icculus.org git repositories - divverent/nexuiz.git/blob - misc/gtkradiant/singlepatches/both-UTpicomodelnormals.diff
add GtkRadiant patch set
[divverent/nexuiz.git] / misc / gtkradiant / singlepatches / both-UTpicomodelnormals.diff
1 Index: libs/picomodel/picomodel.c
2 ===================================================================
3 --- libs/picomodel/picomodel.c  (revision 191)
4 +++ libs/picomodel/picomodel.c  (working copy)
5 @@ -295,10 +295,7 @@
6                 model = PicoModuleLoadModel(module, fileName, buffer, bufSize, frameNum);
7         }
8         
9 -  if(model != 0)
10 -  {
11 -         _pico_free(buffer);
12 -  }
13 +       _pico_free(buffer);
14  
15         /* return */
16         return model;
17 @@ -1573,6 +1570,7 @@
18  {
19         int             i, j;
20         
21 +//   Sys_Printf(" %f %f %f\n", normal[0] , normal[1] , normal[2] );
22         
23         /* dummy check */
24         if( surface == NULL || surface->numVertexes <= 0 )
25 @@ -1861,13 +1859,10 @@
26  typedef picoVec3_t* picoNormalIter_t;
27  typedef picoIndex_t* picoIndexIter_t;
28  
29 -#define THE_CROSSPRODUCTS_OF_ANY_PAIR_OF_EDGES_OF_A_GIVEN_TRIANGLE_ARE_EQUAL 1
30 -
31  void _pico_triangles_generate_weighted_normals(picoIndexIter_t first, picoIndexIter_t end, picoVec3_t* xyz, picoVec3_t* normals)
32  {
33         for(; first != end; first += 3)
34         {
35 -#if (THE_CROSSPRODUCTS_OF_ANY_PAIR_OF_EDGES_OF_A_GIVEN_TRIANGLE_ARE_EQUAL)
36                 picoVec3_t weightedNormal;
37                 {
38                         float* a = xyz[*(first + 0)];
39 @@ -1878,24 +1873,11 @@
40                         _pico_subtract_vec( c, a, ca );
41                         _pico_cross_vec( ca, ba, weightedNormal );
42                 }
43 -#endif
44                 {
45                         int j = 0;
46                         for(; j < 3; ++j)
47                         {
48                                 float* normal = normals[*(first + j)];
49 -#if (!THE_CROSSPRODUCTS_OF_ANY_PAIR_OF_EDGES_OF_A_GIVEN_TRIANGLE_ARE_EQUAL)
50 -                               picoVec3_t weightedNormal;
51 -                               {
52 -                                       float* a = xyz[*(first + ((j + 0) % 3))];
53 -                                       float* b = xyz[*(first + ((j + 1) % 3))];
54 -                                       float* c = xyz[*(first + ((j + 2) % 3))];
55 -                                       picoVec3_t ba, ca;
56 -                                       _pico_subtract_vec( b, a, ba );
57 -                                       _pico_subtract_vec( c, a, ca );
58 -                                       _pico_cross_vec( ca, ba, weightedNormal );
59 -                               }
60 -#endif
61                                 _pico_add_vec(weightedNormal, normal, normal);
62                         }
63                 }
64 @@ -1941,7 +1923,8 @@
65  {
66         for(; first != last; ++first, ++generated)
67         {
68 -               if(!_pico_normal_is_unit_length(*first) || !_pico_normal_within_tolerance(*first, *generated))
69 +      //27 - fix for badly generated normals thing.
70 +      //       if(!_pico_normal_is_unit_length(*first) || !_pico_normal_within_tolerance(*first, *generated))
71                 {
72                         _pico_copy_vec(*generated, *first);
73                 }
74 @@ -1954,10 +1937,11 @@
75  
76         _pico_normals_zero(normals, normals + surface->numVertexes);
77  
78 +   //Just build standard no sg normals for now
79         _pico_triangles_generate_weighted_normals(surface->index, surface->index + surface->numIndexes, surface->xyz, normals);
80         _pico_vertices_combine_shared_normals(surface->xyz, surface->smoothingGroup, normals, surface->numVertexes);
81  
82 -       _pico_normals_normalize(normals, normals + surface->numVertexes);
83 +       _pico_normals_normalize(normals, normals + surface->numVertexes); 
84  
85         _pico_normals_assign_generated_normals(surface->normal, surface->normal + surface->numVertexes, normals);
86  
87 @@ -2261,7 +2245,7 @@
88                 int newVertIndex = PicoGetSurfaceNumIndexes ( workSurface );
89  
90                 /* get the index of the vertex that we're going to store at newVertIndex */
91 -               vertDataIndex = PicoFindSurfaceVertexNum ( workSurface , *xyz[i] , *normals[i] , numSTs , st[i] , numColors , colors[i], smoothingGroup[i]);
92 +      vertDataIndex = -1;// PicoFindSurfaceVertexNum ( workSurface , *xyz[i] , *normals[i] , numSTs , st[i] , numColors , colors[i], smoothingGroup[i]);
93  
94                 /* the vertex wasn't found, so create a new vertex in the pool from the data we have */
95                 if ( vertDataIndex == -1 )
96 @@ -2290,3 +2274,5 @@
97                 PicoSetSurfaceIndex ( workSurface , newVertIndex , vertDataIndex );
98         }
99  }
100 +
101 +