Author: AngeloTheodorou
Date: 2007-08-02 13:46:49 -0400 (Thu, 02 Aug 2007)
New Revision: 513

Modified:
   branches/pysoy-perbodylighting/src/_core-common/Scene.pxi
   branches/pysoy-perbodylighting/src/_core-common/_callback.pxi
   branches/pysoy-perbodylighting/src/_core-x11/soy._core.pxd
   branches/pysoy-perbodylighting/src/bodies._bodies/Body.pxi
   branches/pysoy-perbodylighting/src/bodies._bodies/soy.bodies._bodies.pxd
   branches/pysoy-perbodylighting/src/bodies.lights/Light.pxi
   branches/pysoy-perbodylighting/tests/lit_pyramid.py
Log:
- Still not working but not segfaulting either ;)
- Removed Scene's lights list
- Fixed a bug in collisions _callback()
- Simpler Light.__new__() method
- No more overrided scene property for Light


Modified: branches/pysoy-perbodylighting/src/_core-common/Scene.pxi
===================================================================
--- branches/pysoy-perbodylighting/src/_core-common/Scene.pxi   2007-08-02 
09:46:00 UTC (rev 512)
+++ branches/pysoy-perbodylighting/src/_core-common/Scene.pxi   2007-08-02 
17:46:49 UTC (rev 513)
@@ -33,7 +33,6 @@
   def __new__(self, *args, **kw) :
     global _scenes
     self._bodies   = soy._internals.Children()
-    self._lights   = soy._internals.Children()
     self._worldID  = ode.dWorldCreate()
     self._spaceID  = ode.dSimpleSpaceCreate(NULL)
     self._stepSize = 0.01
@@ -83,17 +82,13 @@
     self._bodies.lock()
     for i from 0 <= i < self._bodies.current :
       _body = <soy.bodies._bodies.Body> self._bodies.list[i]
-      self._lights.lock()
       for j from 0 <= j < _body._nlights :
         # This is a quick hack (gl.GL_LIGHT0+j)
-        (<soy.bodies.lights.Light> _body._lights)._on(gl.GL_LIGHT0+j)
-      self._lights.unlock()
+        (<soy.bodies.lights.Light> _body._lights[j])._on(gl.GL_LIGHT0+j)
       _body._render()
-      self._lights.lock()
       for j from 0 <= j < _body._nlights :
         # This is a quick hack (gl.GL_LIGHT0+j)
-        (<soy.bodies.lights.Light> _body._lights)._off(gl.GL_LIGHT0+j)
-      self._lights.unlock()
+        (<soy.bodies.lights.Light> _body._lights[j])._off(gl.GL_LIGHT0+j)
       _body._nlights = 0 # clearing the lights list
     self._bodies.unlock()
     gl.glDisable(gl.GL_LIGHTING)

Modified: branches/pysoy-perbodylighting/src/_core-common/_callback.pxi
===================================================================
--- branches/pysoy-perbodylighting/src/_core-common/_callback.pxi       
2007-08-02 09:46:00 UTC (rev 512)
+++ branches/pysoy-perbodylighting/src/_core-common/_callback.pxi       
2007-08-02 17:46:49 UTC (rev 513)
@@ -36,7 +36,7 @@
     # Get the Body objects
     bo1 = <soy.bodies._bodies.Body> ode.dBodyGetData(b1)
     bo2 = <soy.bodies._bodies.Body> ode.dBodyGetData(b2)
-    f = 0; l = 0
+    f = 0
     # activate any fields present...
     if isinstance(bo1, soy.bodies.fields.Field) :
       f = 1
@@ -46,13 +46,12 @@
       (<soy.bodies.fields.Field> bo2)._exert(bo1)
     # calculating light influence
     if isinstance(bo1, soy.bodies.lights.Light) ^ isinstance(bo2, 
soy.bodies.lights.Light) : # XOR
-      l = 1
       if isinstance(bo1, soy.bodies.lights.Light) :
         bo2._addLight(bo1)
       else :
         bo1._addLight(bo2)
-    # if neither shape is a field or a light
-    if f == 0 and l == 0 :
+    # if neither shape is a field
+    if f == 0:
       ct.geom = cg
       ct.surface.mode = ode.dContactBounce
       ct.surface.bounce = 0.8

Modified: branches/pysoy-perbodylighting/src/_core-x11/soy._core.pxd
===================================================================
--- branches/pysoy-perbodylighting/src/_core-x11/soy._core.pxd  2007-08-02 
09:46:00 UTC (rev 512)
+++ branches/pysoy-perbodylighting/src/_core-x11/soy._core.pxd  2007-08-02 
17:46:49 UTC (rev 513)
@@ -31,7 +31,6 @@
   cdef ode.dWorldID             _worldID
   cdef ode.dSpaceID             _spaceID
   cdef soy._internals.Children  _bodies
-  cdef soy._internals.Children  _lights
   cdef soy.colors.Color         _ambient
   cdef ode.dReal                _stepSize
   cdef double                   _prevTime

Modified: branches/pysoy-perbodylighting/src/bodies._bodies/Body.pxi
===================================================================
--- branches/pysoy-perbodylighting/src/bodies._bodies/Body.pxi  2007-08-02 
09:46:00 UTC (rev 512)
+++ branches/pysoy-perbodylighting/src/bodies._bodies/Body.pxi  2007-08-02 
17:46:49 UTC (rev 513)
@@ -301,8 +301,10 @@
 
 
   cdef void _addLight(self, object _light) :
