2 KinematicBodies not colliding Newton 3

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Thu Jun 23, 2022 11:17 am

Hi,

I gave you access to my GameEngine NOWA-Engine and there is also a project called NOWA-Design, which is a 3D Level editor with lua integration etc. and I'm Using Ogre2.x since it uses newest nicest grafical features such as physically based rendering, texture streaming, much more performance...

I would not recommend using Ogre 13, because its totally old technology...

Here is the newest Ogre source code:

https://github.com/OGRECave/ogre-next

I have with the player controller 2 issues:
I'm using now the correct:

Code: Select all
dFloat ContactFrictionCallback(const dVector& position, const dVector& normal, int contactId, const NewtonBody* const otherbody) const



It also works for one player controller and rigid bodies. But It does not detect, if a player controller collided with another player controller, which inside is a kinematic body. The collision detection itself does work, the other player will be moved away if I collide with it, but ContactFrictionCallback is not called.
How can this be fixed?

Another question: As I have two player controller. Should I have just one PlayerControllerManager which is adding a PlayerController with AddRoot(...) 2 times? Or can each PlayerController can have its own PlayerControllerManager?


Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Julio Jerez » Thu Jun 23, 2022 12:55 pm

if you sync, you can check now demo
...\newton-3.14\applications\demosSandbox\sdkDemos\demos\BasicPlayerController.cpp

class dBasicPlayerController: public dPlayerController

has a function void UpdatePlayerStatus(dPlayerControllerContactSolver& contactSolver)

as Dave said it is call, call for PreUpdate, but I can see how will be hard to use.

so I made the function virtual on the base class and now you can over load it and iterate ove the contacts checking which is which.
I am simply tracing the tracing "hit a player", you can do as you wish.


on this
Lax wrote:I gave you access to my GameEngine NOWA-Engine and there is also a project called NOWA-Design, which is a 3D Level editor with lua integration etc. and I'm Using Ogre2.x since it uses newest nicest grafical features such as physically based rendering, texture streaming, much more
I would not recommend using Ogre 13, because its totally old technology...
Lax


ah that is much better, when I build ogree13 it seems like a 25 year old game engine,
but I rather do it on a version that have it already working.

so I will try your engine and see how that goes.
them you can provably recommend to anyone who wants to try it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: 2 KinematicBodies not colliding Newton 3

Postby Julio Jerez » Thu Jun 23, 2022 1:24 pm

Oh I see I need a svn client like Torstoi to get the entire project.
svn checkout https://svn.code.sf.net/p/nowa-engine/svn/ nowa-engine-svn

I download the link, but it only get the folder with the extenals: ..\nowa-engine-svn-r338-external
I see OgreNewt3 there,
ok so I will try it this weekend. I have no way to do it during the weekd.

btw you site is very cool.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: 2 KinematicBodies not colliding Newton 3

Postby Slick » Thu Jun 23, 2022 4:47 pm

I use Ogre with Newton but haven't been able to work on it much recently.

I had used Ogrenewt in the past and then moved away to try and use Newton more directly and just make conversions for matrix etc. For me it is working well. When I moved from Newton 3 to 4 I tried to use the least I could of a wrapper over Newton.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: 2 KinematicBodies not colliding Newton 3

Postby Julio Jerez » Thu Jun 23, 2022 5:39 pm

yes, part a big part of the idea of newton 4 is that it could be used directly.
but since most people prefer to work wit what the are familiar with, I can just update that wrapper.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Fri Jun 24, 2022 2:50 am

Oh I see I need a svn client like Torstoi to get the entire project.
svn checkout https://svn.code.sf.net/p/nowa-engine/svn/ nowa-engine-svn


Ok, if something does not work. I can assist you.
You need Visual Studio. I never had the muse to change to cmake and by now the engine does only work in windows. Build all projects in x64.

btw you site is very cool.

Thanks for our feedback :D
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Fri Jun 24, 2022 4:49 pm

Hi Julio,

here some instructions how to built everything.

