Author: ArcRiley Date: 2008-07-18 23:08:49 -0400 (Fri, 18 Jul 2008) New Revision: 1334
Modified: trunk/pysoy/include/soy.scenes.pxd trunk/pysoy/src/scenes/Landscape.pym Log: Ticket #958 : * fixed _delta* arrays Modified: trunk/pysoy/include/soy.scenes.pxd =================================================================== --- trunk/pysoy/include/soy.scenes.pxd 2008-07-19 02:37:30 UTC (rev 1333) +++ trunk/pysoy/include/soy.scenes.pxd 2008-07-19 03:08:49 UTC (rev 1334) @@ -92,8 +92,6 @@ cdef double _position[3] cdef Vert* _vertArray cdef Face* _elementArray - cdef int* _deltaCols - cdef int* _deltaRows cdef void _createBuffer ( self ) cdef void _createArrays ( self ) Modified: trunk/pysoy/src/scenes/Landscape.pym =================================================================== --- trunk/pysoy/src/scenes/Landscape.pym 2008-07-19 02:37:30 UTC (rev 1333) +++ trunk/pysoy/src/scenes/Landscape.pym 2008-07-19 03:08:49 UTC (rev 1334) @@ -51,8 +51,6 @@ self._heightmapID = ode.dGeomHeightfieldDataCreate() self._vertArray = <Vert *> py.PyMem_Malloc(heightmap._width*heightmap._height*16*4) self._elementArray = <Face *> py.PyMem_Malloc(sizeof(Face)*(heightmap._width-1)*(heightmap._height-1)*2) - self._deltaRows = <int *> py.PyMem_Malloc(sizeof(int)*heightmap._width*heightmap._height) - self._deltaCols = <int *> py.PyMem_Malloc(sizeof(int)*heightmap._width*heightmap._height) ode.dGeomHeightfieldDataBuildByte(self._heightmapID, <unsigned char*> heightmap._texels, 0, # copy? @@ -101,8 +99,28 @@ cdef void _createArrays(self) : cdef int _i, _j, _currentLoop, _offset cdef unsigned short _a, _b, _c, _d + cdef float *_deltaCols, *_deltaRows cdef double _v1[3], _v2[3], _normal[3], _normal2[3], _length, _u[3] # + # Alloc _delta arrays + # + # These are arrays for column and row edge deltas: + # . . . . . . . . ._._._._._._._. + # | | | | | | | | + # . . . . . . . . ._._._._._._._. + # | | | | | | | | + # . . . . . . . . ._._._._._._._. + # _deltaCols _deltaRows + # + # They're used in determining edge collapses in LOD generation below. + # + _deltaCols = <float*> py.PyMem_Malloc(sizeof(float) * \ + self.heightmapTex._width * \ + self.heightmapTex._height) + _deltaRows = <float*> py.PyMem_Malloc(sizeof(float) * \ + self.heightmapTex._width * \ + self.heightmapTex._height) + # # Calculate positions and texcoords first for _i from 0 <= _i < self._heightmapTex._height : for _j from 0 <= _j < self._heightmapTex._width : @@ -150,8 +168,8 @@ _v2[2] = self._vertArray[_c].pz-self._vertArray[_a].pz # While we are in this loop, calculate the delta map for LOD - self._deltaRows[_offset] = self._vertArray[_offset].py-self._vertArray[_offset+1].py - stdio.printf("%d : %d\n", _offset, self._deltaRows[_offset]); + _deltaRows[_offset] = self._vertArray[_offset].py-self._vertArray[_offset+1].py + stdio.printf("%d : %d\n", _offset, _deltaRows[_offset]); else : # subtract the vertices to get vectors _v1[0] = self._vertArray[_c].px @@ -245,6 +263,10 @@ self._elementArray[_currentLoop].b = _c self._elementArray[_currentLoop].c = _d _currentLoop += 1 + # + # Free previously alloc'ed delta arrays + py.PyMem_Free(_deltaCols) + py.PyMem_Free(_deltaRows) cdef void _createBuffer(self) : _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn