From bfdd557c0279a98cdd807cd0ce693af5256a7ba8 Mon Sep 17 00:00:00 2001
From: David Martinez Marti <desarrollo@gestiweb.com>
Date: Thu, 17 Dec 2009 09:37:24 +0100
Subject: [PATCH 1/4] Correct pyrex bug (typecast + functioncall)

---
 .gitignore                |    7 +++++++
 soya/main_loop.pyx        |    4 ++++
 soya/model/tree.pyx       |    8 ++++++--
 soya/ode/collision.pyx    |    4 +++-
 soya/ode/geom-terrain.pyx |    8 ++++++--
 soya/ode/old/land.pyx     |    8 ++++++--
 soya/ode/old/terrain.pyx  |    8 ++++++--
 soya/ode/old/util.pyx     |    4 +++-
 soya/ode/space.pyx        |    6 ++++--
 soya/soya3d/raypick.pyx   |   18 +++++++++++++-----
 soya/soya3d/world.pyx     |    8 ++++++--
 11 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/.gitignore b/.gitignore
index eef83e4..e88ba01 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,8 @@
 *.svn
+soya/build
+*~
+soya/_soya.c
+soya/config.pxd
+soya/config.pyx
+soya/opengl.c
+soya/sdlconst.c
diff --git a/soya/main_loop.pyx b/soya/main_loop.pyx
index 227ec65..3ff33d3 100644
--- a/soya/main_loop.pyx
+++ b/soya/main_loop.pyx
@@ -285,12 +285,16 @@ Called by MainLoop.main_loop when rendering is needed; default implementation ca
 
 		Take note that Mouse motion have been coalesced. If you what them all, see
 		the raw_event property."""
 		def __get__(self):
 			return self._events
 
+		def __set__(self,val):
+			"""Deprecated: Mainloop.events will be not writable in the future"""
+			self._events = val
+			
 	property raw_events:
 		"""List all events from the round. Mouse motion have not yet coalesced"""
 		def __get__(self):
 			return self._raw_events
 
 	def queue_event(self, event):
diff --git a/soya/model/tree.pyx b/soya/model/tree.pyx
index 1a3635b..a457ac9 100644
--- a/soya/model/tree.pyx
+++ b/soya/model/tree.pyx
@@ -389,24 +389,28 @@ cdef class _TreeModel(_SimpleModel):
 		chunk_add_int(items, -1)
 		
 	cdef void _raypick_from_context(self, RaypickData data, Chunk* items):
 		cdef float*     raydata
 		cdef int        face_index
 		cdef CoordSyst  parent
-		parent  = <CoordSyst> chunk_get_ptr(items)
+		cdef void*      tmp_ptr
+		tmp_ptr = chunk_get_ptr(items)
+		parent  = <CoordSyst> tmp_ptr
 		raydata = parent._raypick_data(data)
 		face_index = chunk_get_int(items)
 		while face_index != -1:
 			self._face_raypick(self._faces + face_index, raydata, data, parent)
 			face_index = chunk_get_int(items)
 			
 	cdef int _raypick_from_context_b(self, RaypickData data, Chunk* items):
 		cdef float*     raydata
 		cdef int        face_index
 		cdef CoordSyst  parent
-		parent  = <CoordSyst> chunk_get_ptr(items)
+		cdef void*      tmp_ptr
+		tmp_ptr = chunk_get_ptr(items)
+		parent  = <CoordSyst> tmp_ptr
 		raydata = parent._raypick_data(data)
 		face_index = chunk_get_int(items)
 		while face_index != -1:
 			if self._face_raypick_b(self._faces + face_index, raydata, data): return 1
 			face_index = chunk_get_int(items)
 		return 0
diff --git a/soya/ode/collision.pyx b/soya/ode/collision.pyx
index d9e1be3..06efc87 100644
--- a/soya/ode/collision.pyx
+++ b/soya/ode/collision.pyx
@@ -114,12 +114,13 @@ def collide(_Geom geom1, _Geom geom2, int max_contacts=8):
 #U#		cdef dGeomID _land_ray   # Reusable ray geom #XXX misplaced
 #U#
 #U#
 #U#		cdef int n, num_contacts, nA, nB
 #U#		cdef dContactGeom contactA, contactB
 #U#		cdef _Geom other
+#U#		cdef void* tmp_ptr
 #U#		_land_ray = dCreateRay(NULL, 1.0)#XXX misplaced
 #U#
 #U#		# First, do one direction
 #U#		dGeomRaySetLength(_land_ray, point_distance_to(A, B))
 #U#		dGeomRaySet(_land_ray, A[0], A[1], A[2], AB[0], AB[1], AB[2])
 #U#		nA = dCollide(_land_ray, o2, flags, &contactA, sizeof(dContactGeom))
@@ -138,13 +139,14 @@ def collide(_Geom geom1, _Geom geom2, int max_contacts=8):
 #U#				# D
 #U#				contact.normal[0] = (normalA[0] + normalB[0]) / 2.0
 #U#				contact.normal[1] = (normalA[1] + normalB[1]) / 2.0
 #U#				contact.normal[2] = (normalA[2] + normalB[2]) / 2.0
 #U#
 #U#				# Get the depth of the contact point in the colliding geom
-#U#				other = <_Geom>dGeomGetData(o2)
+#U#				tmp_ptr = dGeomGetData(o2)
+#U#				other = <_Geom>tmp_ptr
 #U#				contact.depth = other._point_depth(contact.pos[0], contact.pos[1], 
 #U#																					 contact.pos[2])
 #U#				contact.g1 = o1
 #U#				contact.g2 = o2
 #U#
 #U#				return 1
diff --git a/soya/ode/geom-terrain.pyx b/soya/ode/geom-terrain.pyx
index e747680..ae689fc 100644
--- a/soya/ode/geom-terrain.pyx
+++ b/soya/ode/geom-terrain.pyx
@@ -435,19 +435,23 @@ cdef dGeomID _terrain_ray   # Reusable ray geom
 
 _terrain_plane = dCreatePlane(NULL, 0.0, 1.0, 0.0, 0.0)
 _terrain_ray = dCreateRay(NULL, 1.0)
 
 cdef void _TerrainGetAABB(dGeomID geom, dReal aabb[6]):
 		cdef _GeomTerrain geom_terrain
-		geom_terrain = <_GeomTerrain>dGeomGetData(geom)
+		cdef void* tmp_ptr
+		tmp_ptr = dGeomGetData(geom)
+		geom_terrain = <_GeomTerrain>tmp_ptr
 		geom_terrain._get_aabb(aabb)
 
 cdef int _TerrainCollide(dGeomID o1, dGeomID o2, int flags,
 										 dContactGeom *contact, int skip):
 		cdef _GeomTerrain geom_terrain
-		geom_terrain = <_GeomTerrain>dGeomGetData(o1)
+		cdef void* tmp_ptr
+		tmp_ptr = dGeomGetData(o1)
+		geom_terrain = <_GeomTerrain>tmp_ptr
 		return geom_terrain._collide(o1, o2, flags, contact, skip)
 
 
 cdef dColliderFn * _TerrainGetColliderFn(int gclass):
 
 		if gclass in (dSphereClass, dBoxClass, dCapsuleClass, dCylinderClass):
diff --git a/soya/ode/old/land.pyx b/soya/ode/old/land.pyx
index 5b9f442..bc4bf1d 100644
--- a/soya/ode/old/land.pyx
+++ b/soya/ode/old/land.pyx
@@ -401,19 +401,23 @@ cdef dGeomID _land_ray   # Reusable ray geom
 
 _land_plane = dCreatePlane(NULL, 0.0, 1.0, 0.0, 0.0)
 _land_ray = dCreateRay(NULL, 1.0)
 
 cdef void LandGetAABB(dGeomID geom, dReal aabb[6]):
 		cdef _Land land
-		land = <_Land>dGeomGetData(geom)
+		cdef void* tmp_ptr
+		tmp_ptr = dGeomGetData(geom)
+		land = <_Land>tmp_ptr
 		land._get_aabb(aabb)
 
 cdef int LandCollide(dGeomID o1, dGeomID o2, int flags,
 										 dContactGeom *contact, int skip):
 		cdef _Land land
-		land = <_Land>dGeomGetData(o1)
+		cdef void* tmp_ptr
+		tmp_ptr = dGeomGetData(o1)
+		land = <_Land>tmp_ptr
 		return land._collide(o1, o2, flags, contact, skip)
 
 
 cdef dColliderFn * LandGetColliderFn(int gclass):
 
 		if gclass in (dSphereClass, dBoxClass, dCCylinderClass):
diff --git a/soya/ode/old/terrain.pyx b/soya/ode/old/terrain.pyx
index ea3c043..ed91f4f 100644
--- a/soya/ode/old/terrain.pyx
+++ b/soya/ode/old/terrain.pyx
@@ -401,19 +401,23 @@ cdef dGeomID _terrain_ray   # Reusable ray geom
 
 _terrain_plane = dCreatePlane(NULL, 0.0, 1.0, 0.0, 0.0)
 _terrain_ray = dCreateRay(NULL, 1.0)
 
 cdef void TerrainGetAABB(dGeomID geom, dReal aabb[6]):
 		cdef _Terrain terrain
-		terrain = <_Terrain>dGeomGetData(geom)
+		cdef void* tmp_buf
+		tmp_buf = dGeomGetData(geom)
+		terrain = <_Terrain>tmp_buf
 		terrain._get_aabb(aabb)
 
 cdef int TerrainCollide(dGeomID o1, dGeomID o2, int flags,
 										 dContactGeom *contact, int skip):
 		cdef _Terrain terrain
-		terrain = <_Terrain>dGeomGetData(o1)
+		cdef void* tmp_buf
+		tmp_buf = dGeomGetData(o1)
+		terrain = <_Terrain>tmp_buf
 		return terrain._collide(o1, o2, flags, contact, skip)
 
 
 cdef dColliderFn * TerrainGetColliderFn(int gclass):
 
 		if gclass in (dSphereClass, dBoxClass, dCCylinderClass):
diff --git a/soya/ode/old/util.pyx b/soya/ode/old/util.pyx
index 3692ea5..5a248c5 100644
--- a/soya/ode/old/util.pyx
+++ b/soya/ode/old/util.pyx
@@ -28,12 +28,13 @@ cdef int collide_edge(GLfloat *A, GLfloat *B,
 		that's halfway between the precomputed normals of the vertices
 		that make up the edge."""
 
 		cdef int n, num_contacts, nA, nB
 		cdef dContactGeom contactA, contactB
 		cdef GeomObject other