First download:
https://www.lukas-kalinowski.com/Homepa ... encies.zip
unpack and place under GameEngineDevelopment\external\Ogre2.2SDK

The dependencies are required for Ogre cmake.

Build everything for x64 debug/release
1) start cmake for Ogre. You can use my cache, but the paths need to be adapted:
http://www.lukas-kalinowski.com/Homepage/wp-content/uploads/CMakeCache.txt
2) Configure, Generate, Open VC Project and build the ogre Solution.
3) Start in the main folder the CopyOgre.bat, which will copy all necessary ogre files to the game engine folder
4) Build newton-dynamics debug/release
5) Start in the main folder the CopyNewton.bat, which will copy all necessary newton files to the game engine folder.
6) Open GameEngineDevelopment\NOWA_Engine\NOWA_Engine.sln
7) Build everything. If something does not build, start again.
8 ) Open GameEngineDevelopment\NOWA_Engine\plugins\plugins.sln
9) Build all plugins. It may be that you must build again, somehow because of multithreading, it may be that a project cannot be built.

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Sat Jun 25, 2022 4:21 am

Hi Julio,

I maybe found another bug in PlayerController demo.
I'm using ContactFrictionCallback(...)
I set for some bodies a valid NewtonBodySetMaterialGroupID(...) like 4.
Yet when ContactFrictionCallback is called, I always get the contactId of 0.

Code: Select all
dFloat friction = ContactFrictionCallback(point, normal, int(contact.m_contactID), contact.m_hitBody);


I searched also in the newton code, but m_contactID is never assigned!

So how is it possible to set a contact Id manually?
I also tried NewtonCollisionSetUserId(...), but that does not work.

Update: I found out, that its only possible to set the id via:
Code: Select all
NewtonTreeCollisionAddFace(...)

But now image: In my level editor I want to change the categoryId, so its not possible for the collision to get the new Id.

I think I need something like: NewtonTreeCollisionSetFaceId(id) or even better: NewtonCollisionSetUserId(...) should set that, so that the id can also be set for other collision shapes like box, convexhull etc.

@Julio: Could you make this happen please?

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Julio Jerez » Sat Jun 25, 2022 11:02 am

ok one thing at a time.

if you look at demo Basic Player controller.
it makes one player manager, and add three players,
dBasicPlayerControllerManager* const playerManager = new dBasicPlayerControllerManager(world);

for changing the mass, the played is derived from dVehicle, you can get the common properties from the base class. there you can get the Body and there you can change stuff on the body.

on the contact ID, it should get the id of the contact generated by the collision.
in the demo, I set the is of the collision tree face to the material id
dFloat ContactFrictionCallback(const dVector& position, const dVector& normal, int contactId, const NewtonBody* const otherbody) const

when I set the break point there I get the id, which is 3 in this case.

the contacts are calculated by the same function that does it for the dynamics body,

void dPlayerController::ResolveCollision(dPlayerControllerContactSolver& contactSolver, dFloat timestep)

if you place a break point there, you will see that the first thing is calls is
m_contactCount = NewtonWorldCollide(world, &matrix[0][0], shape, m_controller, PrefilterCallback, m_contactBuffer, D_PLAYER_MAX_CONTACTS, 0);

then ids of the colliding shape are there.
then after it gets the contacts in postprocess them in a loop, and call this

dFloat friction = ContactFrictionCallback(point, normal, int(contact.m_contactID), contact.m_hitBody);

as you can see it collects the id from the material but is can just pass the contact.
there you can get the shape and see if is was a terrain or whatever.

if you want we can make
dFloat friction = ContactFrictionCallback(point, normal, int(contact.m_contactID), contact.m_hitBody);

pass the contact instead of the point normal, id and body.

dFloat friction = ContactFrictionCallback(contact);

will that be better?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Sat Jun 25, 2022 11:36 am

pass the contact instead of the point normal, id and body.

dFloat friction = ContactFrictionCallback(contact);

will that be better?


