I have some questions that have come up while I've been porting Tobias's fixed point code.
1. Why does the main code use sqrtf(x) instead of using the c++ sqrt(x). The nice thing about sqrt is that it is associated with the type of data, while sqrtf forces conversion to float. Same with atanf2.
2. Why is there a b2Abs? wouldn't the c++ abs(x) work just fine?
3. There are four places in the code where 100.0 * EPSILON is computed and used as a threshold. Since EPSILON cannot be such a small value in fixed point, I found that at least one of these thresholds was way too high and circles were going through polygon. I removed the 100.0 and things worked (this was in b2Distance, the line with pointCount==3). Any general advise about how I might set these would be nice.
4. In b2Island.cpp, in solve, the angularVelocity is squared and then compared to a threshold. Squaring the angular velocity causes overflow so I had to change this code, but after looking at the code I don't understand why this squared value is computed at all. I changed the line to:
b->m_angularVelocity = b2Clamp(b->m_angularVelocity,
-b2_maxAngularVelocity, b2_maxAngularVelocity);
and things work and seem clearer. What the squaring some sort of optimization?
4. It would be nice if this or some similar fixed point implementation could be added to the SVN code (right now I have it working against version 80). I am willing to work to make this happen. The code I have now changes float32 to be Fixed so it has very little impact on the existing code base and can be compiled with the option -DTARGET_FLOAT32_IS_FIXED to generate fixed code instead of the normal float code.
Robert
1. Why does the main code use sqrtf(x) instead of using the c++ sqrt(x). The nice thing about sqrt is that it is associated with the type of data, while sqrtf forces conversion to float. Same with atanf2.
2. Why is there a b2Abs? wouldn't the c++ abs(x) work just fine?
3. There are four places in the code where 100.0 * EPSILON is computed and used as a threshold. Since EPSILON cannot be such a small value in fixed point, I found that at least one of these thresholds was way too high and circles were going through polygon. I removed the 100.0 and things worked (this was in b2Distance, the line with pointCount==3). Any general advise about how I might set these would be nice.
4. In b2Island.cpp, in solve, the angularVelocity is squared and then compared to a threshold. Squaring the angular velocity causes overflow so I had to change this code, but after looking at the code I don't understand why this squared value is computed at all. I changed the line to:
b->m_angularVelocity = b2Clamp(b->m_angularVelocity,
-b2_maxAngularVelocity, b2_maxAngularVelocity);
and things work and seem clearer. What the squaring some sort of optimization?
4. It would be nice if this or some similar fixed point implementation could be added to the SVN code (right now I have it working against version 80). I am willing to work to make this happen. The code I have now changes float32 to be Fixed so it has very little impact on the existing code base and can be compiled with the option -DTARGET_FLOAT32_IS_FIXED to generate fixed code instead of the normal float code.
Robert