So basically I prototyped and developed a math code (for vechicle simulations) in C# and it works perfectly. Now when I port the code to C++
so that I could acces it in a C# environment through a DLL I get some junky behaviour.
For example when I run my physics program, the cars driving wheels start accelerating with no reason and it seems like it's mostly caused by rolling resistance, wich by the way works great in C# environment.
This rolling resistance relys on a value that is received from C# environment (from C# float to c++ float)
Another problem is caused by slip ratio and slip angle, the wheels start shaking at low speeds, wich again does not happen in the C# version.
Slip calcs both rely also on values received from C# environment.
So might the float conversion from C# to C++ be the case?
This stands in my exportFunctions.cpp:
EXPORT_API void Dll_Wheel_SetVelocity(CarWheel* wheel,float lonRoadVelocity,float latRoadVelocity){ wheel->SetVelocity(lonRoadVelocity,latRoadVelocity);}
These 2 velocityes are used for the calculations that cause those bug's.
And no I cant share the code, but I can give closer information on how it looks like.
Thanks!
Edit:
Strange part is that this acceleration issue only occurs in Debug build. If I build the dll as a release, then this issue is vanished, but small friction error still remains. Actually it's only causing the smoke to come out of the tires and tireq squal sound to emmit, but physically it seems to be ok.
But I still suspect that there is some sort of a error somewhere, because debug & release should work identically shouldnt they?