-    if not (isinstance(_light, soy.bodies.lights.Light)) :
-      raise TypeError('must be an instance of soy.lights.Light')
+    '''Adding an influencing (colliding) light to the body's array of lights'''
+    stdio.printf('Body._addLight()\n')
+#    if not (isinstance(_light, soy.bodies.lights.Light)) :
+#      raise TypeError('must be an instance of soy.lights.Light')
 
     # Maximum number of OpenGL lights concurrently active is 8.
        # Trying to add more results in the body ignoring them.
@@ -311,3 +313,4 @@
     else :
       self._lights[self._nlights] = <void *>_light
       self._nlights = self._nlights + 1
+      stdio.printf('nlights incremented to %d\n', self._nlights)

Modified: 
branches/pysoy-perbodylighting/src/bodies._bodies/soy.bodies._bodies.pxd
===================================================================
--- branches/pysoy-perbodylighting/src/bodies._bodies/soy.bodies._bodies.pxd    
2007-08-02 09:46:00 UTC (rev 512)
+++ branches/pysoy-perbodylighting/src/bodies._bodies/soy.bodies._bodies.pxd    
2007-08-02 17:46:49 UTC (rev 513)
@@ -46,7 +46,7 @@
   cdef void                     _destroy(self)
   cdef int                      _isActive(self)
   cdef void                     _render(self)
-  cdef void                     _addLight(self, _light)
+  cdef void                     _addLight(self, object _light)
   cdef void                            poke(self, vector)
 
 

Modified: branches/pysoy-perbodylighting/src/bodies.lights/Light.pxi
===================================================================
--- branches/pysoy-perbodylighting/src/bodies.lights/Light.pxi  2007-08-02 
09:46:00 UTC (rev 512)
+++ branches/pysoy-perbodylighting/src/bodies.lights/Light.pxi  2007-08-02 
17:46:49 UTC (rev 513)
@@ -23,18 +23,12 @@
      Lights provide illumination in your scene.  Needs more work.
   '''
 
-  def __new__(self, object scene=None, *args, **keywords) : 
-    if scene == None :
-      self._bodyID = NULL 
-    else :
-      self.scene = scene
-
+  def __new__(self, *args, **keywords) :
     import soy.colors
     self._ambient = soy.colors.Black()    
     self._diffuse = soy.colors.White()
     self._specular = soy.colors.White()
 
-
   cdef void _on(self, int id) :
     cdef gl.GLfloat _ambient[4]
     cdef gl.GLfloat _diffuse[4]
@@ -51,63 +45,12 @@
     gl.glLightfv(id, gl.GL_SPECULAR, _specular)
     gl.glLightfv(id, gl.GL_POSITION, _position)
 
-
   cdef void _off(self, int id) :
     gl.glDisable(id)
 
-
   cdef void _render(self) :
     return
 
-
-  property scene :
-    '''Light's Scene
-
-    This is the Scene that the light is in.  When changed the body's position,
-    orientation, velocity, and rotation are all reset to (0,0,0).
-       It has be overridden from Body's method and altered to let the light be 
-       added to the more specific _lights Children object.
-    '''
-    def __get__(self) :
-      if self._isActive() :
-        return self._scene
-      else :
-        return None
-    def __set__(self, newscene) :
-      if not (isinstance(newscene, soy._core.Scene) or newscene==None) :
-        raise TypeError('not an instance of soy.Scene')
-      if self._isActive() :
-        self._scene._bodies.lock()
-        self._scene._lights.lock()
-        self._scene._bodies.remove(<void *>self)
-        self._scene._lights.remove(<void *>self)
-        self._destroy()
-        self._scene._bodies.unlock()
-        self._scene._lights.unlock()
-        if self._shape :
-          if self._scene :
-            ode.dSpaceRemove(self._scene._spaceID, self._shape._geomID)
-          ode.dSpaceAdd((<soy._core.Scene> newscene)._spaceID, 
self._shape._geomID)
-      if newscene != None :
-        self._scene = newscene
-        self._scene._bodies.lock()
-        self._scene._lights.lock()
-        self._create()
-        self._scene._bodies.append(<void *>self)
-        self._scene._lights.append(<void *>self)
-        self._scene._bodies.unlock()
-        self._scene._lights.unlock()
-    def __del__(self) :
-      if self._isActive() :
-        self._scene._bodies.lock()
-        self._scene._bodies.remove(<void *>self)
-        self._destroy()
-        self._scene._bodies.unlock()
-        self._scene._lights.lock()
-        self._scene._lights.remove(<void *>self)
-        self._scene._lights.unlock()
-
-
   property ambient :
     def __get__(self) :
       return self._ambient
@@ -125,4 +68,3 @@
       return self._specular
     def __set__(self, soy.colors.Color value) :
       self._specular = value
-

Modified: branches/pysoy-perbodylighting/tests/lit_pyramid.py
===================================================================
--- branches/pysoy-perbodylighting/tests/lit_pyramid.py 2007-08-02 09:46:00 UTC 
(rev 512)
+++ branches/pysoy-perbodylighting/tests/lit_pyramid.py 2007-08-02 17:46:49 UTC 
(rev 513)
@@ -16,7 +16,7 @@
 cam = soy.bodies.Camera(sce)
 cam.position = (0.0, 0.0, 5.0)
 pro = soy.widgets.Projector(win, camera=cam)
-pyr = soy.bodies.Body(sce, mesh=pym)
+pyr = soy.bodies.Body(sce, mesh=pym, shape=sph)
 pyr.rotation = (1.0, 0.0, 0.0)
 lig = soy.bodies.lights.Light(sce, shape=sph)
 lig.position = (-1.0, 1.0, 2.0)

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to