3
$\begingroup$

I'm writing an add-on that imports vertex locations and builds a BMesh by placing vertices at those locations. I'm running into precision issues, since the imported data can be large floating point values with several digits after the decimal point.

The image below shows the values imported and the locations of the vertices as stored in the BMesh:

Vertex Locations As Imported vs. BMesh Locations

So I know the problem (floating point precision) but I need to know how best to handle it.

My add-on currently creates the mesh with the vertices stored using the values imported from the data, then shifts all the verts to place the mesh close to the center of the scene. It also, optionally, scales the mesh down if it's particularly enormous.

But it appears that I can't do it this way, as I can't store the verts with the required precision.

How can I build a mesh that represents the vertices with the required precision?

$\endgroup$
1
  • $\begingroup$ Have you tried just rounding it? eg. round(800.1234741210938, 6) $\endgroup$
    – Rick Riggs
    Mar 3, 2017 at 20:53

2 Answers 2

1
$\begingroup$

The problem is caused by the fact that vertex locations are stored using 32-bit float numbers. This means that there are only 6 significant figures stored, so accuracy takes a dive with large (or very small) coordinate values.

Originally, I had been storing the actual locations of the vertices in the mesh and then moving them all toward the origin of the Blender scene in one go. I had to re-work things so that the localization (bringing closer to xyz=0,0,0) has to happen before the vertex locations are stored in the mesh.

$\endgroup$
0
$\begingroup$

Have you tried the BlenderGIS plugin? It handles this pretty well with geospatial data.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .