Unity plugin progress?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 26, 2017 4:30 pm

ah, I found out why is so slow.
solver iteration count is set to 24, if you slide it to 1 then It takes less that 6 ms at worse in my machine.
we do not really need that many number of iterations, I will change that to be from 1 to 4 that's enough for newton. We also update at 120 fps, so we take twice as many updates.
if we set the update rate to 60, then is under 3.1 ms at its worse.
Please verify that this is the case for you as well.

On the crash, I saw it again, I need to figure out what is wrong there.

[edit]
oh solve iteration was set from 1 to 10, the problem was that it was serialized to 24 before modified, I I believe that even 1 to 10 is unnecessarily too many, it can be from 1 to 4 should be perfectly fine.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 26, 2017 4:45 pm

I do not suppose unity support threading, if it did we can cut the loop by probably one third,

in the profile is you click the deep profiler tab, you will see that the newton update take roughfully the same amoung of time than the two calls to update thee scene.

but all that does is iterate of the newton bodies which clod be don in parallel.
if you check carefully the time line unity ha about 7 worker thread that are idling. an only one is don the newton update.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Sweenie » Sun Feb 26, 2017 5:42 pm

ah, I found out why is so slow.
solver iteration count is set to 24, if you slide it to 1 the I stake less that 6 ms at worse in my machine.


Ouch, never thought to check that.
Changed it to 1 iteration and 60hz and now I get more sensible numbers as well. :D
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 26, 2017 7:09 pm

Ok I now added thread synchronization so that creation and destruction of newton objects at run time is never call in the middle of an asynchronous update,
that should fix the random crash provide I covered all ends.

now to complete scene collision
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 26, 2017 7:14 pm

now that I added Synchronization I found the place that caused the crash, but I still do no know why.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby AmFreak » Sun Feb 26, 2017 7:56 pm

Hi,
would this plugin give me deterministic physics (on pc) e.g. for a lockstep mp game?
AmFreak
 
Posts: 1
Joined: Sun Feb 26, 2017 7:52 pm

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 26, 2017 8:01 pm

Ok now I think I fixed the synchronization with collision shapes creations.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Mon Feb 27, 2017 11:42 am

AmFreak wrote:Hi,
would this plugin give me deterministic physics (on pc) e.g. for a lockstep mp game?

Oh no I do not guarantee, this plug in will be deterministic,
for once multithreading code throw deterministic calculations out of the window.
plus Unity Update, FixUpdate, Garbage collection, and many more other things that goes on in c# is no quarantine to predictable.
you could try setting one thread, but I doubt very much that required can be met.


Sweenie, yes said before that the compound collision was acting weird, and you were right.
I found out that the collision shapes of a compound are all at the origin of the body.
the look correct in eh debug display because the debut display use the gameobject matrix top display the shape.
Yesterday I could not figure out why was wrong with scene shape, and then I remember you mentioned that. this is how they look when I serialized it, I am fix that now.
badcompound.png
badcompound.png (39.48 KiB) Viewed 5369 times


BTW I added a one time serialization option so that we can debug problematic scenes.

Later, not no right now, I will see if I can add an option to do xml and binary seriations,
so that for that point on we no longer we have to write complicated demos. we made then in Unity and expert then to other platforms. this is useful for debugging
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Mon Feb 27, 2017 12:56 pm

ok now it looks like this
betterCompound.png
betterCompound.png (46.75 KiB) Viewed 5369 times

but I also nee to fix the debug display that still show on offset, an dI gues that will be all we need for now for collision shapes.

Next step is adding ray cast and convex cast,
and then finally move to Vehicles. :shock: :o
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Mon Feb 27, 2017 4:00 pm

ok compound collision offset matrices should be fine all around now.

I removed cpu any, win32 and x86 configurations.
I was having problems with my visual studio at home and at work each I did something to a project is keep getting all confused nd given me compiler error.

It has been 25 year sinse visual studio came out and they still have figure out how to match different confutations. each time a configuration has a different name geoidal studio try to second guess what the person did, and always get it wrong. and what has that whit the cup any for c#, x86 for the swig dll and win32 for newtondll.
this did not apply to x64 which all have the same name.

I we will ever do a x86 version, although I do not see why, we can simple make a copy of the x64.
anyway I will no goin to test the scene collision and see f we can add terrain collidable brush's
and I think that will cover all solid collision shapes.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Mon Feb 27, 2017 6:40 pm

Ok I got stocked on getting the position of a tree instance

I am adapting this function
private void TraverseColliders(GameObject gameObject, List<ColliderShapePair> colliderList, GameObject rootObject, NewtonBody body)

you iterate one terrain and collect every instance with a collider, but no matter what I do I get the location of the prefab no the location of the instance.
this tree lines shows the same location for three trees that are in different locations.
Code: Select all
      TerrainData data = terrain.terrainData;
                   
                    int treesCount = data.treeInstanceCount;
                    TreeInstance[] treeInstanceArray = data.treeInstances;

                    Debug.Log("xxx count " + treesCount);
                    Debug.Log("xxx0 " + treeInstanceArray[0].position);
                    Debug.Log("xxx1 " + treeInstanceArray[1].position);
                    Debug.Log("xxx2 " + treeInstanceArray[2].position);


maybe you have better lock that I. It is all check in. the scene is demo_14_sceneCollision
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Mon Feb 27, 2017 8:11 pm

ha I think I figured out the location is normalize between zero and one. the all looked the same becuze the print function truncate float values. hope this is the last issue on that
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Mon Feb 27, 2017 9:35 pm

ok we now have terrain with colliding trees working.
Unity took a big hit in the rendering, I when for less that few micro seconds to lithe over 2.0 ms.
the physics did not feel any effect for populating a word with several hundreds trees.

that's the beauty of the scene collision, if we populate the word using static object for each tree, the performance would suffer.
we do have a bridaphse algorithm that capitalize on static bodies but is not where as efficient as scene collision.

we this we can now make any environment no mater how complex it is and the performance will not cost any more than updating one body.
I still have to add the orientation but that is very easy.

please check it and let me know what you find.
I am not sure if we should move to character controller of vehicle first even before ray casting.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Sweenie » Tue Feb 28, 2017 3:21 am

Just tried the scene with the vehicle and trees and stuff. Really nice.
It makes such a difference when you get a sense of the scale.

I was thinking a bit about the scene collision.

Would it be possible to handle the scene collision the way Unity does?

If a gameobject contains a collider but not a body component it automatically becomes part of the scene collision, unless the collider component is a child of gameobject with a body component.

That way you wouldn't need to add the terrain and houses into a gameobject with a bodycomponent flagged as scene. Just add a collider and the object will be a static scene collider.

So, in short, the scene collider would traverse the scene and all collider components without a parent body will become part of the scene collider.

Also if adding a static scene collider at runtime we need a way to update the scene collider.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unity plugin progress?

Postby Julio Jerez » Tue Feb 28, 2017 10:40 am

yes that would be possible, but since we can have more that one world, how do we deal with that?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests

cron