Author: ArcRiley
Date: 2008-07-15 02:32:19 -0400 (Tue, 15 Jul 2008)
New Revision: 1313

Modified:
   trunk/pysoy/src/scenes/Landscape.pym
Log:
Ticket #929 :
  * cleaned up vertex loop code


Modified: trunk/pysoy/src/scenes/Landscape.pym
===================================================================
--- trunk/pysoy/src/scenes/Landscape.pym        2008-07-15 06:08:07 UTC (rev 
1312)
+++ trunk/pysoy/src/scenes/Landscape.pym        2008-07-15 06:32:19 UTC (rev 
1313)
@@ -86,34 +86,33 @@
   #
 
   cdef void _createArrays(self) :
-    cdef int _i, _j, _currentLoop
-    cdef double _x, _y, _z
+    cdef int _i, _j, _currentLoop, _offset
+    cdef float _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 :
+        _offset = self._heightmapTex._width*_i+_j
         # Get the y value here
-        _y = self._heightmapTex._texels[self._heightmapTex._width*_i+_j]
+        _y = self._heightmapTex._texels[_offset] / 255.0 * \
+             self._height + self._position[1]
         #divide by width to get what percentage it is of width, then multiply 
by width wanted
-        _x = _j / 1.0 / self._heightmapTex._width * self._width + 
self._position[0]
-        _y = _y / 255.0 * self._height + self._position[1]
-        _z = _i / 1.0 / self._heightmapTex._height * self._depth + 
self._position[2]
-        self._vertArray[self._heightmapTex._width*_i+_j].px = _x
-        self._vertArray[self._heightmapTex._width*_i+_j].pz = _z
-        self._vertArray[self._heightmapTex._width*_i+_j].py = _y
+        _x = <float> _j / self._heightmapTex._width  * self._width + 
self._position[0]
+        _z = <float> _i / self._heightmapTex._height * self._depth + 
self._position[2]
+        self._vertArray[_offset].px = _x
+        self._vertArray[_offset].py = _y
+        self._vertArray[_offset].pz = _z
         #all below need to be calculated CORRECTLY!
-        self._vertArray[self._heightmapTex._width*_i+_j].tx = 0
-        self._vertArray[self._heightmapTex._width*_i+_j].ty = 1
-        self._vertArray[self._heightmapTex._width*_i+_j].tz = 0
-        self._vertArray[self._heightmapTex._width*_i+_j].ux = 0
-        self._vertArray[self._heightmapTex._width*_i+_j].uy = 1
-        self._vertArray[self._heightmapTex._width*_i+_j].uz = 0
-        self._vertArray[self._heightmapTex._width*_i+_j].nx = 0
-        self._vertArray[self._heightmapTex._width*_i+_j].ny = 1 # Up
-        self._vertArray[self._heightmapTex._width*_i+_j].nz = 0
-     #clear vars for next loops!
-    _i = 0
-    _j = 0
+        self._vertArray[_offset].nx = 0
+        self._vertArray[_offset].ny = 1 # Up
+        self._vertArray[_offset].nz = 0
+        self._vertArray[_offset].tx = 0
+        self._vertArray[_offset].ty = 1
+        self._vertArray[_offset].tz = 0
+        self._vertArray[_offset].ux = 0
+        self._vertArray[_offset].uy = 1
+        self._vertArray[_offset].uz = 0
+    #clear vars for next loops!
     _currentLoop = 0
     #loop through all of the quads in the grid
     for _i from 0 <= _i < self._heightmapTex._height-1 :

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

Reply via email to