Changeset 1270
- Timestamp:
- 05/18/08 15:02:49 (6 months ago)
- Location:
- trunk/pysoy
- Files:
-
- 14 modified
-
include/soy._datatypes.pxd (modified) (1 diff)
-
include/soy.fields.pxd (modified) (2 diffs)
-
include/soy.shapes.pxd (modified) (1 diff)
-
src/_datatypes/HashTable.pym (modified) (3 diffs)
-
src/fields/Buoyancy.pym (modified) (3 diffs)
-
src/fields/Field.pym (modified) (2 diffs)
-
src/fields/Monopole.pym (modified) (1 diff)
-
src/fields/Shockwave.pym (modified) (2 diffs)
-
src/fields/Wind.pym (modified) (1 diff)
-
src/shapes/Box.pym (modified) (2 diffs)
-
src/shapes/Capsule.pym (modified) (3 diffs)
-
src/shapes/Ray.pym (modified) (2 diffs)
-
src/shapes/Shape.pym (modified) (2 diffs)
-
src/shapes/Sphere.pym (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pysoy/include/soy._datatypes.pxd
r1265 r1270 86 86 cdef class HashTable : 87 87 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 92 93 93 94 -
trunk/pysoy/include/soy.fields.pxd
r1265 r1270 23 23 24 24 cdef 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 28 29 cdef void _commit ( self ) 29 cdef void _render ( self ) nogil 30 30 31 31 32 cdef class Monopole (Field) : 32 33 cdef soy._internals.Children _affected 33 34 cdef float _multiplier 35 34 36 35 37 cdef class Wind (Field) : … … 53 55 cdef float _density 54 56 55 cdef extern from "math.h" :57 cdef extern from "math.h" nogil : 56 58 float powf (float x, float y) -
trunk/pysoy/include/soy.shapes.pxd
r1241 r1270 25 25 cdef ode.dGeomID _geomID 26 26 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 32 cdef extern from "math.h" nogil : 33 float powf (float x, float y) 34 -
trunk/pysoy/src/_datatypes/HashTable.pym
r1226 r1270 63 63 # 64 64 65 cdef void _insert(self, char* key, float data) :65 cdef void _insert(self, char* key, float data) nogil : 66 66 cdef glib.gchar* k 67 67 cdef glib.gpointer d … … 72 72 73 73 74 cdef float _lookup(self, char* key) :74 cdef float _lookup(self, char* key) nogil : 75 75 cdef float* f 76 76 f = <float*> glib.g_hash_table_lookup(self._hashtable, key) … … 80 80 81 81 82 cdef int _has_key(self, char* key) :82 cdef int _has_key(self, char* key) nogil : 83 83 cdef glib.gpointer k, d 84 84 return glib.g_hash_table_lookup_extended(self._hashtable, key, &k, &d) 85 85 86 86 87 cdef int _remove(self, char* key) :87 cdef int _remove(self, char* key) nogil : 88 88 return glib.g_hash_table_remove(self._hashtable, key) -
trunk/pysoy/src/fields/Buoyancy.pym
r1257 r1270 38 38 # 39 39 40 cdef void _give(self, int _ccycle) :40 cdef void _give(self, int _ccycle) nogil : 41 41 cdef int _i 42 cdef soy.bodies.Body _otherBody43 42 if (self._shape is not None) ^ (_ccycle == 0) : 44 43 self._affected._iterStart() 45 44 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") 48 46 self._affected._iterDone() 49 self._affected. empty()47 self._affected._empty() 50 48 51 cdef int _exert(self, soy.bodies.Body _otherBody) : 49 50 cdef int _exert(self, soy.bodies.Body _otherBody) nogil : 52 51 cdef float _radius, _submersion 53 52 ode.dBodyGetMass(_otherBody._bodyID, &_otherBody._mass) … … 58 57 if _otherBody._shape._volume() == 0 : 59 58 return 0 60 if self._shape :59 if self._shape is not None : 61 60 # Shaped fields partially submerge shapes 62 61 _radius = _otherBody._shape._radius() … … 65 64 _otherBody._shape._position[1], 66 65 _otherBody._shape._position[2]) 67 + radius) / (radius * 2)66 + _radius) / (_radius * 2) 68 67 else : 69 68 # Universal fields fully submerge all shapes 70 69 _submersion = 1 71 _otherBody._tags._insert("bmass", _otherBody._mass.mass - submersion70 _otherBody._tags._insert("bmass", _otherBody._mass.mass - _submersion 72 71 * _otherBody._shape._volume() 73 72 * self._density) 74 self._affected._append(<void*> other)73 self._affected._append(<void*> _otherBody) 75 74 return 1 75 76 76 77 77 ############################################################################ -
trunk/pysoy/src/fields/Field.pym
r1269 r1270 61 61 62 62 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 66 65 if self._bodyID == NULL : 67 66 return 1 68 67 _r = 1 69 _scene = <soy.scenes.Scene> self._scene 70 if not self._shape : 68 if self._shape is None : 71 69 # 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]) : 75 72 _r = 0 76 73 return _r 77 74 78 75 79 cdef int _exert(self, soy.bodies.Body _other) :76 cdef int _exert(self, soy.bodies.Body _other) nogil : 80 77 # This function is applied once per physics cycle for each combination 81 78 # of affected body and field. … … 83 80 84 81 85 cdef void _give(self, int _data) :82 cdef void _give(self, int _data) nogil : 86 83 # This function is called by the physics cycle for each field before 87 84 # any calls to _exert. It is used for any initialization or cleanup that -
trunk/pysoy/src/fields/Monopole.pym
r1229 r1270 39 39 # 40 40 41 cdef int _exert(self, soy.bodies.Body other) :41 cdef int _exert(self, soy.bodies.Body other) nogil : 42 42 self._affected._append(<void*> other) 43 43 return 0 -
trunk/pysoy/src/fields/Shockwave.pym
r1229 r1270 49 49 # 50 50 51 cdef int _exert(self, soy.bodies.Body other) :51 cdef int _exert(self, soy.bodies.Body other) nogil : 52 52 cdef float depth, force, dx, dy, dz, d 53 53 stdio.printf("begin exert\n") 54 54 # Give up if not active 55 if not self._shape or self._t0 == 0 :55 if self._shape is None or self._t0 == 0 : 56 56 return 1 57 57 … … 81 81 return 1 82 82 83 cdef void _give(self, int ccycle) :83 cdef void _give(self, int ccycle) nogil : 84 84 stdio.printf("begin give\n") 85 85 # Quit if inactive 86 if not self._shape or self._t0 == 0 :86 if self._shape is None or self._t0 == 0 : 87 87 stdio.printf("abort give\n") 88 88 return -
trunk/pysoy/src/fields/Wind.pym
r1229 r1270 38 38 39 39 # 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 : 41 41 cdef float dx, dy, dz, d2, r, f 42 42 if other._tags._has_key('cd') : -
trunk/pysoy/src/shapes/Box.pym
r1232 r1270 34 34 ode.dGeomSetData(self._geomID, <void*> self) 35 35 36 ############################################################################37 #38 # C functions39 #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 xyz46 ode.dGeomBoxGetLengths(self._geomID, xyz)47 return <float> xyz[0] * xyz[1] * xyz[2]48 49 cdef float _radius(self) :50 cdef ode.dVector3 xyz51 ode.dGeomBoxGetLengths(self._geomID, xyz)52 return <float> (xyz[0] + xyz[1] + xyz[2]) / 353 54 cdef int _finite(self) :55 return 156 36 57 37 ############################################################################ … … 71 51 def __set__(self, value) : 72 52 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 33 33 ode.dGeomSetData(self._geomID, <void*> self) 34 34 35 ############################################################################36 #37 # C functions38 #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, l45 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, l50 ode.dGeomCapsuleGetParams(self._geomID, &r, &l)51 return <float> (l / 2 + r)52 53 cdef int _finite(self) :54 return 155 35 56 36 ############################################################################ … … 74 54 ode.dGeomCapsuleSetParams(self._geomID, r, l) 75 55 56 76 57 property length : 77 58 '''Capsule's length … … 88 69 l = value 89 70 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 33 33 ode.dGeomSetData(self._geomID, <void*> self) 34 34 35 ############################################################################36 #37 # C functions38 #39 40 cdef float _radius(self) :41 return 042 43 cdef int _finite(self) :44 return 045 35 46 36 ############################################################################ … … 86 76 ode.dGeomRayGet(self._geomID, s, d) 87 77 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 33 33 self._geomID = NULL 34 34 35 35 36 ############################################################################ 36 37 # … … 38 39 # 39 40 40 cdef float _pointDepth(self, float x, float y, float z):41 cdef float _pointDepth(self, float _x, float _y, float _z) nogil : 41 42 return 0 42 43 43 cdef float _volume(self) :44 cdef float _volume(self) nogil : 44 45 return 0 45 46 46 cdef float _radius(self) :47 cdef float _radius(self) nogil : 47 48 return 0 48 49 49 cdef int _finite(self) :50 cdef int _finite(self) nogil : 50 51 return 0 -
trunk/pysoy/src/shapes/Sphere.pym
r1232 r1270 33 33 ode.dGeomSetData(self._geomID, <void*> self) 34 34 35 ############################################################################36 #37 # C functions38 #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.141592653545 46 cdef float _radius(self) :47 return <float> ode.dGeomSphereGetRadius(self._geomID)48 49 cdef int _finite(self) :50 return 151 35 52 36 ############################################################################ … … 64 48 def __set__(self, value) : 65 49 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
