Ghost in the Machine [3.14] (2016-02-18 build) [NOT BUG]

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Ghost in the Machine [3.14] (2016-02-18 build) [NOT BUG]

Postby Stucuk » Fri Feb 19, 2016 12:40 am

I have noticed that when i reset a scene but i don't destroy the world that there seems to be residual forces/collisions left over. The only difference is the lines for destroying and creating the world are commented out.

- O3_2016-02-19.rar

Example06.exe destroys and creates the world and GhostInTheMachine.exe doesn't destroy and create the world.


All bodies are destroyed with the NewtonDestroyBody (FCubes[X].Free calls it for the cubes).

Code: Select all
if FRestart then
 begin
  FRestart := False;
  for X := 0 to High(FCubes) do
  FCubes[X].Free;
  NewtonDestroyBody(FloorBody);
  NewtonUpdate(FWorld,1/60);

  //NewtonDestroy(FWorld);
  //MakeWorld;

  CreateFloor;
  MakeScene();
  NewtonUpdate(FWorld,1/60);
  FLastFrameTime := 0;
  SystemTimer.Refresh;
 end;


The following video shows the issue. The app switches between mode 3 and 4. At about 34 seconds into the video is one of the obvious instances of the bug.

User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Julio Jerez » Fri Feb 19, 2016 1:38 am

I have noticed that when i reset a scene but i don't destroy the world that there seems to be residual forces/collisions left over.

I am confused, do you mean you delete all the bodies and there recreated them again and that some how create a malfunction?

could you sync to github so that you get the bug fix and then test this bug again? please.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Stucuk » Fri Feb 19, 2016 3:05 am

Julio Jerez wrote:I am confused, do you mean you delete all the bodies and there recreated them again and that some how create a malfunction?


Yes, i do the following:

1. Create Newton World
2. Create all bodies (Scene)
3. Wait 7 seconds
4. Delete all bodies
5. Switch scene (Just because it makes the bug more obvious then doing the same scene) between 3 and 4.
6. Goto Step 2

From my observations it looks like new bodies are somehow getting forces placed on them from the time the deleted bodies were simulated.

I also noticed that the simulation mostly doesn't follow the same chain of events each time even if there is no obvious looking bugged behaviour.

Julio Jerez wrote:could you sync to github so that you get the bug fix and then test this bug again? please.

The latest build has no impact on this bug.

Latest newton.dll can be found below:
- newton_2016-02-19.rar
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Julio Jerez » Fri Feb 19, 2016 10:09 am

how do I do the steps bellow in that demo, all I can do is hit key 1, 2, 3, 4, 5, 6, 7, 8, 9

1. Create Newton World
2. Create all bodies (Scene)
3. Wait 7 seconds
4. Delete all bodies
5. Switch scene (Just because it makes the bug more obvious then doing the same scene) between 3 and 4.
6. Goto Step 2
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Stucuk » Fri Feb 19, 2016 10:14 am

Julio Jerez wrote:how do I do the steps bellow in that demo


You just run GhostInTheMachine.exe, sit back and watch as it does those steps.

by "Yes, i do the following" i just meant "yes, the following is how its coded".
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Julio Jerez » Fri Feb 19, 2016 10:36 am

Ok I run the test and I see that the demos start out nice, and as you progress swith demos, as one point the same demo (particular the flat wall) some at column in the middle seem to have some force applied at the bottom.
do you also say that if you destroy the world this do no happens but if you just delete the bodies does?

could you run the test switching just between the wall, and some other scene, to see if is also happened. if it does than pack that demo, this is because it is easy to figure out how to debug it.

My guess is that some how the contact cache and the memory manager are conflating to match pairs.
for example was body was deleted, and so where the joints, but since the cache state in memory
if the joint if a scene I recreated and tow bodies happen to have description then it may find that pair in the cache. If I am correct.

could you please insert a function to NewtonInvalidateCache and try again see if the bug goes away.
this will narrow the scope of the bug.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Stucuk » Fri Feb 19, 2016 11:49 am

Julio Jerez wrote:do you also say that if you destroy the world this do no happens but if you just delete the bodies does?

Yes, if the world is deleted and a new one created it works perfectly.

Julio Jerez wrote:could you run the test switching just between the wall, and some other scene, to see if is also happened. if it does than pack that demo, this is because it is easy to figure out how to debug it.

It happens with any combination and even happens if you just reset the same scene all the time. It is not dependent on what is in the scene.

Julio Jerez wrote:could you please insert a function to NewtonInvalidateCache and try again see if the bug goes away.
this will narrow the scope of the bug.


It doesn't change it.

------

Below is the latest version which uses NewtonInvalidateCache:
- O3_2016-02-19b.rar

It includes test.ini which allows you basic control over what happens. First and Second are the scene id's it will switch between (They can be between 0 and 4). The delay value is in seconds and is how long it waits before switching scene.

Scene 0 to 2 are stacks. Scene 3 is the "Cube Wall", Scene 4 is the "Brick Wall".
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Julio Jerez » Fri Feb 19, 2016 11:54 am

Oh so it happens even when testing the same scene, that makes it a lot simpler to debug.
Could you do one more thing, can you make a test switching the same scene and upload that archive.
I will save me a lot of time.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Stucuk » Fri Feb 19, 2016 7:00 pm

Julio Jerez wrote:Oh so it happens even when testing the same scene, that makes it a lot simpler to debug.
Could you do one more thing, can you make a test switching the same scene and upload that archive.
I will save me a lot of time.


You just need to modify test.ini so that first and second have the same number. In a few hours i will be going about 400 miles due to a family thing and won't be back home for at least a week, so i won't be able to reply further until i am back (Since where i will be won't have the internet except over a very slow connection through my phone, meaning i won't be able to upload anything).

If you modify test.ini (thats included with the O3_2016-02-19b.rar version) so it looks like the following it will repeat the same scene (3 is the Cube Wall)
Code: Select all
[modes]
first=3
second=3
[main]
delay=7
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Ghost in the Machine [3.14] (2016-02-18 build)

Postby Julio Jerez » Fri Feb 19, 2016 8:29 pm

Stucuk wrote:You just need to modify test.ini so that first and second have the same number.

yes I figured that out after I made the post, I will debug that over this weekend. and I post the result
you can check it out after you come back.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Ghost in the Machine [3.14] (2016-02-18 build) [NOT BUG]

Postby Stucuk » Fri Feb 19, 2016 9:24 pm

You can safely ignore this thread. The bug was in my code. I noticed it worked perfectly when NewtonDestroyAllBodies(FWorld) was added after i manually destroyed each body. I was creating cubes from 0 to High(FCubes)-3 and then with the rotating ones going from High(FCubes)-3 to High(FCubes) . So it was creating a single phantom body each time.

Doh.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Ghost in the Machine [3.14] (2016-02-18 build) [NOT BUG]

Postby Julio Jerez » Sat Feb 20, 2016 6:20 am

awesome, thank for the notice.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 8 guests

cron