Permalink
Browse files

some tweaks to get pypy working

  • Loading branch information...
1 parent 3908148 commit ce5febc6693115872c7e4653dfea503e029fa0d5 @paddywwoof paddywwoof committed Dec 3, 2013
Showing with 10 additions and 7 deletions.
  1. +3 −3 pi3d/Buffer.py
  2. +4 −4 pi3d/Camera.py
  3. +3 −0 pi3d/Shape.py
View
@@ -98,15 +98,15 @@ def __init__(self, shape, pts, texcoords, faces, normals=None, smooth=True):
if len(texcoords) != n_verts:
if len(normals) != n_verts:
self.N_BYTES = 12 # only use pts
- self.array_buffer = c_floats(pts.reshape(-1))
+ self.array_buffer = c_floats(pts.reshape(-1).tolist())
else:
self.N_BYTES = 24 # use pts and normals
self.array_buffer = c_floats(np.concatenate((pts, normals),
- axis=1).reshape(-1))
+ axis=1).reshape(-1).tolist())
else:
self.N_BYTES = 32 # use all three NB doesn't check that normals are there
self.array_buffer = c_floats(np.concatenate((pts, normals, texcoords),
- axis=1).reshape(-1))
+ axis=1).reshape(-1).tolist())
self.ntris = len(faces)
self.element_array_buffer = c_shorts(faces.reshape(-1))
View
@@ -47,7 +47,7 @@ def __init__(self, at=(0, 0, 0), eye=(0, 0, -0.1), lens=None,
self.projection = _OrthographicMatrix(scale=scale)
self.model_view = dot(self.view, self.projection)
# Apply transform/rotation first, then shift into perspective space.
- self.mtrx = copy(self.model_view)
+ self.mtrx = array(self.model_view, copy=True)
# self.L_reflect = _LookAtMatrix(at,eye,[0,1,0],reflect=True)
self.rtn = [0.0, 0.0, 0.0]
@@ -204,7 +204,7 @@ def _LookAtMatrix(at, eye, up=[0, 1, 0], reflect=False):
zaxis.append(-vec_dot(zaxis, eye))
z = [0, 0, 0, 1.0]
return array([[xaxis[a], yaxis[a], zaxis[a], z[a]] for a in range(4)],
- dtype=ctypes.c_float)
+ dtype=float)
def _ProjectionMatrix(near, far, fov, aspectRatio):
"""Set up perspective projection matrix
@@ -228,7 +228,7 @@ def _ProjectionMatrix(near, far, fov, aspectRatio):
M[2][2] = (far + near) / (far - near)
M[2][3] = 1
M[3][2] = -(2 * far * near)/(far - near)
- return array(M, dtype=ctypes.c_float)
+ return array(M, dtype=float)
def _OrthographicMatrix(scale=1.0):
"""Set up orthographic projection matrix
@@ -246,5 +246,5 @@ def _OrthographicMatrix(scale=1.0):
M[2][2] = 2.0 / 10000.0
M[3][2] = -1
M[3][3] = 1
- return array(M, dtype=ctypes.c_float)
+ return array(M, dtype=float)
View
@@ -9,6 +9,7 @@
from pi3d.Buffer import Buffer
from pi3d.Light import Light
from pi3d.util import Utility
+from pi3d.util.Ctypes import c_floats
from pi3d.util.Loadable import Loadable
@@ -146,7 +147,9 @@ def draw(self, shader=None, txtrs=None, ntl=None, shny=None, camera=None):
dot(self.rox,
dot(self.roz, self.tr1)))))
self.M[0:16] = self.MRaw.ravel()
+ #self.M[0:16] = c_floats(self.MRaw.reshape(-1).tolist()) #pypy version
self.M[16:32] = dot(self.MRaw, camera.mtrx).ravel()
+ #self.M[16:32] = c_floats(dot(self.MRaw, camera.mtrx).reshape(-1).tolist()) #pypy
self.MFlg = False
elif camera.was_moved:

0 comments on commit ce5febc

Please sign in to comment.