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
#261
06/02/2014 (7:56 pm)
Sweet :)

Just rolled in that trigger change, so think I'm in sync now too.

Thanks!
#262
06/02/2014 (9:07 pm)
Just realized the player activates triggers fine but only at their original scale of 1 1 1.

So if I scale up my trigger the way I want to, a bigger target, the player only actually activates it when they are in the dead center, in the original 1 1 1 area, even though they are standing within the larger scaled area that is visible in the mission editor.

If I load up my non-physx build, the scaled triggers work fine for both players and rigid shapes.

Now, I know that physx doesn't deal well with scale, you can't scale physicsshapes at all for obvious reasons, but is there a reason why the triggers can't be scaled?

Can make do with smaller triggers if necessary, but I wonder is there also perhaps another way to define a trigger area without having to use the scale option?

Maybe this will all work itself out with what you're working on right now, that would be cool :)
#263
06/02/2014 (9:56 pm)
Can't you just resize the Polyhedron to the required size instead of scaling it? I'm guessing that is why the other method doesn't use the convex hull shape for the trigger with physics ( that is what i changed ). The old method used a box shape which is scaled but inaccurate because it's a box shape.

Convex shape can be scaled in physx 3 so i'll take a look when i get a chance.
#264
06/03/2014 (7:53 am)
Got it working... set scale back to 1 1 1 and then edited the polyhedron as suggested... just multiplied polyhedron numbers by 10 and now trigger is same size as if it was scaled 10 10 10. And the player triggers it now the second I step into the larger area.

So, one problem solved :) ready to test physics shapes crossing into the triggers once you figure that out.

Cheers
P
#265
06/03/2014 (4:19 pm)
I got the scaling to work ok but i'm not 100% sure if i should push these changes. It would mean that convex collision shapes within physx3 plugin support scaling but other shapes will not. I think this is rather inconsistent and could lead to confusion. What i think i will do is push the changes through but comment them out and if anyone wants to enable it than just simply remove the comments and compile the support in.

Any thoughts??
#266
06/03/2014 (4:40 pm)
Oh yeah how could i forget lol ... I got the PhysicsShape trigger working too, this will work on all physics plugins.

What i was thinking of doing was adding a field to the PhysicsShape data block called bool activateTriggers and default to false because i don't know if everyone will want this functionality enabled by default?? Again doing this will slightly go against the rest of T3D where the trigger is enabled no matter what and you just ignore the object if you want to. There is a performance penalty for enabling trigger testing and i figure if you don't need it than why have it enabled?

Thoughts on this one?

#267
06/03/2014 (4:58 pm)
Awesome!

OK well I think you have it right, especially if there is any sort of performance hit by having it enabled by default ... in our case not every physics shape we use in the game will be used to activate triggers, so just enabling it in the data block when needed sounds great.

This is fantastic, I'm going to have fun now making mini games and planning out cool traps and triggers.

Any thought on making the physics shapes also be able to do damage or anything when they collide? Like enabling an on collision callback? That would be the crown jewel :) would love to be able to crush the player with a boulder like an Indiana Jones temple lol

Thanks again, great work!
#268
06/03/2014 (5:09 pm)
Well the performance hit is no more than say any other T3D object so it's not the end of the world. Personally i prefer the method of been able to disable it completely and just enable it on objects that i would want potential trigger callbacks. Anyway i'll do it this way for now, i'll update the repo in the next few minutes.

I'll look into the on collision callbacks.
#269
06/03/2014 (5:20 pm)
Ok repo updated with two updates:

1) PhysicsShape trigger testing support (disabled by default).
2) Scaling support for physx3 convex collision shapes.

Also i'll think up a good example of the physics trigger stuff and update andrew's physx3 samples.

#270
06/03/2014 (5:28 pm)
Perfect, woohoo!

#271
06/03/2014 (8:22 pm)
I updated the physx-samples with a very basic trigger test. Just shoot the box through the arch thingy with the cloth hanging on it (or walk through it). The tower should than get deleted causing the boxes to fall.
#272
06/03/2014 (11:00 pm)
@Paul:

This onCollision script callback, you want this for PhysicsShape based objects yeah?
#273
06/03/2014 (11:14 pm)
Yes please :)

So that I can script various events when a particular PhysicsShape rolls into a player or a vehicle, etc.

The aim being that I could turn the large boulder into a kind of rolling projectile, that when it hits a player object it applies damage and/or impulse. I think that would be so cool, and open up a world of possibilities for mini-games.

By the way, I've been playing with the triggers and they work perfectly.

Does that scaling change you made enable me to scale the triggers now too? I don't mind doing it the way we figured out before, increasing the size of the polyhedron and keeping scale at 1, was just curious if that's what that fix was for :)

Thanks again!
#274
06/03/2014 (11:38 pm)
Ok sweet, good news about the triggers than :-)

Yes you can now scale the trigger with Physx3, just beware though that the other physics plugins do not support this because of that change i made earlier to Trigger.cpp. I really should document all this stuff on the wiki page of my repo actually.

I'll have to definitely put on the thinking cap for the onCollision stuff. The big problem is PhysicsShape derives from GameBase* where as the onCollision stuff is from ShapeBase* (Player,vehicles,rigidshape all these derive from ShapeBase*). The obvious solution is to create a second PhysicsShape that derives from ShapeBase and than just implement the onCollision etc. I do agree it is functionality that T3D physics could really benefit from having.
#275
06/03/2014 (11:56 pm)
I'm only ever using this plugin, so no worries :)

Sounds like you're on the right track with the onCollision, it's too bad it doesn't just work out of the box in physics builds.

Really late here, gonna pack it in, thanks again, things are looking really good!

Cheers
P
#276
06/04/2014 (12:18 am)
Ok no worries ;-)

What i think is the logical way to implement all of this is to create a second PhysicsShape that uses ShapeBase and leave the current PhysicsShape as is. Actually i will remove the trigger stuff from the current PhysicsShape and implement it on the second one.

This way there will be two options:
1) Standard PhysicsShape - Derives from GameBase - no Triggers,no onCollision etc but is lean and mean.
2) Extended PhysicsShape - Derives from ShapeBase so gets all the bloat/features that come along with that (triggers,onCollision etc etc)
#277
06/04/2014 (4:02 pm)
It's going to be so cool when you're done :)

This should really be the new standard physics plugin for T3D... especially since on their main github repository page they are asking for physx 2.8 or something which you can't even download anymore. 3.3 is faster than its ever been and should be the new standard IMO.

This plugin rocks!
#278
06/04/2014 (4:37 pm)
I guess i'm partly to blame for that as i have never done a pull request on any of this stuff and it's kind of tricky because there is changes outside of the physics directory itself. I created the physx3_basic branch so it could be accepted into T3D first and than work on getting the other stuff in at a later date. I really should get that physx3_basic branch up to scratch and get the ball rolling.

I also have to do a pull request on the project manager too.
#279
06/04/2014 (5:28 pm)
Paul i got the onCollision stuff working ok, it was ridiculously simple actually. I'll just do a bit more testing first before i release it.

I also need to come up with a new name for this PhysicsShape variant?? as i don't want to get rid of the original one as it still serves a purpose as it has far less bloat associated with it.
#280
06/04/2014 (5:35 pm)
Hey that's great news!

OK, for a name hmmmm... How about PxHybridShape? I dunno, there's always the un-original NewPhysicsShape as well :)