+		cdef void* tmp_buf
 
 		# First, do one direction
 		dGeomRaySetLength(_land_ray, _soya.point_distance_to(A, B))
 		dGeomRaySet(_land_ray, A[0], A[1], A[2], AB[0], AB[1], AB[2])
 		nA = dCollide(_land_ray, o2, flags, &contactA, sizeof(dContactGeom))
 
@@ -49,13 +50,14 @@ cdef int collide_edge(GLfloat *A, GLfloat *B,
 				# D
 				contact.normal[0] = (normalA[0] + normalB[0]) / 2.0
 				contact.normal[1] = (normalA[1] + normalB[1]) / 2.0
 				contact.normal[2] = (normalA[2] + normalB[2]) / 2.0
 
 				# Get the depth of the contact point in the colliding geom
-				other = <GeomObject>dGeomGetData(o2)
+				tmp_buf = dGeomGetData(o2)
+				other = <GeomObject>tmp_buf
 				contact.depth = other._point_depth(contact.pos[0], contact.pos[1], 
 																					 contact.pos[2])
 				contact.g1 = o1
 				contact.g2 = o2
 
 				return 1
diff --git a/soya/ode/space.pyx b/soya/ode/space.pyx
index d170fb0..516d4eb 100644
--- a/soya/ode/space.pyx
+++ b/soya/ode/space.pyx
@@ -205,12 +205,14 @@ cdef class SimpleSpace(_Space):
 	number of objects. This is also useful for debugging potential
 	problems with the collision system.
 	"""
 
 	cdef _create(self):
 		cdef dSpaceID parent_id
+		cdef void* tmp_buf
 		if self._space is None:
 			parent_id = NULL
 		else:
 			parent_id = <dSpaceID>self._space._OdeGeomID
-		
-		self._OdeGeomID = <dGeomID>dSimpleSpaceCreate(parent_id)
+
+		tmp_buf = dSimpleSpaceCreate(parent_id)		
+		self._OdeGeomID = <dGeomID>tmp_buf
diff --git a/soya/soya3d/raypick.pyx b/soya/soya3d/raypick.pyx
index 8511961..493d426 100644
--- a/soya/soya3d/raypick.pyx
+++ b/soya/soya3d/raypick.pyx
@@ -84,24 +84,26 @@ See World.raypick"""
 		
 		cdef RaypickData data
 		cdef _CObj       obj
 		cdef CoordSyst   coordsyst
 		cdef float*      d
 		cdef int         max
+		cdef void*       tmp_ptr
 		data = get_raypick_data()
 		
 		origin   ._out(data.root_data)
 		direction._out(&data.root_data[0] + 3)
 		vector_normalize(&data.root_data[0] + 3)
 		data.root_data[6] = distance
 		data.option       = RAYPICK_CULL_FACE * cull_face + RAYPICK_HALF_LINE * half_line
 		
 		max = items.nb
 		items.nb = 0
 		while items.nb < max:
-			obj = <_CObj> chunk_get_ptr(items)
+			tmp_ptr = chunk_get_ptr(items)
+			obj = <_CObj> tmp_ptr
 			if   isinstance(obj, _TreeModel):
 				(<_TreeModel> obj)._raypick_from_context(data, items)
 			elif isinstance(obj, _BSPWorld):
 				(<_BSPWorld>obj)._raypick_from_context(data, items, category)
 			else:
 				(<CoordSyst> obj)._raypick(data, (<CoordSyst> obj)._parent, category)
@@ -109,13 +111,14 @@ See World.raypick"""
 		if data.result_coordsyst is None: d = NULL
 		else:                             d = data.result_coordsyst._raypick_data(data)
 		
 		max = data.raypicked.nb
 		data.raypicked.nb = 0
 		while data.raypicked.nb < max:
-			coordsyst = <CoordSyst> chunk_get_ptr(data.raypicked)
+			tmp_ptr = chunk_get_ptr(data.raypicked)
+			coordsyst = <CoordSyst> tmp_ptr
 			coordsyst.__raypick_data = -1
 			
 		return make_raypick_result(d, data.result, data.normal, data.result_coordsyst, p, v)
 		
 	def raypick_b(self, Position origin not None, _Vector direction not None, float distance = -1.0, int half_line = 1, int cull_face = 1, _Point p = None, _Vector v = None, int category = 0xffffffff):
 		"""raypick_b(origin, direction, distance = -1.0, half_line = 1, cull_face = 1, p = None, v = None, category = 1) -> bool
@@ -126,49 +129,54 @@ See World.raypick_b"""
 		if items.nb == 0: return 0
 		
 		cdef RaypickData data
 		cdef _CObj       obj
 		cdef CoordSyst   coordsyst
 		cdef int         result, max
+		cdef void*       tmp_ptr
 		data = get_raypick_data()
 		origin   ._out(data.root_data)
 		direction._out(&data.root_data[0] + 3)
 		vector_normalize(&data.root_data[0] + 3)
 		data.root_data[6] = distance
 		data.option       = RAYPICK_CULL_FACE * cull_face + RAYPICK_HALF_LINE * half_line
 		
 		max = items.nb
 		items.nb = 0
 		while items.nb < max:
-			obj = <_CObj> chunk_get_ptr(items)
+			tmp_ptr = chunk_get_ptr(items) 
+			obj = <_CObj> tmp_ptr
 			if isinstance(obj, _TreeModel):
 				if (<_TreeModel> obj)._raypick_from_context_b(data, items): result = 1; break
 			elif isinstance(obj, _BSPWorld):
 				if (<_BSPWorld>obj)._raypick_from_context_b(data, items, category): result = 1; break
 			else:
 				if (<CoordSyst>  obj)._raypick_b(data, (<CoordSyst> obj)._parent, category): result = 1; break
 		else: result = 0
 		
 		max = data.raypicked.nb
 		data.raypicked.nb = 0
 		while data.raypicked.nb < max:
-			coordsyst = <CoordSyst> chunk_get_ptr(data.raypicked)
+			tmp_ptr = chunk_get_ptr(data.raypicked)
+			coordsyst = <CoordSyst> tmp_ptr
 			coordsyst.__raypick_data = -1
 			
 		return result
 	
 	def get_items(self):
 		"""Return a list of all items inside the raypick context"""
 		cdef Chunk* items
 		cdef _CObj obj
 		cdef int max
+		cdef void* tmp_ptr
 		
 		items = self._items
 		if items.nb == 0:
 			return None
 		result = list()
 		max = items.nb
 		items.nb = 0
 		while items.nb < max:
-			obj = <_CObj> chunk_get_ptr(items)
+			tmp_ptr = chunk_get_ptr(items)
+			obj = <_CObj> tmp_ptr
 			result.append(obj)
 		return result
diff --git a/soya/soya3d/world.pyx b/soya/soya3d/world.pyx
index 4eb94e6..0c70079 100644
--- a/soya/soya3d/world.pyx
+++ b/soya/soya3d/world.pyx
@@ -284,12 +284,13 @@ object hit.
 NORMAL is the normal of the object at the impact point.
 """
 		cdef RaypickData data
 		cdef _World      root
 		cdef CoordSyst   coordsyst
 		cdef float*      d
+		cdef void*       tmp_ptr
 		data = get_raypick_data()
 		origin   ._out(data.root_data)
 		direction._out(&data.root_data[0] + 3)
 		vector_normalize(&data.root_data[0] + 3)
 		data.root_data[6] = distance
 		data.option       = RAYPICK_CULL_FACE * cull_face + RAYPICK_HALF_LINE * half_line
@@ -299,13 +300,14 @@ NORMAL is the normal of the object at the impact point.
 		else:                             d = data.result_coordsyst._raypick_data(data)
 		
 		cdef int max
 		max = data.raypicked.nb
 		data.raypicked.nb = 0
 		while data.raypicked.nb < max:
-			coordsyst = <CoordSyst> chunk_get_ptr(data.raypicked)
+			tmp_ptr = chunk_get_ptr(data.raypicked)
+			coordsyst = <CoordSyst> tmp_ptr
 			coordsyst.__raypick_data = -1
 		return make_raypick_result(d, data.result, data.normal, data.result_coordsyst, p, v)
 	
 	def raypick_b(self, Position origin not None, _Vector direction not None, float distance = -1.0, int half_line = 1, int cull_face = 1, int category = 1):
 		"""World.raypick_b(ORIGIN, DIRECTION, DISTANCE = -1.0, HALF_LINE = 1, CULL_FACE = 1, CATEGORY = 1) -> bool
 
@@ -331,12 +333,13 @@ visible side. If false, both side are take into account.
 CATEGORY is a 32 bit wide bitfield identifying witch categories the methode should take into account (see "solid"  attribute). Only objects witch belong to these categories will be raypicked.
 """
 		cdef RaypickData data
 		cdef _World      root
 		cdef CoordSyst   coordsyst
 		cdef int         result
+		cdef void*       tmp_ptr
 		data = get_raypick_data()
 		origin   ._out(data.root_data)
 		direction._out(&data.root_data[0] + 3)
 		vector_normalize(&data.root_data[0] + 3)
 		data.root_data[6] = distance
 		data.option       = RAYPICK_CULL_FACE * cull_face + RAYPICK_HALF_LINE * half_line
@@ -344,13 +347,14 @@ CATEGORY is a 32 bit wide bitfield identifying witch categories the methode shou
 		result = self._raypick_b(data, None, category)
 		
 		cdef int max
 		max = data.raypicked.nb
 		data.raypicked.nb = 0
 		while data.raypicked.nb < max:
-			coordsyst = <CoordSyst> chunk_get_ptr(data.raypicked)
+			tmp_ptr = chunk_get_ptr(data.raypicked)
+			coordsyst = <CoordSyst> tmp_ptr
 			coordsyst.__raypick_data = -1
 		return result
 	
 	def add(self, CoordSyst child not None):
 		"""add(child)
 
-- 
1.6.5

