Game Development Community

PhysX 3.x Plugin

by Timmy01 · in Torque 3D Professional · 10/28/2013 (5:11 am) · 500 replies

Update:
If you wish to follow this than please check here github.com/ChrisCalef/Torque3D/tree/physx3_advanced_WIP
#181
03/13/2014 (2:45 pm)
@Andrew it only works with Triangle Meshes at the moment, which is probably why you didn't notice anything :P

Please email me at programmerjeff95 at gmail dot com for more info.

Also don't know much 3D modeling, so I can't make a test level really :P
#182
03/14/2014 (7:14 am)
@Paul:

Does the climbing part work if you force it to use the _findContact method instead of mPhysicsRep->findContact even with physics enabled?
#183
03/14/2014 (7:18 am)
@Timmy:

That's a good question, I haven't tried that...

Will have to copy the climb code up to that function and see.

P
#184
03/14/2014 (7:26 am)
@Paul:

You shouldn't even have to do that, with the player class either just temporarily comment out this part in that findContact function

//if ( mPhysicsRep && mDataBlock->physicsCollision )  
 //     mPhysicsRep->findContact( &contactObject, contactNormal, //&overlapObjects );  
//   else  
      _findContact( &contactObject, contactNormal, &overlapObjects );

or set the player datablock::physicsCollision to false. I think that _findContact function should still work even when physics is enabled.
#185
03/14/2014 (7:39 am)
@Timmy:

No, that didn't work... Lost my jump key, and when I would move it would keep gliding for a second after I let off the key. Bumping into the ladder did nothing - no console messages/errors.


@Andrew:

