Author: ArcRiley Date: 2008-05-18 14:26:30 -0400 (Sun, 18 May 2008) New Revision: 1269
Modified: trunk/pysoy/src/fields/Field.pym trunk/pysoy/src/scenes/Scene.pym Log: '''Pyrex 0.9.8.2 fixes''' : * soy.fields now add themselves to Scene._fields * removed extraneous <void*> castings in Scene._loop Modified: trunk/pysoy/src/fields/Field.pym =================================================================== --- trunk/pysoy/src/fields/Field.pym 2008-05-18 18:21:36 UTC (rev 1268) +++ trunk/pysoy/src/fields/Field.pym 2008-05-18 18:26:30 UTC (rev 1269) @@ -23,11 +23,42 @@ Fields are optionally visible generic objects in 3d space that apply forces and other changes to other bodies. ''' + + ############################################################################ + # + # Python Functions + # + + def __cinit__(self, scene=None, + *args, **keywords) : + if self._scene is not None : + self._scene._fields._append(<void*> self) + ############################################################################ # - # C functions + # General C functions # + + cdef void _append(self) : + # + # this overrides Body._append to also append self to self._scene._fields + # + self._scene._bodies._append(<void*> self) + self._scene._fields._append(<void*> self) + # + ###################################### + + + cdef void _remove(self) : + # + # this overrides Body._remove to also remove self from self._scene._fields + # + self._scene._bodies._remove(<void*> self) + self._scene._fields._remove(<void*> self) + # + ###################################### + cdef int _apply(self) : cdef int _i, _r @@ -44,17 +75,20 @@ _r = 0 return _r + cdef int _exert(self, soy.bodies.Body _other) : # This function is applied once per physics cycle for each combination # of affected body and field. return 1 + cdef void _give(self, int _data) : # This function is called by the physics cycle for each field before # any calls to _exert. It is used for any initialization or cleanup that # the Field requires. return + cdef void _commit(self) : # This function is called by the physics cycle after every call to _exert # has been done Modified: trunk/pysoy/src/scenes/Scene.pym =================================================================== --- trunk/pysoy/src/scenes/Scene.pym 2008-05-18 18:21:36 UTC (rev 1268) +++ trunk/pysoy/src/scenes/Scene.pym 2008-05-18 18:26:30 UTC (rev 1269) @@ -92,15 +92,15 @@ self._fields._iterStart() for _i from 0 <= _i < self._fields._current : # Make sure every field is in givefields & _give each one - if not self._giveFields._has_key(<void*> self._fields._list[_i]) : + if not self._giveFields._has_key(self._fields._list[_i]) : (<soy.fields.Field> self._fields._list[_i])._give(0) - self._giveFields._insert(<void*> self._fields._list[_i]) + self._giveFields._insert(self._fields._list[_i]) # for _i from 0 <= _i < self._fields._current : # Apply fields; add incompletly applied fields to the list if not (<soy.fields.Field> self._fields._list[_i])._apply() : pass - #self._callFields._insert(self._bodies.list[_i]) + #self._callFields._insert(self._fields.list[_i]) # # Apply any outstanding fields self._callFields._foreach(_runField, NULL) @@ -123,14 +123,13 @@ cdef void _render(self) : - cdef int _i + cdef int _i # # Setup scene-level rendering gl.glClear(gl.GL_DEPTH_BUFFER_BIT) gl.glEnable(gl.GL_DEPTH_TEST) gl.glEnable(gl.GL_LIGHTING) - gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, - (<soy.colors.Color> self._ambient)._rgba) + gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, self._ambient._rgba) # # Turn on each light, keep it's iteration locked against mod until done self._lights._iterStart() @@ -165,12 +164,15 @@ self._prevTime = self._prevTime + (_step * self._stepSize) return _step + cdef void _stepLock(self) nogil : py.PyThread_acquire_lock(self._stepMutex,1) + cdef int _stepTryLock(self) nogil : return py.PyThread_acquire_lock(self._stepMutex,0) + cdef void _stepUnLock(self) nogil : py.PyThread_release_lock(self._stepMutex) @@ -312,6 +314,7 @@ def __set__(self, soy.colors.Color value) : self._ambient = value + property friction : '''Scene's Friction _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn