Skip to content

Commit e273ff5

Browse files
committed
fix geometry buffer not being updated in each frame
1 parent 7c3f610 commit e273ff5

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

ngsolve_webgpu/geometry.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def set_colors(self, colors):
7474
self.device.queue.writeBuffer(self._buffers["colors"], 0, self.colors.tobytes())
7575

7676
def update(self, options):
77+
if self._buffers:
78+
return
7779
vis_data = self.vis_data
7880
self.bounding_box = (vis_data["min"], vis_data["max"])
7981
verts = vis_data["vertices"]
@@ -160,6 +162,8 @@ def set_colors(self, colors):
160162
self.device.queue.writeBuffer(self._buffers["colors"], 0, self.colors.tobytes())
161163

162164
def update(self, options):
165+
if self._buffers:
166+
return
163167
vis_data = self.vis_data
164168
verts = vis_data["edges"]
165169
self.colors = vis_data["edge_colors"]
@@ -219,6 +223,8 @@ def get_shader_code(self):
219223
return read_shader_file("ngsolve/geo_vertex.wgsl")
220224

221225
def update(self, options):
226+
if self._buffers:
227+
return
222228
verts = set(self.geo.shape.vertices)
223229
self.colors = np.array(
224230
[v.col if v.col is not None else [0.3, 0.3, 0.3, 1.0] for v in verts],
@@ -257,13 +263,15 @@ def __init__(self, geo, label="Geometry", clipping=None, symmetry=None):
257263
self.edges.clipping = self.clipping
258264
self.vertices.clipping = self.clipping
259265
self.vertices.active = False
266+
self._vis_data = None
260267
super().__init__([self.vertices, self.edges, self.faces])
261268

262269
def update(self, options: RenderOptions):
263-
vis_data = self.geo._visualizationData()
270+
if self._vis_data is None:
271+
self._vis_data = self.geo._visualizationData()
264272
self.clipping.update(options)
265273
for ro in self.render_objects:
266-
ro.vis_data = vis_data
274+
ro.vis_data = self._vis_data
267275
ro.update(options)
268276

269277
self.canvas = options.canvas

0 commit comments

Comments
 (0)