No I think I understood and its ok, that way it works. Thanks for clarification!

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Sat Jun 25, 2022 12:43 pm

Hi Julio,

I must change in the dPlayerController the function:
Code: Select all
void SetHeadingAngle(dFloat angle)

from:
Code: Select all
void SetHeadingAngle(dFloat angle) { m_headingAngle = dClamp(angle, dFloat(-dPi), dFloat(dPi)); }

to:
Code: Select all
void SetHeadingAngle(dFloat angle) { m_headingAngle = angle; }

Because internally a player can have a different start orientation. And each time newton does rotate the player back. So I use the formula:
Code: Select all
m_heading = m_startHeading + headingAngle;

Start heading is the initial orientation of the body. Now If it will be clamped, I cannot rotate around 360 degree anymore. If I remove the clamp and make my own clamp. It will work like a charm.
Could you at least maybe create an additional function:
Code: Select all
void SetHeadingAngle(dFloat angle) { m_headingAngle = dClamp(angle, dFloat(-dPi), dFloat(dPi)); }
void SetHeadingAngleUnnormalized(dFloat angle)  { m_headingAngle = angle; }

In which no clamping is done?

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Julio Jerez » Sat Jun 25, 2022 1:32 pm

done.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Sun Jun 26, 2022 4:26 am

Thanks!
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Lax » Tue Jul 05, 2022 6:07 am

Hi,

I made a funny video showing the newton collision system:

https://www.youtube.com/watch?v=9vDNdfVs4ao

Lua Code:
Code: Select all
CollisionDirection_Monster02_0["onContactFriction"] = function(gameObject0, gameObject1, playerContact)
    gameObject0 = AppStateManager:getGameObjectController():castGameObject(gameObject0);
    gameObject1 = AppStateManager:getGameObjectController():castGameObject(gameObject1);
   
    if (gameObject1:getCategoryId() == 4) then
        playerContact:setResultFriction(0.5);
    else
        playerContact:setResultFriction(2);
    end
   
    --log("Collision friction between: " .. gameObject0:getName() .. " vs. " .. gameObject1:getName() .. " friction: " .. playerContact:getResultFriction());
end

CollisionDirection_Monster02_0["onContact"] = function(gameObject0, gameObject1, playerContact)
    -- For dot the other player that is not moving is of interest and no backward collision!
    if (isActive == false or moveHorizontal < 0) then
        return;
    end
   
    gameObject0 = AppStateManager:getGameObjectController():castGameObject(gameObject0);
    gameObject1 = AppStateManager:getGameObjectController():castGameObject(gameObject1);
    -- log("Collision between: " .. gameObject0:getName() .. " vs. " .. gameObject1:getName());
   
    if (gameObject1:getCategory() ~= "Enemy") then
        return;
    end
   
    local toGameObject = gameObject0:getPosition() - gameObject1:getPosition();
    local heading = gameObject1:getOrientation() * gameObject1:getDefaultDirection();
    local dot = heading:dotProduct(toGameObject:normalisedCopy());
   
    local velocity0 = gameObject0:getPhysicsPlayerControllerComponent():getVelocity();
    local velocity1 = gameObject1:getPhysicsPlayerControllerComponent():getVelocity();
    local velocityDiff = velocity0 - velocity1;
    local velocityDot = velocity1:dotProduct(velocityDiff:normalisedCopy());
   
    -- log("Player1:  Collision between: " .. gameObject0:getName() .. " vs. " .. gameObject1:getName() .. " velDiff: " .. toString(velocityDot));
   
    oldHeight = rectangleComponent:getHeight(0);
    local height = MathHelper:lowPassFilter(5.0 - (dot * velocityDot), oldHeight, 0.01);
    titleComponent:setCaption("Player1 Hit: " .. toString(height));
    rectangleComponent:setHeight(0, height);
end
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: 2 KinematicBodies not colliding Newton 3

Postby Julio Jerez » Tue Jul 05, 2022 5:33 pm

that is quite funny.
looks as if they are doing a choreograph Tango dance. :D
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 18 guests