From: Matthias B. <mb...@us...> - 2007-06-05 09:03:10
|
Update of /cvsroot/pyode/pyode/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23333/src Modified Files: declarations.pyx ode.pyx Added Files: heightfield.pyx heightfielddata.pyx Log Message: Applied the heightfield patch Index: ode.pyx =================================================================== RCS file: /cvsroot/pyode/pyode/src/ode.pyx,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ode.pyx 5 Jun 2007 08:42:17 -0000 1.18 --- ode.pyx 5 Jun 2007 09:03:10 -0000 1.19 *************** *** 184,187 **** --- 184,189 ---- include "_trimesh_switch.pyx" + include "heightfielddata.pyx" + include "heightfield.pyx" def collide(geom1, geom2): --- NEW FILE: heightfield.pyx --- ###################################################################### # Python Open Dynamics Engine Wrapper # Copyright (C) 2004 PyODE developers (see file AUTHORS) # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of EITHER: # (1) The GNU Lesser General Public License as published by the Free # Software Foundation; either version 2.1 of the License, or (at # your option) any later version. The text of the GNU Lesser # General Public License is included with this library in the # file LICENSE. # (2) The BSD-style license that is included with this library in # the file LICENSE-BSD. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # LICENSE and LICENSE-BSD for more details. ###################################################################### cdef class GeomHeightfield(GeomObject): """Heightfield object. To construct the heightfield geom, you need a HeightfieldData object that stores the heightfield data. This object has to be passed as the first argument to the constructor. Constructor:: GeomHeightfield(data, space=None) """ cdef HeightfieldData data def __new__(self, HeightfieldData data not None, placeable=True, space=None): cdef SpaceBase sp cdef dSpaceID sid self.data = data sid=NULL if space!=None: sp = space sid = sp.sid self.gid = dCreateHeightfield(sid, data.hfdid, <int>placeable) _geom_c2py_lut[<long>self.gid] = self def __init__(self, HeightfieldData data not None, space=None): self.space = space self.body = None def placeable(self): return True def _id(self): cdef long id id = <long>self.gid return id --- NEW FILE: heightfielddata.pyx --- ###################################################################### # Python Open Dynamics Engine Wrapper # Copyright (C) 2004 PyODE developers (see file AUTHORS) # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of EITHER: # (1) The GNU Lesser General Public License as published by the Free # Software Foundation; either version 2.1 of the License, or (at # your option) any later version. The text of the GNU Lesser # General Public License is included with this library in the # file LICENSE. # (2) The BSD-style license that is included with this library in # the file LICENSE-BSD. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files # LICENSE and LICENSE-BSD for more details. ###################################################################### cdef class HeightfieldData: """This class is used to store heightfield data. """ cdef dHeightfieldDataID hfdid def __new__(self): self.hfdid = dGeomHeightfieldDataCreate() def __dealloc__(self): if self.hfdid!=NULL: dGeomHeightfieldDataDestroy(self.hfdid) def build_callback(self, userdata, callback, width, depth, wsamp, dsamp, scale, offset, thickness, bwrap): cdef object tup cdef void* data tup = (callback, arg) data = <void*>tup dGeomHeightfieldDataBuildCallback(self.hfdid, data, get_height, width, depth, wsamp, dsamp, scale, offset, thickness, bwrap) cdef dReal get_height(void *data, int x, int z): cdef object tup tup = <object>data callback, arg = tup return callback(arg, x, z) Index: declarations.pyx =================================================================== RCS file: /cvsroot/pyode/pyode/src/declarations.pyx,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** declarations.pyx 5 Jun 2007 08:42:17 -0000 1.20 --- declarations.pyx 5 Jun 2007 09:03:10 -0000 1.21 *************** *** 50,53 **** --- 50,55 ---- cdef struct dxTriMeshData: int _dummy + cdef struct dxHeightfieldData: + int _dummy # Types *************** *** 59,62 **** --- 61,65 ---- ctypedef dxJointGroup* dJointGroupID ctypedef dxTriMeshData* dTriMeshDataID + ctypedef dxHeightfieldData* dHeightfieldDataID ctypedef dReal dVector3[4] ctypedef dReal dVector4[4] *************** *** 82,85 **** --- 85,89 ---- ctypedef void dNearCallback(void* data, dGeomID o1, dGeomID o2) + ctypedef dReal dHeightfieldGetHeight( void* p_user_data, int x, int z ) ctypedef struct dSurfaceParameters: *************** *** 458,459 **** --- 462,477 ---- void dGeomTriMeshEnableTC(dGeomID g, int geomClass, int enable) int dGeomTriMeshIsTCEnabled(dGeomID g, int geomClass) + + # Heightfield + dHeightfieldDataID dGeomHeightfieldDataCreate() + void dGeomHeightfieldDataDestroy(dHeightfieldDataID g) + void dGeomHeightfieldDataBuildCallback(dHeightfieldDataID d, + void* pUserData, + dHeightfieldGetHeight* pCallback, + dReal width, dReal depth, + int widthSamples, int depthSamples, + dReal scale, dReal offset, + dReal thickness, int bWrap) + dGeomID dCreateHeightfield (dSpaceID space, dHeightfieldDataID data, + int bPlaceable) + |