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
If you wish to follow this than please check here github.com/ChrisCalef/Torque3D/tree/physx3_advanced_WIP
About the author
#162
Two seperate commits:
* Updated bullet physics lib to version 2.82
* Updated bullet plugin with the new changes from physx3 branch.
StaticShape and vehicles should work with bullet now. CCD and cloth is not supported at this stage with bullet though.
I'll get round to updating the physx2 plugin at some stage over the weekend or maybe next week.
03/06/2014 (6:19 pm)
Repo update time yet again :-)Two seperate commits:
* Updated bullet physics lib to version 2.82
* Updated bullet plugin with the new changes from physx3 branch.
StaticShape and vehicles should work with bullet now. CCD and cloth is not supported at this stage with bullet though.
I'll get round to updating the physx2 plugin at some stage over the weekend or maybe next week.
#163
03/06/2014 (6:51 pm)
@Paul Shaking and jittering you say? Does it happen to have any interpolation code, as that sounds more like lack of enough updating between the move calls, or your start and end destination and timing is too fast for it to keep it smooth. Maybe try creating more nodes so it has less distance to travel within the time interval, or see if you can hack up some interpolation code if needed? (The physX shape will move during the simulation but maybe the rendered shape isn't being updated as often or something? Just a wild guess.)
#164
03/07/2014 (4:17 am)
where is the bullet changes ? on the physx3 repo ? o_0 ..?
#165
Lol yep, nice and confusing huh ;-)
03/07/2014 (4:18 am)
Quote:
where is the bullet changes ? on the physx3 repo ? o_0 ..?
Lol yep, nice and confusing huh ;-)
#166
03/07/2014 (4:38 am)
dude.. don't get me started, your work is nice and i don't want to bite you :P
#167
03/07/2014 (5:01 am)
ok so i'm utterly confused is the boulder supposed to bounces and react to cheetah ? is it a physx shape ???? i cant collide with it or shoot..
#168
03/07/2014 (2:59 pm)
What boulder??
#169
*Updated physx2 physics plugin with new features from physx3 branch.
So now all three physics plugins should work with those vehicle and StaticShape changes.
Also andrew added a new
*Edit:
Next on the agenda is to finally finish the PhysX3 based vehicles
03/07/2014 (5:50 pm)
Repo update:*Updated physx2 physics plugin with new features from physx3 branch.
So now all three physics plugins should work with those vehicle and StaticShape changes.
Also andrew added a new
virtual PhysicsCloth* createCloth(TSShapeInstance* shapeInst, const MatrixF &transform);function to the PhysicsPlugin when creating the cloth stuff and currently this is only implemented in physx3 plugin and returns a NULL pointer for the rest (while sending an error to console). I think it would certainly be possible to implement this in physx2 plugin but as far as i can tell bullet has SFA to no support for cloth. Maybe it would be best for bullet if i create an empty cloth class instead of returning a NULL pointer.
*Edit:
Next on the agenda is to finally finish the PhysX3 based vehicles
#170
I have a sphere in my game, and whenever it rolls over 2 triangle meshes touch each other at the same height, an impulse is applied. Is there any way to force it to ignore the contact or something so that it don't impulse it? Been trying to solve this, and I posted on the nVidia forums today as well.
Unfortunately, this goes hand-and-hand with my changes for multiple materials, as I have it create a new triangle mesh for each material type. So if there's an ice patch, then it will bounce when it comes into contact with an ice texture, as there's 2 edges rubbing up against each other.
03/08/2014 (1:35 pm)
If Tim or Andrew wouldn't mind looking into this, this would be amazing:I have a sphere in my game, and whenever it rolls over 2 triangle meshes touch each other at the same height, an impulse is applied. Is there any way to force it to ignore the contact or something so that it don't impulse it? Been trying to solve this, and I posted on the nVidia forums today as well.
Unfortunately, this goes hand-and-hand with my changes for multiple materials, as I have it create a new triangle mesh for each material type. So if there's an ice patch, then it will bounce when it comes into contact with an ice texture, as there's 2 edges rubbing up against each other.
#171
03/08/2014 (2:30 pm)
Going to be a little hard when i haven't seen the multiple material stuff you have done, Could i see the PVD capture of this happening? Email it to me if you don't want to post it publicly.
#172
03/08/2014 (4:38 pm)
Gonna package the code for you now, I'll get Glenn to make the video, check your email within the next hour tim.
#173
03/08/2014 (5:33 pm)
Oh i meant the Physx Visual Debugger file, not a screen grab ;-)
#174
Visual Debugger, erm...I have that totally disabled in my build, it was causing issues for me (i forget why). In the process of getting the code making sure I don't forget to send u something again like last time hehe.
03/08/2014 (5:45 pm)
oh...i already have a vid uploading, well i guess you get that haha.Visual Debugger, erm...I have that totally disabled in my build, it was causing issues for me (i forget why). In the process of getting the code making sure I don't forget to send u something again like last time hehe.
#175
If you can't get it working let me know because it's such a handy and powerful tool when trying to find problems.
03/08/2014 (6:02 pm)
Currently the visual debugger is only enabled during debug builds of the physx3 plugin. Shouldn't be too hard to enable it for release mode if you really want too, just remember though you will still have to link to the CHECKED physx3 libs because it is disabled at the physx end with their release libs. I Can't remember if it is enabled with the PROFILE libs too?If you can't get it working let me know because it's such a handy and powerful tool when trying to find problems.
#176
03/08/2014 (6:05 pm)
email sent, i'll have to look into that i guess haha.
#177
So, the vehicle stuff works great, we can now mount a vehicle simply by walking up to it and colliding with it, as we could before in non-PhysX builds... Excellent!
I decided to apply the same logic to Paul Dana's turrets resource, and it worked as it should - the turrets are now destroyable and mountable.
However, I am having an issue with blowing myself up the minute I fire the turret when mounted to it. Must have something to do with the PhysicsRep of the turret, since in non-PhysX builds we mount and fire just fine.
Anyone have a quick hack to get around this? Maybe some way of setting the projectile to appear further out when it is created, so it doesn't appear inside the turret or whatever it is doing to make it instantly kill the mounted player lol...
Thanks!
P
03/12/2014 (7:05 am)
Hey again all,So, the vehicle stuff works great, we can now mount a vehicle simply by walking up to it and colliding with it, as we could before in non-PhysX builds... Excellent!
I decided to apply the same logic to Paul Dana's turrets resource, and it worked as it should - the turrets are now destroyable and mountable.
However, I am having an issue with blowing myself up the minute I fire the turret when mounted to it. Must have something to do with the PhysicsRep of the turret, since in non-PhysX builds we mount and fire just fine.
Anyone have a quick hack to get around this? Maybe some way of setting the projectile to appear further out when it is created, so it doesn't appear inside the turret or whatever it is doing to make it instantly kill the mounted player lol...
Thanks!
P
#178
Timmy sent me your material code and I'm trying to test it. Perhaps I misunderstand how it's supposed to work. Could you package up a test level that highlights how it works? I set static friction and dynamic friction to low values on the material for a cube, and the material for a convex shape box expecting it to slide across it like ice but there's no difference in behavior. No difference in character movement across it either, though I'm not sure if that was an intended feature or not.
Also, I notice huge frame rate drops since merging the changes. For instance the first cube test level jumps between 130fps and 8fps as I try to shoot the cubes around. I made a new test level with just a cube and convex shape and while the frame rate was more stable at first as I was shooting the cube around to test it I saw similar frame rate drops, going as low as 6-8fps while objects are in motion.
03/12/2014 (12:02 pm)
@ JeffHTimmy sent me your material code and I'm trying to test it. Perhaps I misunderstand how it's supposed to work. Could you package up a test level that highlights how it works? I set static friction and dynamic friction to low values on the material for a cube, and the material for a convex shape box expecting it to slide across it like ice but there's no difference in behavior. No difference in character movement across it either, though I'm not sure if that was an intended feature or not.
Also, I notice huge frame rate drops since merging the changes. For instance the first cube test level jumps between 130fps and 8fps as I try to shoot the cubes around. I made a new test level with just a cube and convex shape and while the frame rate was more stable at first as I was shooting the cube around to test it I saw similar frame rate drops, going as low as 6-8fps while objects are in motion.
#179
I have another question for anyone here who may have an idea.
I'm trying to integrate this old climbable objects resource:
www.garagegames.com/community/resources/view/17283
And it doesn't seem to be firing at all now that we're using PhysX. Before we put PhysX in, this used to work lol.
Anyone know why none of these console echoes are firing when I collide with my ladder? Collision is working, the ladder is a StaticShape and I have it angled slightly as the resource requires.
Here is the part of the function in player.cpp that is not working (findcontact routine, which is the correct findcontact for PhysX - non-PhysX uses _findcontact):
Please, any ideas how to fix the code to be PhysX-compatible?
Or anyone have another way of doing climbable stuff in PhysX? I need my player to be able to climb ladders in my game.
Thanks in advance!
P
03/13/2014 (11:20 am)
Me again...I have another question for anyone here who may have an idea.
I'm trying to integrate this old climbable objects resource:
www.garagegames.com/community/resources/view/17283
And it doesn't seem to be firing at all now that we're using PhysX. Before we put PhysX in, this used to work lol.
Anyone know why none of these console echoes are firing when I collide with my ladder? Collision is working, the ladder is a StaticShape and I have it angled slightly as the resource requires.
Here is the part of the function in player.cpp that is not working (findcontact routine, which is the correct findcontact for PhysX - non-PhysX uses _findcontact):
void Player::findContact( bool *run, bool *jump, VectorF *contactNormal )
{
SceneObject *contactObject = NULL;
Vector<SceneObject*> overlapObjects;
// andrewmac: Physics Collision Flag
if ( mPhysicsRep && mDataBlock->physicsCollision )
mPhysicsRep->findContact( &contactObject, contactNormal, &overlapObjects );
else
_findContact( &contactObject, contactNormal, &overlapObjects );
Con::printf("findcontact checking for objects..."); // THIS ECHO DISPLAYS CONTINUOUSLY
// Check for triggers, corpses and items.
const U32 filterMask = isGhost() ? sClientCollisionContactMask : sServerCollisionContactMask;
for ( U32 i=0; i < overlapObjects.size(); i++ )
{
Con::printf("findcontact looping through objects..."); // NONE OF THESE ECHOES OR THOSE BELOW ARE DISPLAYING IN THE CONSOLE
SceneObject *obj = overlapObjects[i];
U32 objectMask = obj->getTypeMask();
if ( !( objectMask & filterMask ) )
continue;
Con::printf("findcontact found an object...");
// Check: triggers, corpses and items...
//
//Climb Resource - Added this to check for ladders.
if(objectMask & ClimableItemObjectType)
{
Con::printf("findcontact Checking if we are facing item to climb");
MatrixF playerTransform = getRenderTransform();
Point3F start, end, vec;
playerTransform.getColumn(1,&vec); //get the forward vector
playerTransform.getColumn(3,&start); //get the position
end = start + vec; //set the end of the ray
RayInfo rInfo;
//see if we are facing the climable item that we just collided with
if(gClientContainer.castRay(start, end, objectMask & (ClimableItemObjectType | StaticShapeObjectType), &rInfo))
{
if(!mClimbing)
Con::executef(mDataBlock,"onStartClimb",getIdString(), Con::getIntArg(rInfo.object->getId()));
mClimbing = true;
}
else
{
if(mClimbing)
Con::executef(mDataBlock,"onEndClimb",getIdString());
mClimbing = false;
}
}
//Climb Resource
else if (objectMask & TriggerObjectType)
{
Trigger* pTrigger = static_cast<Trigger*>( obj );
pTrigger->potentialEnterObject(this);
}
else if (objectMask & CorpseObjectType)
{
// If we've overlapped the worldbounding boxes, then that's it...
if ( getWorldBox().isOverlapped( obj->getWorldBox() ) )
{
ShapeBase* col = static_cast<ShapeBase*>( obj );
queueCollision(col,getVelocity() - col->getVelocity());
}
}
else if (objectMask & ItemObjectType)
{
// If we've overlapped the worldbounding boxes, then that's it...
Item* item = static_cast<Item*>( obj );
if ( getWorldBox().isOverlapped(item->getWorldBox()) &&
item->getCollisionObject() != this &&
!item->isHidden() )
queueCollision(item,getVelocity() - item->getVelocity());
}
}
F32 vd = (*contactNormal).z;
//*run = vd > mDataBlock->runSurfaceCos;
*run = vd > mDataBlock->runSurfaceCos || mClimbing; //Climb Resource - make sure we can climb climable objects;
*jump = vd > mDataBlock->jumpSurfaceCos;
mContactInfo.clear();
mContactInfo.contacted = contactObject != NULL;
mContactInfo.contactObject = contactObject;
if ( mContactInfo.contacted )
mContactInfo.contactNormal = *contactNormal;
mContactInfo.run = *run;
mContactInfo.jump = *jump;
}Please, any ideas how to fix the code to be PhysX-compatible?
Or anyone have another way of doing climbable stuff in PhysX? I need my player to be able to climb ladders in my game.
Thanks in advance!
P
#180
Still don't know how to use though :P
@Paul
Change:
To:
OR set a breakpoint inside the loop. Basically, check to see if there's any items in overlapObjects.
03/13/2014 (2:33 pm)
I started getting frame drops in everything and ended up tracking it down to Google Chrome. For whatever reason it's just been skyrocketing to 99% CPU usage and killing everything. So, it was just a coincidence.Still don't know how to use though :P
@Paul
Change:
Con::printf("findcontact checking for objects..."); // THIS ECHO DISPLAYS CONTINUOUSLYTo:
Con::printf("findcontact checking for objects... Size: %d", overlapObjects.size()); // THIS ECHO DISPLAYS CONTINUOUSLYOR set a breakpoint inside the loop. Basically, check to see if there's any items in overlapObjects.
Paul Weston
Gambit Realm
Like I said, they function correctly, my issue was that when I jump onto it, the platform shakes and jitters while it moves... I'll keep looking at it.