OSMTrafficSim
OSMTrafficSim copied to clipboard
Any chance for an update to the newer API?
Hey there, Great work on this, it looks awesome. I was wondering if there was any possibility you might be updating this to the newer API? Some nice but also important changes have come, such as there is a hybrid renderer package, [inject] has been deprecated and replaced with a new better way of doing things, etc. I would definitely love to be able to look this over using the current API!
Thanks again for all the time and effort you put into this, it is greatly appreciated! -MH
Thanks for your advice! I will take time upgrade the project.
Thank you, that is very much appreciated! And again, great work. I hope to learn a lot from this. : D
Hi! Already add unity.rendering.hybrid package and start to use RenderMesh. Replace [inject] with ComponentGroup and IJobProcessComponentData. Some document says that ComponentDataArray will be deprecated, but I did not find better alternatives, so I will leave it unchanged until I can find more explanation.
Hey man, awesome news. Can't wait to give it a look over when I get home. I actually just literally came across some information on ComponentDataArray, too. Instead of that, it seems like you need to just use chunk iteration itself, which I believe ComponentDataArray was going under the hood, but also some other not-so-performant things. I saw some info on it here.
https://forum.unity.com/threads/how-to-iterate-through-all-chunks.624616/#post-4183453
Thanks again for taking the time out to go back through things. A few other systems in which I had looked at in the past seemed great, but the creators didn't care to make any adjustments after the initial commit or soon after, so I definitely appreciate it.
Cool! Thanks for your information!
hey maajor - great project - very cool use of ECS. I was reviewing your code and adapted your randomization stuff for my own project, but discovered that the randomizer was showing artifacts for lots of regular entities. I remembered another project I did with randomization for ECS that seems to give better random vals - i mention it because it might be interesting to you -
The trick is to create a single randomizer per thread, and then make sure to not throw it away after each use so its state is preserved:
There is a utility function
`
public static NativeArray<Random> GetRandomizerPerThread()
{
var randomizers = new NativeArray<Random>(JobsUtility.MaxJobThreadCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
for (int i = 0; i < JobsUtility.MaxJobThreadCount; i++)
{
randomizers[i] = new Random((uint)UnityEngine.Random.Range(int.MinValue, int.MaxValue));
}
return randomizers;
}
`
This will be used by a member on your system:
private NativeArray<Random> _rngs; ... _rngs = Utility.GetRandomizerPerThread();
Pass this into your job struct, then, use this handy attribute to get the current thread id:
`
[NativeSetThreadIndex]
int threadId;
...
var threadRandom = randomizers[threadId];
` just remember to reassign to the nativearray:
randomizers[threadId] = threadRandom; // preserve state
Maybe this is useful to you - anyway, thanks for your great example
Hi ajaxlex! Thanks for your code, I'll take time investigate it!
Hi, I found ECS APIs in 2019.1 are a lot different from 2018.3, I have upgraded to new version. and thanks @ajaxlex your approach is elegant, I have adopted your code in this project. Thank you very much.
Hi, I found ECS APIs in 2019.1 are a lot different from 2018.3, I have upgraded to new version. and thanks @ajaxlex your approach is elegant, I have adopted your code in this project. Thank you very much.
i was trying to upgrade this to 2019.3 but was failing. i have learned a lot from this project and thank you for that but was wondering if you were going to upgrade it because i have failed
Hi @tredpro I have upgrade it to 2019.3 as its official version is released, please have a look at if it works now.
Add some upgrading note from 2019.1 to 2019.3
- OnCreateManager and OnDestroyManager is renamed to OnCreate and OnDestroy
- NativeMultiHashmap.Concurrent is renamed to NativeMultiHashmap.ParallelWritter
- IShareComponent need to extend IEquatable interface
- Use GetEntityQuery instead of EntityManager.CreateEntityQuery to create entity query