MCPcopy Create free account
hub / github.com/vispy/vispy / _update_data

Method _update_data

vispy/visuals/mesh.py:312–354  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

310 return func
311
312 def _update_data(self):
313 md = self.mesh_data
314
315 v = md.get_vertices(indexed='faces')
316 if v is None:
317 return False
318 if v.shape[-1] == 2:
319 v = np.concatenate((v, np.zeros((v.shape[:-1] + (1,)))), -1)
320 self._vertices.set_data(v, convert=True)
321 if md.has_vertex_color():
322 colors = md.get_vertex_colors(indexed='faces')
323 colors = colors.astype(np.float32)
324 elif md.has_face_color():
325 colors = md.get_face_colors(indexed='faces')
326 colors = colors.astype(np.float32)
327 elif md.has_vertex_value():
328 colors = md.get_vertex_values(indexed='faces')
329 colors = colors.ravel()[:, np.newaxis]
330 colors = colors.astype(np.float32)
331 else:
332 colors = self._color.rgba
333
334 self.shared_program.vert['position'] = self._vertices
335
336 self.shared_program['texture2D_LUT'] = self._cmap.texture_lut()
337
338 # Position input handling
339 ensure_vec4 = self._ensure_vec4_func(v.shape[-1])
340 self.shared_program.vert['to_vec4'] = ensure_vec4
341
342 # Set the base color.
343 #
344 # The base color is mixed further by the material filters for texture
345 # or shading effects.
346 self.shared_program.vert['color_transform'] = self._build_color_transform(colors)
347 if colors.ndim == 1:
348 self.shared_program.vert['base_color'] = colors
349 else:
350 self.shared_program.vert['base_color'] = VertexBuffer(colors)
351
352 self._data_changed = False
353
354 self.events.data_updated()
355
356 def _prepare_draw(self, view):
357 if self._data_changed:

Callers 1

_prepare_drawMethod · 0.95

Calls 12

_ensure_vec4_funcMethod · 0.95
VertexBufferClass · 0.85
get_verticesMethod · 0.80
has_vertex_colorMethod · 0.80
get_vertex_colorsMethod · 0.80
has_face_colorMethod · 0.80
get_face_colorsMethod · 0.80
has_vertex_valueMethod · 0.80
get_vertex_valuesMethod · 0.80
set_dataMethod · 0.45
texture_lutMethod · 0.45

Tested by

no test coverage detected