Skip to content

Commit

Permalink
address single precision by adding a setting #1137
Browse files Browse the repository at this point in the history
  • Loading branch information
marcomusy committed Jun 17, 2024
1 parent 36eda43 commit 73d02a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion vedo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ class Settings:
enable_default_mouse_callbacks = True
enable_default_keyboard_callbacks = True
# Force single precsion of points coordinates.
# Useful for very large point clouds and meshes. Default is True.
force_single_precision_points = True
# Progress bar delay before showing up [sec]
self.progressbar_delay = 0.5
progressbar_delay = 0.5
# If False, when multiple renderers are present, render only once at the end
immediate_rendering = True
Expand Down Expand Up @@ -180,6 +184,7 @@ class Settings:
"renderer_frame_alpha",
"renderer_frame_width",
"renderer_frame_padding",
"force_single_precision_points",
"point_smoothing",
"line_smoothing",
"polygon_smoothing",
Expand Down Expand Up @@ -245,6 +250,8 @@ def __init__(self) -> None:
self.palette = 0
self.remember_last_figure_format = False

self.force_single_precision_points = True

self.cache_directory = ".cache" # "/vedo" is added automatically

self.screenshot_transparent_background = False
Expand Down
5 changes: 4 additions & 1 deletion vedo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,10 @@ def buildPolyData(vertices, faces=None, lines=None, strips=None, index_offset=0)

vertices = make3d(vertices)
source_points = vtki.vtkPoints()
source_points.SetData(numpy2vtk(vertices, dtype=np.float32))
if vedo.settings.force_single_precision_points:
source_points.SetData(numpy2vtk(vertices, dtype=np.float32))
else:
source_points.SetData(numpy2vtk(vertices))
poly.SetPoints(source_points)

if lines is not None:
Expand Down

0 comments on commit 73d02a3

Please sign in to comment.