Thanks for the tip, did that and the response was always 0. So it isn't detecting anything in the overlapobjects I'm guessing? What exactly does that mean? The actual collision is happening - when I bump into any StaticShape or TSStatic or vehicle and even Paul Dana's turrets now, I am stopped as I should be (with vehicles and turrets I even auto-mount when colliding)... But I'm out to lunch when it comes to what is happening in these findcontact routines :(

Really more of a script guy, been learning a lot about the C++ engine side of things while working through all this PhysX stuff, but still pretty foggy. So thanks for all the help.

Cheers
P
#186
03/14/2014 (9:34 am)
FYI - solved my turrets issue...

Just opened up the barrel model in Shape Editor and created a MuzzlePoint node out off the end of the barrel (there wasn't a muzzlePoint node in this model for some reason, so projectiles were being created at the root node inside the barrel and exploding it as soon as you fired lol).

Anyhow, now I can mount a turret and blast everything around me, lots of fun!

P
#187
03/14/2014 (6:25 pm)
@Paul:

I'll try and reproduce the problem without adding in the climbing code.

@jeff:

Sorry i haven't had a chance to check out your problem either, i have had sfa free time this past week but i will get to it eventually ;-)
#188
03/14/2014 (7:00 pm)
@Paul:

The problem is the overlap test on the physics side is only looking for trigger items, that is why the overlapObjects is always size 0 because obviously the ladder is not a trigger item.

Take a look at the function Px3Player::findContact which is what that mPhysicsRep->findContact function is. Take a look from line 249 in px3Player.cpp and you can see the filter PX3_TRIGGER (internal name for PhysicsBody::BF_TRIGGER) is applied.

You could try changing that PX3_TRIGGER to PX3_DEFAULT but this may have adverse side effects with other parts of the code (i haven't tested this myself). You will just have to test it and see how it goes.

I mentioned this a few pages back, the whole physics plugin collision group system could certainly do with some updates as it is pretty limited in it's current state.
#189
03/14/2014 (7:23 pm)
@Tim no worries man, take your time.

@Paul I'm mainly script as well, I know that feeling with dealing with C++ :P

I didn't read all of these posts in depth above, which I should have, but dealing with contacts you guys know there is a contactreporter that reports every contact every dynamic object has in the simulation for both triggers and actors right? One suggestion is if your gonna hook it up with script, you'll have to do an internal schedule because deleting an object from a physx callback will cause torque to crash (sometimes) as they say it is not thread safe (but torque runs on 1 thread, I don't even...).

The documentation is good on that, didn't take long to write a contact reporter.
#190
03/15/2014 (8:26 am)
bug report of some sort : i recompiled last repository without the examples, i tried to add one cheetah car and it worked (saw the shape on pvd) and i had performances troubles (i use a gt6402gd3 : powerfull card, can play arma 2 full hd) then i added a second car and all went to hell : the whole application basically slowed down like i ran it on a gt 300 or something, so i suspect the world update loop or something is acting up.. i'm gona try the same with samples and physx2 tho in physx2 we couldnt use cars like this, maybe its the engine setups ?

anyway i used default empty terrain the performance issue still happen on the empty room but at a less noticeable scale (1-2 fps drop in the terrain it was like 30-40 drop), so i highly suspect a problem with the loop update in link to terrain, if you fix this i have a full solution of tons of vehicles i can make work with torque and i will so share it there.
#191
03/15/2014 (9:57 pm)
@Henares:

Thanks for the feedback, yep you are right this is a part i haven't fixed up yet. If you look in the processTick of vehicle.cpp i put a TODO note in there but haven't actually fixed it up, i'll try and get around to fixing this up today.

*Edit:

On second testing i am getting the exact same frame rates with physics enabled or disabled when there multiple vehicles in the scene.
#192
03/16/2014 (7:02 am)
Hey again all,

Thanks for the replies... I'm still not able to figure it out, climbing just isn't activating in PhysX build.

Is this really the only way anyone ever figured out to do climbing in T3D? At least without adding in the action adventure kit or something like that?

Seems like something that should just work... Wish that was the case lol.

FYI - I am not seeing the vehicle problem mentioned by the way - I have one mission where I've put two race cars and a cheetah and a couple of dune buggies, plus a flying vehicle or two and a new boat vehicle based on hovervehicles, and frame rate doesn't seem to drop significantly.

But I did see the TODO comment in the code :)

P
#193
03/16/2014 (6:56 pm)
timmy : its explicitly happening on NON SAMPLES (full template!) :)
#194
03/16/2014 (9:16 pm)
solved : sound like a mixup of different repo versions was causing it
#195
03/17/2014 (3:52 am)
So you are taking over the GREED project henares?
#196
03/19/2014 (7:23 am)
okay, I have a huge issue but I think it might just be my code. My ragdoll was finally created with linking a bunch of rigid bodies to d6 joints.

Here's a very simple representation in the physx debugger (anyone know why these actors aren't displaying with physicssdebugdraw(1))

i.gyazo.com/178c0627076b672117cb2c2b85843a68.png
but when I move the bone nodes on my object to the position it goes horribly out of whack.

i.gyazo.com/0823390bbe06d63e34c7dd06cb273046.png
INFACT, the actual PhysX ragdoll is about 1 unit infront of my feet in that photo.

I am getting the PxRigidDynamic position with getTransform...
whateverPxRigidDynamicPointer->getGlobalPose());

and applying those transformations onto the model with

S32 rightThigh =  mShapeInstance->getShape()->findNode("Bip01_R_Thigh");  
		if(rightThigh)
			mShapeInstance->mNodeTransforms[rightThigh] = mPhysicsRagdoll->getTransform(eRagdollBone::RIGHT_THIGH);

Any ideas?
#197
03/19/2014 (6:00 pm)
Take a look here developer.nvidia.com/sites/default/files/akamai/physx/Docs/Joints.html it will give a few visualization parameters that you can add to help see what is going on. If you take a look at Px3World::onDebugDraw you can enable more visualization parameters there as I haven't enabled too many of them.

Once you have enabled some of the joints visualization could you repost that screenshot above with physicsDebugDraw enabled.
#198
03/19/2014 (10:50 pm)
They refuse to visualize :O

I've enabled physicsDebugDraw and added..

//jlea:
   mScene->setVisualizationParameter(physx::PxVisualizationParameter::eJOINT_LIMITS,1.0f);
   mScene->setVisualizationParameter(physx::PxVisualizationParameter::eJOINT_LOCAL_FRAMES,1.0f);

my ragdoll init code is here, anything look strange?

http://pastebin.com/w59RxCei
#199
03/19/2014 (11:17 pm)
Managed to fix the offset issue, I had to subtract the current shape position after applying the PhysX offsets. PhysX still doesn't display visualization on my custom stuff though.
#200
03/21/2014 (11:35 am)
I was also wondering, will APEX destruction, vegetation, particles, etc, be integrated later on? Just wondering.