Author: ArcRiley
Date: 2008-02-26 14:27:45 -0500 (Tue, 26 Feb 2008)
New Revision: 993

Modified:
   trunk/pysoy/src/bodies.lights/Light.pxi
Log:
Ticket #934 :
  * Light's cinit no longer removes/readds to scene (first add with Body)
  * oops - glLightfv GL_POSITION takes float[4], was passing float[3]
  * still segfaults when light is active, bug likely outside Light


Modified: trunk/pysoy/src/bodies.lights/Light.pxi
===================================================================
--- trunk/pysoy/src/bodies.lights/Light.pxi     2008-02-26 18:48:54 UTC (rev 
992)
+++ trunk/pysoy/src/bodies.lights/Light.pxi     2008-02-26 19:27:45 UTC (rev 
993)
@@ -24,11 +24,14 @@
   '''
 
   def __cinit__(self, object scene=None, *args, **keywords) : 
-    if scene == None :
-      self._bodyID = NULL 
-    else :
-      self.scene = scene
-
+    if isinstance(scene, soy.scenes.Scene) :
+      self._scene._lights.lock()
+      self._scene._lights.append(<void *>self)
+      self._scene._lights.unlock()
+    elif scene != None :
+      raise TypeError('not an instance of soy.scenes.Scene')
+    #
+    # These need to be capable of being set with __cinit__
     self._ambient = soy.colors.black
     self._diffuse = soy.colors.white
     self._specular = soy.colors.white
@@ -38,14 +41,19 @@
     cdef gl.GLfloat _ambient[4]
     cdef gl.GLfloat _diffuse[4]
     cdef gl.GLfloat _specular[4]
+    cdef gl.GLfloat _position[4]
     gl.glEnable(id)
     (<soy.colors.Color>  self._ambient)._getRGBA(_ambient)
     (<soy.colors.Color>  self._diffuse)._getRGBA(_diffuse)
     (<soy.colors.Color> self._specular)._getRGBA(_specular)
+    _position[0] = self._position[0]
+    _position[1] = self._position[1]
+    _position[2] = self._position[2]
+    _position[3] = 1.0
     gl.glLightfv(id, gl.GL_AMBIENT,  _ambient)
     gl.glLightfv(id, gl.GL_DIFFUSE,  _diffuse)
     gl.glLightfv(id, gl.GL_SPECULAR, _specular)
-    gl.glLightfv(id, gl.GL_POSITION, self._position)
+    gl.glLightfv(id, gl.GL_POSITION, _position)
 
 
   cdef void _off(self, int id) :

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

Reply via email to