InteractiveComputerGraphics / PositionBasedDynamics

PositionBasedDynamics is a library for the physically-based simulation of rigid bodies, deformable solids and fluids.
MIT License
1.9k stars 358 forks source link

Alignment issues on Windows #41

Closed FantasyVR closed 7 years ago

FantasyVR commented 7 years ago

When I run CosseratRodsDemo on Windows 10 with Visual Studion 2015, it crashed sometimes. I figure out that it has to do with alignment.

Acoording to this page, if one uses STL container with Eigen, she/he should use an aligned allocator. So the solution is that all of the std::vector<Vector3r> and std::vector<Quaternionr>in ParticleData.h should be replaced by std::vector<Vector3r, Eigen::allocator<Vector3r> and std::vector<Quaternionr, Eigen::allocator<Quaternionr> respectively.

Acoording to this issue, if a class has Eigen members, you should put a EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro in a public part of your class. Thus, we should put a EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro in class BendTwistConstraint, because it has a Quaternionr m_restDarbouxVector.

janbender commented 7 years ago

I know this issue. Since we cannot test our library on Windows and Linux using 32bit and 64bit builds, we put the note "Please use a 64-bit target on a 64-bit operating system." in the build instructions in the readme file.

Is there any reason why you want to perform a 32bit build on a 64bit system?

FantasyVR commented 7 years ago

I just haven't noticed that note. However, using sligned allocator and EIGEN_MAKE_ALIGNED_OPERATOR_NEW can solve the alignment problems of 32bit build. So I thought it might be helpful for them who confront with this kind of problems.

janbender commented 7 years ago

In fact we once had this support of 32bit builds on 64bit systems. However, no one had the time to maintain it and after a while it didn't work anymore. Then we decided that anyway it is not necessary to make a 32bit build on a 64bit system and skipped the support.