Can std::complex be used in C++ programming?
I'm building a shooting mechanic for my game in C++. I have included functionality for aiming to moving targets and this comes down to an grade 4 equation:
The only reliable and exact solution to solving this equation seems to be using complex numbers. My implementation is using
Are there any compatibility / deployability issues with
Note: I intend to deploy on Windows, Android and maybe others. Definitely not on MacOS or iOS.
asked Jan 30 '18 at 07:37 PM in C++ Programming
I should be fine as long as it not using it with UPROPERTY() or UFUNCTION() or other things like that. you need to understand that not using those means that engine don't see them, but on other hand engine don't support that type so it really does not matter.
There 2 major reason why they using C++ std library as well as other types from elsewhere is not recommended:
-UE4 has set of own core implementations, some are just wrappers of std, platform, system, third party libraries and other APIs. Point of it is to make UE4 code and much as portable to supported platform as possible without you UE4 deweloper to even think about it. By using something else UE4 don't give you guaranty that it will work (or atleast inform that it does not work on specific platfrom) with any target platform case. Sadly UE4 indeed don't have any implementation of complex numbers, whole there is alternatives for std::vector and std::stack.
-UE4 code expects you to use only UE4 APIs, which means a) reflection system don't support them (mentioned U macros above) b) using it with UE4 APIs risks crashes as UE4 don't know what to do with them, UE4 also might be not prepared for what specific library doing as it was not design to cooperate with it. Other potantion compatibiliuty issues is advance UE4 memory manipulation might have potention issue dilling with object that use those types, epcially if you implement to asset type. But as long as you using external types and function with isolation from the engine it should be fine.
Best practice here is to do what UE4 is doing, make your own implementation of complex numbers in UE4 or try creating a wrapper from UE4 APIs, simply create FComplex struct, try to make std::complex to be operatable C++ primitive type that UE4 support, if oyu up to iyt you can even make custom UI for your property type and bluepritn nodes so you can it in Blueprints too. And as point 1 saying UE4 and Epic won't guaranty you that things will work out and work on every platform (you will need to implement specific platfrom support if needed on your own), you on your own in this journey.
Also look up how UE4 deals with third party libraries or find plugins that do so, those are best examples you can find to how to interact with things outside of UE4 APIs and how to make them work with UE4.
Follow this question
Once you sign in you will be able to subscribe for any updates here