Access violation CalculateForcesGameMode

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Access violation CalculateForcesGameMode

Postby arkeon » Wed Sep 24, 2014 5:58 pm

First video where I could make it fail.
(don't believe the debug informations it don't work well in ralease with debug, but the functions where it fail must be right.)

I'll pulling my hairs off... It do not act the same again.. I understand better why you don't see the problem :/ and the mouse making explode the joints ar not normal here you're right...

720p so you should be able to read the screen



next video the same without the scale functions.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby Julio Jerez » Wed Sep 24, 2014 6:11 pm

but that's the same thing I am seeing, that has nothing to do with call a scale function or not,
that has to do setting the velocity of the body in the pick functions.

the forces you are applying are so huge that make floating point values go out of dynamics range.

when you are debugging the code you can set the thread to emulation so that you can see when the bug happened in the first place
in this file
C:\Development\newton-dynamics\coreLibrary_300\source\core\dgThread.h
uncomment this define
Code: Select all
// by default newton is run on a separate thread, optionally concurrent with the calling thread, it also uses a thread job pool for multi core systems.
// define DG_USE_THREAD_EMULATION on the command line for platform that do not support hardware multi threading or if multi threading is not stable
//#define DG_USE_THREAD_EMULATION

then I will let you see the complete call stack.

the explosion problem has to be fix first, there is no reason for that to happen under any circumstances.

you still have a bug in you pick function, did you put some limit check to see when or why go up so high?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Access violation CalculateForcesGameMode

Postby arkeon » Wed Sep 24, 2014 6:25 pm

OK I'll try that tomorrow.
I'm not able to make the thing working again (yes today it was working when I remove async update and scaling..) must be something wrong with my visual studio all that must be cleaned and rebuild from start (take hours).
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby arkeon » Wed Sep 24, 2014 8:04 pm

Ho you can redownload the ragdoll.xos file again. I did test a high mass on the mouse body and forget to revert it, this is why it explode ^^ 10000 of mass on the small mouse body linked to a joint....

http://arkeon.dyndns.org/scol/ragdoll.xos

So finally after rebuild everything I got all working as before.
Here the video, the first part show the result when the scaling is enable (as explained before) the second part do not use the collision scaling function and work as expected.



(note that the virtual call thing still happen when using updateAsync)
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby Julio Jerez » Wed Sep 24, 2014 8:29 pm

Ok I see.
few questions.

did uncomment the define that disable the treading?
How do to do the scaling, you do it once and start become bad, or are you doing on every frame.
last, some how the code that I have behave like the same video, so I guess I nee that last build that you made, because the one I have explode the moment I touch the skeleton.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Access violation CalculateForcesGameMode

Postby arkeon » Wed Sep 24, 2014 8:34 pm

I've rebuild everything clean in static :/
you can just replace this file again to avoid the skeleton exploding : http://arkeon.dyndns.org/scol/ragdoll.xos

The scale is applied only once in this sample. when the bodies are created.
I'll try to debug the threading tomorrow this the compilation flag.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby Julio Jerez » Thu Sep 25, 2014 10:21 am

Ok after debugging this I see no reason for the Scale to cause the problem that you are seeing.
But I think I know what the problem is.

I see that you use the method NewtonUpdateAsync which is cool because it give you almost free physics updates,

However when using that method you have to realize that the engine is running asynchronous with the application, I see that you call function NewtonBodySetCollisionScale while the update is running

but that function manipulate pointer in the body list, it is possible that if an update is in progress and you call that function that the update may read a pointer while is transition.
I added a world->Sync to the function, maybe that was the problem, but I could not verified.

in the future, when you want to stop the update to make scene changes, you should call function
void NewtonWaitForUpdateToFinish (const NewtonWorld* const newtonWorld)

this will wait for the current update to complete befre is return back to the application.

That m_matesrPoint become NULL is a symptom of that, but I could not verify it,
please sync and try again see If the remove the crash problem.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Access violation CalculateForcesGameMode

Postby arkeon » Thu Sep 25, 2014 3:45 pm

Hi,

after a first test this is all the same :/
I'll try to add NewtonWaitForUpdateToFinish before bodies creation / destruction and setmatrix things.

Do you think this is also related to the strange bones acting in the first part of the video ?


Edit : seem ok for the virtual call issue when I add NewtonWaitForUpdateToFinish. But with scale enable the bones still act crazy.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby Julio Jerez » Thu Sep 25, 2014 4:44 pm

