Changeset 1270

Show
Ignore:
Timestamp:
05/18/08 15:02:49 (6 months ago)
Author:
ArcRiley
Message:

Pyrex 0.9.8.2 fixes :

  • updated some of _datatypes.HashTable?
  • numerous fixes to soy.shapes
  • numerous fixes to soy.fields
Location:
trunk/pysoy
Files:
14 modified

Legend:

Unmodified
Added
Removed
  • trunk/pysoy/include/soy._datatypes.pxd

    r1265 r1270  
    8686cdef class HashTable : 
    8787  cdef glib.GHashTable*           _hashtable 
    88   cdef void                       _insert               ( self, char*, float ) 
    89   cdef float                      _lookup               ( self, char* ) 
    90   cdef int                        _has_key              ( self, char* ) 
    91   cdef int                        _remove               ( self, char* )  
     88  cdef void                       _insert               ( self, char*,  
     89                                                          float )         nogil 
     90  cdef float                      _lookup               ( self, char* )   nogil 
     91  cdef int                        _has_key              ( self, char* )   nogil 
     92  cdef int                        _remove               ( self, char* )   nogil 
    9293 
    9394 
  • trunk/pysoy/include/soy.fields.pxd

    r1265 r1270  
    2323 
    2424cdef class Field (soy.bodies.Body) : 
    25   cdef void                     _give            ( self, int ) 
    26   cdef int                      _apply           ( self ) 
    27   cdef int                      _exert           ( self, soy.bodies.Body )  
     25  cdef void                     _give            ( self, int )            nogil 
     26  cdef int                      _apply           ( self )                 nogil 
     27  cdef int                      _exert           ( self,  
     28                                                   soy.bodies.Body )      nogil 
    2829  cdef void                     _commit          ( self )                  
    29   cdef void                     _render          ( self )                 nogil 
     30 
    3031 
    3132cdef class Monopole (Field) : 
    3233  cdef soy._internals.Children  _affected 
    3334  cdef float                    _multiplier 
     35 
    3436 
    3537cdef class Wind (Field) : 
     
    5355  cdef float                    _density 
    5456 
    55 cdef extern from "math.h" : 
     57cdef extern from "math.h" nogil : 
    5658  float powf (float x, float y) 
  • trunk/pysoy/include/soy.shapes.pxd

    r1241 r1270  
    2525  cdef ode.dGeomID               _geomID 
    2626  cdef ode.dReal*                _position 
    27   cdef float                     _pointDepth(self, float x, float y, float z) 
    28   cdef float                     _radius(self) 
    29   cdef int                       _finite(self) 
    30   cdef float                     _volume(self) 
     27  cdef float                     _pointDepth(self, float, float, float)   nogil 
     28  cdef float                     _radius(self)                            nogil 
     29  cdef int                       _finite(self)                            nogil 
     30  cdef float                     _volume(self)                            nogil 
     31 
     32cdef extern from "math.h" nogil : 
     33  float powf (float x, float y) 
     34 
  • trunk/pysoy/src/_datatypes/HashTable.pym

    r1226 r1270  
    6363  # 
    6464 
    65   cdef void _insert(self, char* key, float data) : 
     65  cdef void _insert(self, char* key, float data) nogil : 
    6666    cdef glib.gchar* k 
    6767    cdef glib.gpointer d 
     
    7272 
    7373 
    74   cdef float _lookup(self, char* key) : 
     74  cdef float _lookup(self, char* key) nogil : 
    7575    cdef float* f 
    7676    f = <float*> glib.g_hash_table_lookup(self._hashtable, key) 
     
    8080 
    8181 
    82   cdef int _has_key(self, char* key) : 
     82  cdef int _has_key(self, char* key) nogil : 
    8383    cdef glib.gpointer k, d 
    8484    return glib.g_hash_table_lookup_extended(self._hashtable, key, &k, &d) 
    8585 
    8686   
    87   cdef int _remove(self, char* key) : 
     87  cdef int _remove(self, char* key) nogil : 
    8888    return glib.g_hash_table_remove(self._hashtable, key) 
  • trunk/pysoy/src/fields/Buoyancy.pym

    r1257 r1270  
    3838  # 
    3939   
    40   cdef void _give(self, int _ccycle) : 
     40  cdef void _give(self, int _ccycle) nogil : 
    4141    cdef int _i 
    42     cdef soy.bodies.Body _otherBody 
    4342    if (self._shape is not None) ^ (_ccycle == 0) : 
    4443      self._affected._iterStart() 
    4544      for _i from 0 <= _i < self._affected._current : 
    46         _otherBody = <soy.bodies.Body> self._affected._list[_i] 
    47         _otherBody._tags._remove("bmass") 
     45        (<soy.bodies.Body> self._affected._list[_i])._tags._remove("bmass") 
    4846      self._affected._iterDone() 
    49       self._affected.empty() 
     47      self._affected._empty() 
    5048 
    51   cdef int _exert(self, soy.bodies.Body _otherBody) : 
     49 
     50  cdef int _exert(self, soy.bodies.Body _otherBody) nogil : 
    5251    cdef float _radius, _submersion 
    5352    ode.dBodyGetMass(_otherBody._bodyID, &_otherBody._mass) 
     
    5857    if _otherBody._shape._volume() == 0 : 
    5958      return 0 
    60     if self._shape : 
     59    if self._shape is not None : 
    6160      # Shaped fields partially submerge shapes 
    6261      _radius = _otherBody._shape._radius()  
     
    6564                      _otherBody._shape._position[1], 
    6665                      _otherBody._shape._position[2]) 
    67                     + radius) / (radius * 2) 
     66                     + _radius) / (_radius * 2) 
    6867    else : 
    6968      # Universal fields fully submerge all shapes 
    7069      _submersion = 1 
    71     _otherBody._tags._insert("bmass", _otherBody._mass.mass - submersion 
     70    _otherBody._tags._insert("bmass", _otherBody._mass.mass - _submersion 
    7271                                      * _otherBody._shape._volume() 
    7372                                      * self._density) 
    74     self._affected._append(<void*> other) 
     73    self._affected._append(<void*> _otherBody) 
    7574    return 1 
     75 
    7676   
    7777  ############################################################################ 
  • trunk/pysoy/src/fields/Field.pym

    r1269 r1270  
    6161 
    6262   
    63   cdef int _apply(self) : 
    64     cdef int              _i, _r 
    65     cdef soy.scenes.Scene _scene 
     63  cdef int _apply(self) nogil : 
     64    cdef int _i, _r 
    6665    if self._bodyID == NULL : 
    6766      return 1 
    6867    _r = 1 
    69     _scene = <soy.scenes.Scene> self._scene 
    70     if not self._shape : 
     68    if self._shape is None : 
    7169      # Do we need an iterlock here? 
    72       for _i from 0 <= _i < _scene._bodies._current : 
    73         if not self._exert(<soy.bodies.Body>  
    74                            _scene._bodies._list[_i]) : 
     70      for _i from 0 <= _i < self._scene._bodies._current : 
     71        if not self._exert(<soy.bodies.Body> self._scene._bodies._list[_i]) : 
    7572          _r = 0 
    7673    return _r 
    7774 
    7875 
    79   cdef int _exert(self, soy.bodies.Body _other) : 
     76  cdef int _exert(self, soy.bodies.Body _other) nogil : 
    8077    # This function is applied once per physics cycle for each combination 
    8178    # of affected body and field. 
     
    8380 
    8481 
    85   cdef void _give(self, int _data) : 
     82  cdef void _give(self, int _data) nogil : 
    8683    # This function is called by the physics cycle for each field before 
    8784    # any calls to _exert.  It is used for any initialization or cleanup that 
  • trunk/pysoy/src/fields/Monopole.pym

    r1229 r1270  
    3939  # 
    4040   
    41   cdef int _exert(self, soy.bodies.Body other) : 
     41  cdef int _exert(self, soy.bodies.Body other) nogil : 
    4242    self._affected._append(<void*> other) 
    4343    return 0 
  • trunk/pysoy/src/fields/Shockwave.pym

    r1229 r1270  
    4949  # 
    5050   
    51   cdef int _exert(self, soy.bodies.Body other) : 
     51  cdef int _exert(self, soy.bodies.Body other) nogil : 
    5252    cdef float depth, force, dx, dy, dz, d 
    5353    stdio.printf("begin exert\n") 
    5454    # Give up if not active 
    55     if not self._shape or self._t0 == 0 : 
     55    if self._shape is None or self._t0 == 0 : 
    5656      return 1 
    5757 
     
    8181      return 1 
    8282 
    83   cdef void _give(self, int ccycle) : 
     83  cdef void _give(self, int ccycle) nogil : 
    8484    stdio.printf("begin give\n") 
    8585    # Quit if inactive 
    86     if not self._shape or self._t0 == 0 : 
     86    if self._shape is None or self._t0 == 0 : 
    8787      stdio.printf("abort give\n") 
    8888      return 
  • trunk/pysoy/src/fields/Wind.pym

    r1229 r1270  
    3838   
    3939  # TODO incomplete: needs area measurements rather than assumptions 
    40   cdef int _exert(self, soy.bodies.Body other) : 
     40  cdef int _exert(self, soy.bodies.Body other) nogil : 
    4141    cdef float dx, dy, dz, d2, r, f 
    4242    if other._tags._has_key('cd') : 
  • trunk/pysoy/src/shapes/Box.pym

    r1232 r1270  
    3434    ode.dGeomSetData(self._geomID, <void*> self) 
    3535 
    36   ############################################################################ 
    37   # 
    38   # C functions 
    39   # 
    40    
    41   cdef float _pointDepth(self, float x, float y, float z) : 
    42     return <float> ode.dGeomBoxPointDepth(self._geomID, x, y, z) 
    43  
    44   cdef float _volume(self) : 
    45     cdef ode.dVector3 xyz 
    46     ode.dGeomBoxGetLengths(self._geomID, xyz) 
    47     return <float> xyz[0] * xyz[1] * xyz[2] 
    48  
    49   cdef float _radius(self) : 
    50     cdef ode.dVector3 xyz 
    51     ode.dGeomBoxGetLengths(self._geomID, xyz) 
    52     return <float> (xyz[0] + xyz[1] + xyz[2]) / 3 
    53  
    54   cdef int _finite(self) : 
    55     return 1 
    5636 
    5737  ############################################################################ 
     
    7151    def __set__(self, value) : 
    7252      ode.dGeomBoxSetLengths(self._geomID, value[0], value[1], value[2]) 
     53 
     54 
     55  ############################################################################ 
     56  # 
     57  # C functions 
     58  # 
     59   
     60  cdef float _pointDepth(self, float _x, float _y, float _z) nogil : 
     61    return <float> ode.dGeomBoxPointDepth(self._geomID, _x, _y, _z) 
     62 
     63 
     64  cdef float _volume(self) nogil : 
     65    cdef ode.dVector3 _xyz 
     66    ode.dGeomBoxGetLengths(self._geomID, _xyz) 
     67    return <float> _xyz[0] * _xyz[1] * _xyz[2] 
     68 
     69 
     70  cdef float _radius(self) nogil : 
     71    cdef ode.dVector3 _xyz 
     72    ode.dGeomBoxGetLengths(self._geomID, _xyz) 
     73    return <float> (_xyz[0] + _xyz[1] + _xyz[2]) / 3 
     74 
     75 
     76  cdef int _finite(self) nogil : 
     77    return 1 
  • trunk/pysoy/src/shapes/Capsule.pym

    r1232 r1270  
    3333    ode.dGeomSetData(self._geomID, <void*> self) 
    3434 
    35   ############################################################################ 
    36   # 
    37   # C functions 
    38   # 
    39    
    40   cdef float _pointDepth(self, float x, float y, float z) : 
    41     return <float> ode.dGeomCapsulePointDepth(self._geomID, x, y, z) 
    42  
    43   cdef float _volume(self) : 
    44     cdef ode.dReal r, l 
    45     ode.dGeomCapsuleGetParams(self._geomID, &r, &l) 
    46     return (l * powf(r, 2) * 3.1415926535 + 4 / 3 * powf(r, 3) * 3.1415926535) 
    47  
    48   cdef float _radius(self) : 
    49     cdef ode.dReal r, l 
    50     ode.dGeomCapsuleGetParams(self._geomID, &r, &l) 
    51     return <float> (l / 2 + r) 
    52  
    53   cdef int _finite(self) : 
    54     return 1 
    5535 
    5636  ############################################################################ 
     
    7454      ode.dGeomCapsuleSetParams(self._geomID, r, l) 
    7555 
     56 
    7657  property length : 
    7758    '''Capsule's length 
     
    8869      l = value 
    8970      ode.dGeomCapsuleSetParams(self._geomID, r, l) 
     71 
     72 
     73  ############################################################################ 
     74  # 
     75  # C functions 
     76  # 
     77   
     78  cdef float _pointDepth(self, float _x, float _y, float _z) nogil : 
     79    return <float> ode.dGeomCapsulePointDepth(self._geomID, _x, _y, _z) 
     80 
     81 
     82  cdef float _volume(self) nogil : 
     83    cdef ode.dReal _r, _l 
     84    ode.dGeomCapsuleGetParams(self._geomID, &_r, &_l) 
     85    return (_l * powf(_r, 2) * 3.1416 + 4 / 3 * powf(_r, 3) * 3.1416) 
     86 
     87 
     88  cdef float _radius(self) nogil : 
     89    cdef ode.dReal _r, _l 
     90    ode.dGeomCapsuleGetParams(self._geomID, &_r, &_l) 
     91    return <float> (_l / 2 + _r) 
     92 
     93 
     94  cdef int _finite(self) nogil : 
     95    return 1 
  • trunk/pysoy/src/shapes/Ray.pym

    r1232 r1270  
    3333    ode.dGeomSetData(self._geomID, <void*> self) 
    3434 
    35   ############################################################################ 
    36   # 
    37   # C functions 
    38   # 
    39    
    40   cdef float _radius(self) : 
    41     return 0 
    42  
    43   cdef int _finite(self) : 
    44     return 0 
    4535 
    4636  ############################################################################ 
     
    8676      ode.dGeomRayGet(self._geomID, s, d) 
    8777      ode.dGeomRaySet(self._geomID, s[0], s[1], s[2], value[0], value[1], value[2]) 
     78 
     79 
     80  ############################################################################ 
     81  # 
     82  # C functions 
     83  # 
     84   
     85  cdef float _radius(self) nogil : 
     86    return 0 
     87 
     88 
     89  cdef int _finite(self) nogil : 
     90    return 0 
     91 
  • trunk/pysoy/src/shapes/Shape.pym

    r1232 r1270  
    3333    self._geomID = NULL 
    3434 
     35 
    3536  ############################################################################ 
    3637  # 
     
    3839  # 
    3940   
    40   cdef float _pointDepth(self, float x, float y, float z) : 
     41  cdef float _pointDepth(self, float _x, float _y, float _z) nogil : 
    4142    return 0 
    4243 
    43   cdef float _volume(self) : 
     44  cdef float _volume(self) nogil : 
    4445    return 0 
    4546 
    46   cdef float _radius(self) : 
     47  cdef float _radius(self) nogil : 
    4748    return 0 
    4849 
    49   cdef int _finite(self) : 
     50  cdef int _finite(self) nogil : 
    5051    return 0 
  • trunk/pysoy/src/shapes/Sphere.pym

    r1232 r1270  
    3333    ode.dGeomSetData(self._geomID, <void*> self) 
    3434 
    35   ############################################################################ 
    36   # 
    37   # C functions 
    38   # 
    39    
    40   cdef float _pointDepth(self, float x, float y, float z) : 
    41     return <float> ode.dGeomSpherePointDepth(self._geomID, x, y, z) 
    42  
    43   cdef float _volume(self) : 
    44     return <float> 4 / 3 * powf(ode.dGeomSphereGetRadius(self._geomID), 3) * 3.1415926535 
    45  
    46   cdef float _radius(self) : 
    47     return <float> ode.dGeomSphereGetRadius(self._geomID) 
    48  
    49   cdef int _finite(self) : 
    50     return 1 
    5135 
    5236  ############################################################################ 
     
    6448    def __set__(self, value) : 
    6549      ode.dGeomSphereSetRadius(self._geomID, value) 
     50 
     51 
     52  ############################################################################ 
     53  # 
     54  # C functions 
     55  # 
     56   
     57  cdef float _pointDepth(self, float _x, float _y, float _z) nogil : 
     58    return <float> ode.dGeomSpherePointDepth(self._geomID, _x, _y, _z) 
     59 
     60  cdef float _volume(self) nogil : 
     61    return <float> (4 / 3 *  
     62                    powf(ode.dGeomSphereGetRadius(self._geomID), 3) * 3.1416) 
     63 
     64  cdef float _radius(self) nogil : 
     65    return <float> ode.dGeomSphereGetRadius(self._geomID) 
     66 
     67  cdef int _finite(self) nogil : 
     68    return 1