Skip to content

Commit b19a5d8

Browse files
committed
Be more consistent about NumPy array types
1 parent 44fb0f8 commit b19a5d8

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/flitter/render/window/models.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ cdef class Model:
123123
logger.debug("Filled holes in non-manifold mesh: {}", self.name)
124124
elif merged:
125125
logger.trace("Merged vertices of non-manifold mesh: {}", self.name)
126-
return manifold3d.Manifold(mesh=manifold3d.Mesh(vert_properties=np.array(trimesh_model.vertices, dtype=np.float32),
126+
return manifold3d.Manifold(mesh=manifold3d.Mesh(vert_properties=np.array(trimesh_model.vertices, dtype='f4'),
127127
tri_verts=np.array(trimesh_model.faces, dtype=np.uint32)))
128128

129129
cpdef void add_dependent(self, Model model):
@@ -205,8 +205,8 @@ cdef class Model:
205205
vertex_uvs = visual.uv
206206
else:
207207
vertex_uvs = np.zeros((len(trimesh_model.vertices), 2))
208-
vertex_data = np.hstack((trimesh_model.vertices, trimesh_model.vertex_normals, vertex_uvs)).astype('f4')
209-
index_data = trimesh_model.faces.astype('i4')
208+
vertex_data = np.hstack((trimesh_model.vertices, trimesh_model.vertex_normals, vertex_uvs)).astype('f4', copy=False)
209+
index_data = trimesh_model.faces.astype('i4', copy=False)
210210
buffers = (glctx.buffer(vertex_data), glctx.buffer(index_data))
211211
logger.trace("Constructed model {} with {} vertices and {} faces", name, len(vertex_data), len(index_data))
212212
objects[name] = buffers
@@ -494,7 +494,7 @@ cdef class Transform(UnaryOperation):
494494
cpdef object build_trimesh(self):
495495
trimesh_model = self.original.get_trimesh()
496496
if trimesh_model is not None:
497-
transform_array = np.array(self.transform_matrix, dtype='float64').reshape((4, 4)).transpose()
497+
transform_array = np.array(self.transform_matrix, dtype='f8').reshape((4, 4)).transpose()
498498
trimesh_model = trimesh_model.copy().apply_transform(transform_array)
499499
if self.original.is_manifold() and not trimesh_model.is_volume:
500500
logger.warning("Result of transform is no longer a volume: {}", self.name)
@@ -504,7 +504,7 @@ cdef class Transform(UnaryOperation):
504504
cpdef object build_manifold(self):
505505
manifold = self.original.get_manifold()
506506
if manifold is not None:
507-
transform_matrix = np.array(self.transform_matrix, dtype='float64').reshape((4, 4)).transpose()[:3].tolist()
507+
transform_matrix = np.array(self.transform_matrix, dtype='f8').reshape((4, 4)).transpose()[:3].tolist()
508508
manifold = manifold.transform(transform_matrix)
509509
return manifold
510510

@@ -527,14 +527,14 @@ cdef class UVRemap(UnaryOperation):
527527
return model
528528

529529
cdef object remap_sphere(self, trimesh_model):
530-
cdef const double[:, :] vertices
530+
cdef const float[:, :] vertices
531531
cdef object vertex_uv_array
532-
cdef double[:, :] vertex_uv
532+
cdef float[:, :] vertex_uv
533533
cdef int64_t i, n
534-
cdef double x, y, z
534+
cdef float x, y, z
535535
n = len(trimesh_model.vertices)
536-
vertices = trimesh_model.vertices.astype('float64')
537-
vertex_uv_array = np.zeros((n, 2), dtype='float64')
536+
vertices = trimesh_model.vertices.astype('f4', copy=False)
537+
vertex_uv_array = np.zeros((n, 2), dtype='f4')
538538
vertex_uv = vertex_uv_array
539539
for i in range(n):
540540
x, y, z = vertices[i][0], vertices[i][1], vertices[i][2]

src/flitter/render/window/target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def array(self):
103103
if self._release_time is not None:
104104
return None
105105
if self._array is None:
106-
self._array = np.ndarray((self.height, self.width, 4), 'float32', self._image_framebuffer.read(components=4, dtype='f4'))
106+
self._array = np.ndarray((self.height, self.width, 4), 'f4', self._image_framebuffer.read(components=4, dtype='f4'))
107107
return self._array
108108

109109
@property

0 commit comments

Comments
 (0)