I do not know why will this be different with or with out calling the scale, the scale is simple 1, it should no make any difference.
they only thong I can try is try to recreate what you are doing in the sandbox demo.

The sandbox has a ragdoll demo, I can probably past the same code you are using to do the scaling and see if I can reproduce the bug.

specially since I am still no sure how I will detect the bug when if it happens.

try doing this, in this function

Code: Select all
void NewtonBodySetCollisionScale (const NewtonBody* const bodyPtr, dFloat scaleX, dFloat scaleY, dFloat scaleZ)
{
   TRACE_FUNCTION(__FUNCTION__);
   dgBody* const body = (dgBody *)bodyPtr;
   dgWorld* const world = body->GetWorld();
   NewtonCollision* const collision = NewtonBodyGetCollision(bodyPtr);

   world->Sync ();
   dgFloat32 mass = body->GetInvMass().m_w > dgFloat32 (0.0f) ? body->GetMass().m_w : dgFloat32 (0.0f);
   NewtonCollisionSetScale (collision, scaleX, scaleY, scaleZ);

   NewtonJoint* nextJoint;
   for (NewtonJoint* contactJoint = NewtonBodyGetFirstContactJoint(bodyPtr); contactJoint; contactJoint = nextJoint) {
      nextJoint = NewtonBodyGetNextContactJoint(bodyPtr, contactJoint);
      world->DestroyConstraint ((dgConstraint*)contactJoint);
   }
    NewtonBodySetMassProperties (bodyPtr, mass, collision);
   world->GetBroadPhase()->ResetEntropy ();
}


comment out these lines
NewtonBodySetMassProperties (bodyPtr, mass, collision);
world->GetBroadPhase()->ResetEntropy ();

and see If the Bug goes away., then try commenting only the last line and so on maybe we can see whis of those function introduce the malfunction.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Access violation CalculateForcesGameMode

Postby arkeon » Thu Sep 25, 2014 4:50 pm

in this sample I just create slider joints with a limit of 0 0. each bone body is a box.
I have a scale of 1 1 1 but an offset matrix with the bone length and direction.
I don't know why I didn't think about that before ^^ but if this is not related to the scale it must be related to the offset matrix.

here my scale function
orient and pos are the offsets.
Code: Select all
  float matrix[16];
  OgreNewt::Converters::QuatPosToMatrix(orient, pos, &matrix[0]);
  NewtonCollisionSetMatrix(NewtonBodyGetCollision(m_body), matrix);
  NewtonBodySetCollisionScale(m_body, scale.x, scale.y, scale.z);
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby arkeon » Thu Sep 25, 2014 5:12 pm

nope.. just commenting //NewtonBodySetCollisionScale(m_body, scale.x, scale.y, scale.z); make all working correctly, so this is not the collision offset matrix.

I'll try also with your ragdoll demo.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby Julio Jerez » Thu Sep 25, 2014 5:26 pm

Onless the matrix is ill formed, that shoudl not make any difference

My guess Is that the matrix may be ill formed.
Ogre matrix are transposed with respect to Newton Matrices
in newton the Matrix layout should be like this

x00 x01 x02 0.0
x10 x11 x12 0.0
x20 x21 x22 0.0
p.x p.y p.z 1.0

make sure the matrix is on that from, my guess it is not.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Access violation CalculateForcesGameMode

Postby arkeon » Thu Sep 25, 2014 5:30 pm

just an interesting thing with the ragdoll demo, with exact solver and when moving the ragdolls with the mouse they finish by spinning infinitely.

I will check the matrix but as I said before when I just comment the scale part but keep the setmatrix all works correctly.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby arkeon » Thu Sep 25, 2014 5:56 pm

Arf I found the issue. I had a bug in pre render update for animation before physic update, where the scale function where called each frame....

Sorry for the time lost :/

Does calling the scale function before each physic update should really be a bad thing ?
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Access violation CalculateForcesGameMode

Postby Julio Jerez » Thu Sep 25, 2014 6:02 pm

arkeon wrote:Does calling the scale function before each physic update should really be a bad thing ?

yes that's was I what I was saying before, calling on scale Body will do that because scale body call function set mass matrix that will reposition the object on the mater list.
this will only happen when running NewtonUpdateAsync

I could probably add a Lock there but it is a big task since the container class is no thread safe so I will have to track all the places where the mater not is reference which is hundred of places.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 5 guests

cron