Closed attilaz closed 4 months ago
That's a good find!
Unfortunately, the suggested solution won't work as e.g. Vec3 is is_trivial and is_trivially_copyable but it requires calling the custom Read(Vec3 &) function to avoid writing garbage for the unused W component.
Let me cook something up.
Should be fixed now, thanks for reporting this!
We have a 8192x8192 heightfield. RestoreBinaryState takes 1231ms on a Galaxy A51 phone.
Most of the time spent with reading vector elements (mRangeBlocks, mHeightSamples, mActiveEdges)
https://github.com/jrouwe/JoltPhysics/blob/40dc67068b853761baf262cc47e3cf567e2118e9/Jolt/Core/StreamIn.h#L44
I have modified the StreamIn vector reader to read the whole vector data with one call. This takes 114ms on the same phone.
I am not sure about is_trivial_v maybe it should be is_trivially_copyable?
Our deserialization code looks like this. The ReadBytes is a virtual function which gets called with small sizes.