One more thing broken in 3.14 [SOLVED]

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

One more thing broken in 3.14 [SOLVED]

Postby pHySiQuE » Sat Jun 03, 2017 11:12 pm

With my custom-made character controller system, when a rigid body collides with a player controller, the rigid body wakes up the character controller. In the video below, the oil drum will wake up the player and the custom collision system will kick in.

Since I updated to 3.14, all these collisions are not detected. I can't figure out why, but it has completely broken my player physics. If you keep the player still and then turn or move the player, it will suddenly throw the player across the room because of the depth of penetration.

The Steam summer sale is coming up, but there's no way I can release this in the current state.

I am now using an unmodified version of Newton as a DLL, so all demos can be debugged in Visual Studio:
https://www.leadwerks.com/files/CollisionTest.zip

Last edited by pHySiQuE on Sun Jun 04, 2017 12:40 pm, edited 1 time in total.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: One more thing broken in 3.14

Postby Julio Jerez » Sun Jun 04, 2017 11:12 am

ok I see, I will debug the problem now,
can you show me the code sniped that you use to detect collision?

also another thing I have problem running you demos window do no let me run then any time, you may want to register your name so that does no happen to other people.

https://blogs.msdn.microsoft.com/vsnets ... c-at-risk/
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: One more thing broken in 3.14

Postby pHySiQuE » Sun Jun 04, 2017 11:20 am

Thank you. I am sending you all my physics classes.

In NewtonDynamicsPhysicsDriver.cpp, line 3.91, is where the character controller body is created:
Code: Select all
CharacterController* NewtonDynamicsPhysicsDriver::CreateCharacterController(Entity* entity, const float radius, const float height, const float stepheight, const float maxslope, const float crouchheight)


In NewtonDynamicsBody.cpp, line 512, this is the function where regular rigid bodies are created:
Code: Select all
void NewtonDynamicsBody::Update()


In the same file, NewtonOnAABBOverlap() can be found on line 1315. For some reason, this function is never called when a rigid body hits the player. (When the player is awake, the collisions you see are due to my own character controller code found in NewtonDynamicsCharacterController.cpp.)
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: One more thing broken in 3.14

Postby Julio Jerez » Sun Jun 04, 2017 11:29 am

also there is another problem, I can't debug the code if the mouse is set exclusive, I need to be able to step on the debugger.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: One more thing broken in 3.14

Postby pHySiQuE » Sun Jun 04, 2017 12:13 pm

The CollisionTest example is updated. Press escape to release the mouse, press escape again to go back into FPS control mode. Close the window to exit.
https://www.leadwerks.com/files/CollisionTest.zip
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: One more thing broken in 3.14

Postby Julio Jerez » Sun Jun 04, 2017 12:25 pm

edit: I posted this before you made your last post, please try what I sad I beleive this is the problem.

I can't really step on the code the mouse the way it is now, but when I look at the code
I see this in the update function.

Code: Select all
   void NewtonDynamicsCharacterController::Update(const float step)
   {
///
      //Print(GetChild(0)->GetPosition(true));

      CharacterController::Update(1.0);

      if (asleep) return;


I do not see the place where variable asleep is set, and I do not know if the player is a newton dynamics body, I assuming it is just a shape that you move around because if it was a kinematic body the other dynamics body will see the incoming shape, at least that's how it works on the demos.

if this is correct, you said this worked before, but that code could have never work on any newton version, but you can fix very easily.

the first thing you can do to verify if this solve the problem is comment out line
Code: Select all
if (asleep) return;


this will allows the collision test run every time and show if it solves the problem.

the next step is to optimize it so that asleep has effect, for this you can modify the function like this.

Code: Select all
      CharacterController::Update(1.0);

      bool hasclosebody = GetAdjacentBodies();

      if (asleep || hasclosebody) return;



here you modify GetAdjacentBodies so that it test if any dynamics body can potentially collide with the player. something as eassy as this can do it.
The return value if GetAdjacentBodies is the Boolean Or of each dynamic body who's velocity is different than zero.
I believe that should take care of that problem.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: One more thing broken in 3.14

Postby pHySiQuE » Sun Jun 04, 2017 12:40 pm

That's actually a pretty good solution. I tried it and it works. You can consider this resolved.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: One more thing broken in 3.14

Postby Julio Jerez » Sun Jun 04, 2017 12:43 pm

edit: again I poste before you made you last post,
there are still some problems, is you are using a dynamics body for you player, since you are setting the matrix directly, this can cause really bad undeniable behavior, that what kinematic bodies are for.


ok I can debug now,
in the controller class I see the variable newtonbody
but is set to NULL, this and if I set a break point on NewtonCreateKinematicBody it never hit.
so if the play is a newtonBody is must be set somewhere outside the class.

can you tell me if the player is represented by a shape, or by a NewtonCreateDynamicBody?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: One more thing broken in 3.14 [SOLVED]

Postby pHySiQuE » Sun Jun 04, 2017 12:45 pm

The player is a dynamic body, created in the NewtonDynamicsPhysicsDriver::CreateCharacterController() function, in the file NewtonDynamicsPhysicsDriver.cpp.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: One more thing broken in 3.14 [SOLVED]

Postby Julio Jerez » Sun Jun 04, 2017 12:49 pm

you should really use a kinematic body for the player.
Kinematic body are like dynamics for collision because the have mass body and like static body in that the do no integrate. they have some special considerations

It is up to you to try, but do not complain when you see object high energy jumps of other bodies because you are setting the matrix of a dynamics body in the middle of a collision , Try and see if it work
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: One more thing broken in 3.14 [SOLVED]

Postby pHySiQuE » Sun Jun 04, 2017 12:55 pm

The player doesn't actually use any of Newton's physics. It uses my own system, all in NewtonDynamicsCharacterController::UpdateCollision(). The dynamic body was only being used to detect the AABBOverlap and wake the character controller up, so that my own collision system would turn back on.

The problem with kinematic bodies is other objects won't push them out of the way. I may revisit this system in the future and attempt redoing it with a dynamic body and a kinematic joint.

However, for now I am pretty satisfied with the fix you suggested.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: One more thing broken in 3.14 [SOLVED]

Postby Julio Jerez » Sun Jun 04, 2017 1:02 pm

if it is a dynamics body it will be part of the collision unless you have a material that return zero on the collision callback.
yes Kinematic bodies aren't push by other bodies, but that is what you are doing by teleporting them

It is up to you to try it, I am only telling you the way I think is suppose or expected to work.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: One more thing broken in 3.14 [SOLVED]

Postby pHySiQuE » Sun Jun 04, 2017 1:09 pm

How would you suggest handling this situation, where a car runs into a player made with a kinematic body?
Image1.jpg
Image1.jpg (10.43 KiB) Viewed 7968 times
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: One more thing broken in 3.14 [SOLVED]

Postby Julio Jerez » Sun Jun 04, 2017 1:30 pm

I do not know, I suppose the same way is doing it now, you already said that the player do not uses the physic system to react, since you at teleporting the body.

A player control does no act physically whether it is kinematic or dynamics. the application assume control of that body, what I say is that the proper type of body for that kind of object is the kinematic body, no the dynamics body. This is for the behavior of the other bodies not of the behavior of the player, the behavior of the play is your responsibility.

But in any case if you fell satisfied with the result than there is no need change anything.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests