Undesired truncated egg precision with EggData

Something I noticed when reading+writing eggs through EggData is that the precision of decimals is often greatly trunicated. I noticed that this is the case even before exporting the EggData to disk (via write()) This also seems to happen regardless if I modify the egg-precision config value.

Is there an intentional reason as to why these values become truncated?

Here’s some sample code that replicates my situation:

from panda3d.egg import *
import os
from panda3d.core import Filename

target_egg_file = Filename.fromOsSpecific(os.path.join(os.getcwd(), "test_model.egg"))
output_egg_file = Filename.fromOsSpecific(os.path.join(os.getcwd(), "test_model_out.egg"))

egg_data = EggData()

with open(output_egg_file, "w") as egg_file:

test_model.egg (246.4 KB)

Hi loonaticx,

I’ve had a look into your issue and have found a way to get what you’re after.

Instead of writing out the string representation of the EggData str(egg_data), if you use EggData::write_egg/writeEgg() then it seems to respect the egg-precision.

The following without any egg-precision gives almost the same file output as the input.

egg_data = EggData()

There’s a few lines where the last digit/s are ever so slightly different, like the following:

    <Normal> { 0.0253209799905412 -0.99963346311501 0.00958057373076304 }

becomes (Z component last digit 4 becomes 5)

    <Normal> { 0.0253209799905412 -0.99963346311501 0.00958057373076305 }

I had a quick look and wasn’t able to find a way to get your way to work.
I suspect it’s the str(egg_data) that’s the issue and not the open()/egg_file.write().

Hope that’s helpful :slight_smile:



Works for me!! Thank you very much :slight_smile:

1 Like