Author: EricStein
Date: 2007-07-02 02:57:17 -0400 (Mon, 02 Jul 2007)
New Revision: 323

Modified:
   trunk/pysoy/include/ode.pxd
   trunk/pysoy/src/_core-common/_coreLoop.pxi
   trunk/pysoy/src/bodies.fields/Field.pxi
Log:
fixed declarations in ode.pxd, worked on collision activated fields


Modified: trunk/pysoy/include/ode.pxd
===================================================================
--- trunk/pysoy/include/ode.pxd 2007-07-01 09:25:23 UTC (rev 322)
+++ trunk/pysoy/include/ode.pxd 2007-07-02 06:57:17 UTC (rev 323)
@@ -102,7 +102,7 @@
     dVector3    pos
     dVector3    normal
     dReal       depth
-    dGeomID     g1
+    dGeomID     g1, g2
 
   cdef void  dInitODE()
 
@@ -162,7 +162,7 @@
 
   cdef void     dSpaceCollide        ( dSpaceID, void*, dNearCallback )
   cdef void     dSpaceCollide2       ( dGeomID, dGeomID, void*, dNearCallback )
-  cdef int      dCollide             ( dGeomID, dGeomID, int, dContactGeom, 
int )
+  cdef int      dCollide             ( dGeomID, dGeomID, int, dContactGeom*, 
int )
 
   # General geom functions
   cdef void           dGeomDestroy          ( dGeomID )

Modified: trunk/pysoy/src/_core-common/_coreLoop.pxi
===================================================================
--- trunk/pysoy/src/_core-common/_coreLoop.pxi  2007-07-01 09:25:23 UTC (rev 
322)
+++ trunk/pysoy/src/_core-common/_coreLoop.pxi  2007-07-02 06:57:17 UTC (rev 
323)
@@ -18,7 +18,30 @@
 # $Id$
 
 cdef void callback(void* data, ode.dGeomID o1, ode.dGeomID o2) :
-  return
+  cdef int c
+  cdef ode.dBodyID b1, b2
+  cdef soy.bodies._bodies.Body bo1, bo2
+  cdef ode.dContactGeom cg
+  # Get associated bodies
+  b1 = ode.dGeomGetBody(o1)
+  b2 = ode.dGeomGetBody(o2)
+  # Do not continue if we can't do anything with our collisions
+  if b1 == NULL or b2 == NULL :
+    return
+  # Wham!
+  c = ode.dCollide(o1, o2, 1, &cg, sizeof(cg))
+  if c > 0 :
+    # Get the Body objects
+    bo1 = <soy.bodies._bodies.Body> ode.dBodyGetData(b1)
+    bo2 = <soy.bodies._bodies.Body> ode.dBodyGetData(b2)
+    # activate any fields present...
+#    stdio.printf("%d has collided with %d!\n", bo1._bodyID, bo2._bodyID)
+    if isinstance(bo1, soy.bodies.fields.Field) :
+      stdio.printf("looks like %d is a field!\n", bo1._bodyID)
+      (<soy.bodies.fields.Field> bo1)._exert(bo2)
+    if isinstance(bo2, soy.bodies.fields.Field) :
+      stdio.printf("looks like %d is a field!\n", bo2._bodyID)
+      (<soy.bodies.fields.Field> bo2)._exert(bo1)
 
 cdef void _coreLoop() :
   cdef int i, j

Modified: trunk/pysoy/src/bodies.fields/Field.pxi
===================================================================
--- trunk/pysoy/src/bodies.fields/Field.pxi     2007-07-01 09:25:23 UTC (rev 
322)
+++ trunk/pysoy/src/bodies.fields/Field.pxi     2007-07-02 06:57:17 UTC (rev 
323)
@@ -27,9 +27,7 @@
   cdef void apply(self) :
     cdef int i
     if self._scene :
-      if self._shape :
-         return #TODO ODE collision based apply()
-      else :
+      if not self._shape :
         for i from 0 <= i < self._scene._bodies.current :
           if (<soy.bodies._bodies.Body> self._scene._bodies.list[i])._bodyID :
             self._exert(<soy.bodies._bodies.Body> self._scene._bodies.list[i])

_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to