I am a roughly “junior level” Computer Science and Mathematics (combined) student at University of Montana.
Although I do not know if my University’s CS department has any current licenses for Unreal 4 I have put in a request for one to the school’s dean and I think I should be able to get access to one fairly soon.
The reason I am writing this is that I see potential for Unreal 4 to serve as more than just a game engine but also as an engineering/physics simulator that can allow one program to do quicker but lower graphics internal simulation as well as pre-recorded, high graphical detail, simulations for presentation purposes. I see Unreal as having potential to allow me and potentially others to accomplish both tasks at once with the same software at a price I can afford.
Since I am assuming my school’s CS department will be able to get me access to Unreal 4 sooner or later I am curious as to how I would best implement such a physics simulator.
I am not referring to the graphics end of it, but the physics calculations. I have some concerns after giving some of the documentation a quick look that it may be difficult to plug in a multi-threaded physics engine into the game engine given how Unreal 4 seems to have its own built-in preference on how to allocate threads and memory management.
The physics simulation I have in mind includes an interesting take on macroscopic and microscopic (in scale) particle systems and so I am thinking it would be best that I have as much control over that aspect of the program as possible.
Would it be a good idea for me to do this inside of the Unreal 4 engine’s framework or would something like an Unreal 4 plugin grant me the freedom to do such a simulation in either pre-recorded simulations (played back from a file containing position data) or real time simulations?
My hardware constraints are within the 8-core CPU and 1-2 GPU range for the project.
Depending on the actual task, there are likely a number of ways to approach it in Unreal Engine 4. More info on what you’re trying to accomplish is always better when looking for the best way to solve the problem - are you suggesting that you’re wanting to replace the UE4 physics engine with a custom engine of your own?
Yes I need to have complete control. I want to use Unreal to render the physics data for either quick’n’dirty simulations or high detail presentations and be able to use the same program to accomplish both to save time/money. For this to work I would need either complete control of the built-in physics engine (including how it handles memory and threads) or my own custom physics engine that had its own memory allocation that Unreal wouldn’t be able to mess with.
For me that means I would need Unreal 4 to grant me access to my own separate stack and heap from the initial program allocation. Otherwise I would be forced to create a second executable with the risk that Unreal and the physics engine would be getting in each other’s way. It can still work though.
I’m not an expert on the subject but if you need to actually replace the whole physics system, I would just say that uhh… it is not exactly an easy task
If your simulation is for demonstration purposes and you do not require some “scientific”-level of accuracy and calculations in real time then there are always ways you could fake & approximate things but of course it depends on what you are trying to accomplish.
You mentioned pre-recorded simulations… from a file containing position data… that sounds like a better idea to me instead of trying to simulate everything in real time but again it all depends on what the goal is.
It would be interesting if you gave us more specific information
You don’t have to replace the ue4 physics system, just ignore it (make all your actors unaffected by the ue physics) and use physics bodies from your own physics engine, keep references in your custom actora and update transforms of the actors based on them. It’s like in the old days when you were playing with a graphics library directly and integrated a separate physics engine. Use a fixed time step update function, ue4’s onTick function won’t cut it, to update the simulation for the most realistic effect. About multithreading, i’m not familiar with how ue4 does it, but if it’s not easy to use and if you have a fixed system (desktop) you’re going to run your simulations on, you might want to test if c++11 threads are available or integrate a third party threading library (boost, posix,…) to run your physics engine only.