Author: ArcRiley
Date: 2008-07-15 01:40:39 -0400 (Tue, 15 Jul 2008)
New Revision: 1310

Modified:
   trunk/pysoy/src/scenes/Landscape.pym
Log:
Ticket #929 :
 * cleaned up face generation loop
 * fixed winding order


Modified: trunk/pysoy/src/scenes/Landscape.pym
===================================================================
--- trunk/pysoy/src/scenes/Landscape.pym        2008-07-15 05:15:40 UTC (rev 
1309)
+++ trunk/pysoy/src/scenes/Landscape.pym        2008-07-15 05:40:39 UTC (rev 
1310)
@@ -88,6 +88,7 @@
   cdef void _createArrays(self) :
     cdef int _i, _j, _currentLoop
     cdef double _x, _y, _z
+    cdef unsigned short _a, _b, _c, _d
     # set up the vert array
     for _i from 0 <= _i < self._heightmapTex._height :
       for _j from 0 <= _j < self._heightmapTex._width :
@@ -117,16 +118,28 @@
     #loop through all of the quads in the grid
     for _i from 0 <= _i < self._heightmapTex._height-1 :
       for _j from 0 <= _j < self._heightmapTex._width-1 :
+        # 
+        # for code cleanlyness, get the four verticies first as:
+        # 
+        # a-d  Note CCW winding order.
+        # |\|   Tri 1 = abc
+        # b-c   Tri 2 = acd
+        # 
+        _a = _j + ( _i    * self._heightmapTex._width)
+        _b = _j + ((_i+1) * self._heightmapTex._width)
+        _c = _j + ((_i+1) * self._heightmapTex._width) + 1
+        _d = _j + ( _i    * self._heightmapTex._width) + 1
+        # 
         #create the upper left tri in the quad
         #verts are in counter clockwise direction
-        self._elementArray[_currentLoop].a = _j + 1 + _i * 
self._heightmapTex._width
-        self._elementArray[_currentLoop].b = _j + _i * 
self._heightmapTex._width
-        self._elementArray[_currentLoop].c = _j + (_i+1) * 
self._heightmapTex._width
+        self._elementArray[_currentLoop].a = _a
+        self._elementArray[_currentLoop].b = _b
+        self._elementArray[_currentLoop].c = _c
         _currentLoop += 1
         #now the bottom right!
-        self._elementArray[_currentLoop].a = _j + 1 + _i * 
self._heightmapTex._width
-        self._elementArray[_currentLoop].b = _j + (_i+1) * 
self._heightmapTex._width
-        self._elementArray[_currentLoop].c = _j + 1 + (_i+1) * 
self._heightmapTex._width
+        self._elementArray[_currentLoop].a = _a
+        self._elementArray[_currentLoop].b = _c
+        self._elementArray[_currentLoop].c = _d
         _currentLoop += 1
 
 

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to