NewtonWorldForEachBodyInAABBDo issue

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

NewtonWorldForEachBodyInAABBDo issue

Postby Sweenie » Wed Dec 09, 2015 3:37 am

Hi.

Is there some known bug with NewtonWorldForEachBodyInAABBDo ?

Last night I implemented a new debug renderer and for some scenes it returned the wrong number of bodies.

For example I have a scene with 20 bodies, and the first few seconds of the simulation NewtonWorldForEachBodyInAABBDo(with an AABB extent of -100 to 100) returns 20 bodies but after a while it only returns 13 bodies and after all bodies comes to rest it returns 14 bodies.
I tried increasing the extents to 1000 but the same result.

[EDIT]
I will fix a serialized scene but right now my cloud drive service is down so I can't reach my code. :(
Sweenie
 
Posts: 490
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Julio Jerez » Wed Dec 09, 2015 11:43 am

I has not tested, after made work with the 3.14 broad phase
try this,
1- if the object are going to sleep move one and see if it rejecting sleep objects,
2- there are two prophase modes, the persisted and the dynamics

the dynamics is like the previous ones, the persisted is the default now,
and this one try to group objects by proximity.
those test see will show is the bug is in both or just one of them.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Sweenie » Wed Dec 09, 2015 1:19 pm

Hi.

Regarding test 1, the bodies are definitely not sleeping.

Regarding test 2, it happens in both modes, but on different bodies.

NewtonSelectBroadphaseAlgorithm(world, 0);


NewtonSelectBroadphaseAlgorithm(world, 1);
Sweenie
 
Posts: 490
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Julio Jerez » Wed Dec 09, 2015 2:47 pm

ha ok so is general, that mean I will take a look.
the scene is so simple that this should be testable in the sand box demos.
I refactored the function but I never test it, because is so trivial that I thought it will just work.
I will check tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Sweenie » Wed Dec 09, 2015 4:26 pm

Here is the testscene I used in the videos.

http://www.svenberra.net/testworld.bin

By the way, it seems when serializing the world it doesn't account for scaled collisions.
My scene had alot of scaled collisions but when I deserialized the scene in the sandbox all collisions were unscaled.

I thought maybe this could be related to the bug so I removed all scaling and just adjusted the box sizes and sphere radius instead but the bug still happens.
Sweenie
 
Posts: 490
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Julio Jerez » Mon Dec 14, 2015 3:50 pm

Hey sweenie, do you have a paid version Unity?
How can you add engine plugins? My impression was that only people who get a license get to add C++ plugins.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Sweenie » Mon Dec 14, 2015 5:44 pm

Since Unity 5 you can create native c++ plugins for the personal edition as well.

You actually could use external apis before version 5.0 though you couldn't write true plugins in the free version since the callbacks into the plugin interface was disabled. But you could do pinvokes from Mono as usual.
Sweenie
 
Posts: 490
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Sweenie » Mon Dec 14, 2015 6:16 pm

By the way, checkout the Newton Vehicle running in Unity :D



Sorry about the low video quality but my new apartment got a crappy internet connection so I had to keep the video quality low or it would take all night to upload to youtube. :roll:
Sweenie
 
Posts: 490
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Julio Jerez » Mon Dec 14, 2015 8:36 pm

wow!! the is really cool. you see how natural is the integration of the wheels with the rest of the environment?
That was my motivation for moving away from raycast car BS, in the long run it become a bigger problem.
I download the Unity a while back, and I want to get the license, but then I learned a professional license was $2000 then I saw $1500, and then the have like 75/month license rent if you want the ability of plug in. The hoviest license did not allowed for C++ plugin in
https://store.unity3d.com/products/pricing
has that changed?, when I type for the unity 5, I do not see anything about cost.

what I want to do is to put time on of content, a way to have a editor that people can create content instead of hard code demos that only very few people understand.
I downloaded Unity, but after few days of looking at it I did not see know to integrate a new library.
how much do you pay for a unity license?
Maybe we can work together in polishing what you already has.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Julio Jerez » Mon Dec 14, 2015 9:14 pm

for example would I be able to assets that interface this guy is taking about
https://www.youtube.com/watch?v=ZtcAOQv9GWs

I will try to download load the SDK see if I can make head ways. I really like some platform where I can provide an alternative solution to the people.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonWorldForEachBodyInAABBDo issue

Postby Sweenie » Tue Dec 15, 2015 3:59 am

It's really easy to use the Unity Editor and it makes setting up test scenes so much easier.

I guess it could be a little weird for a hardcore c++ programmer like you to work with C# though ;)

I will send you my plugin and my Unity project to you so you can try it out.

Basically my plugin is just a wrapper for the standard newton c functions and I could have used the default Newton functions without creating a wrapper. But since the vehicle and the custom joint library doesn't have standard c functions I had to create a wrapper to handle them in Unity.

Another reason I created a wrapper is to handle the creation of Newton World and having control over it's lifetime.

The basic problem is this...
In unity the scene contains of Game Objects which contains components.

First I created a component (c# script) that creates and destroys the NewtonWorld.
Then I created a component that creates and destroy the rigid bodies.

The problem now is that I can't fully control the execution order of these scripts.
Obviously the Newton World script must run first or else the bodies can't be created.

Now you can tell the editor that the NewtonWorld script has higher priority and must run before any other scripts.
So I can control the startup order.

The real problem is when shutting down.
This time the Newtonworld script and it's function OnDestroy must be the last function to execute.
But I can't control this and if the world is destroyed before the bodies my calls to NewtonWorldDestroyBody crashes for obvious reasons.

Instead I let the wrapper create the world when Unity loads the plugin and destroys the world when it unloads the plugin. Ideally I would rather like to Unity create a new Newton world each time it starts a scene so I'm still trying to figure that out.

If Unity just added two more callbacks this would be so easy.
Like OnSceneStart and OnSceneEnd (or something like that)
Sweenie
 
Posts: 490
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest