Physics Engine doesn't disengage??

Posted By: fastlane69

Physics Engine doesn't disengage?? - 11/01/03 06:39

I've waited a long time to post this to make sure it wasn't something in my script, so here goes.

In my project, I need to pick up an object which is under the control of the PE. Now, when the object is still (v=0), I can disengage the PE and use ent_move to attach it to me and thus carry it around. I can then issue a THROW command, which re-engages the PE and applies a set force for a set time. Perfect.

HOWEVER, if the object still has a velocity component to it (ie. not still) when I want to pick it up, the PE dis-engages fine, I can ent_move it fine, BUT WHEN I THROW (RE-ENGAGE THE PE) THE OBJECT HAS IT'S VELOCITY FROM WHEN THE ENGINE WAS PREVIOUSLY ON!!!

I first thought that it was because of the skills, since my entities move in response to a net_force skill vector. But that is absolutely not the case, as in that case it would accelerate, not veloci-rate upon re-engagement of the PE.

So it seems to me that while you can turn off the PE, you don't unregister the object and somewhere, it's velocity is stored and thus when the engine is re-engaged, it loads up these old values for velocity and goes from there. This is the same behaiviour if I use phent_settype to "unregister" the entity from the PE or if I use phent_enable to "temp disable" the PE.

Personally, if I'm turning off the engine, I would like at least the option to zero out the velocity, since I have no direct control over it. Otherwise, I'm missing something critical here...

Posted By: SpaceJim

Re: Physics Engine doesn't disengage?? - 11/03/03 01:14

Instead of disengaging the object why not set a constraint to the hand? Initialising physics objects is slow too so this may also provide a performance boost and make things simpler.

Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 11/03/03 03:17

Several reasons. I want to pick up an object and not have that act affect my player. If I set a contraint, then the object is locked into my player physically and I get dynamics I don't want.

By disengaging/unregitering an object, my hope was that I wouldn't be losing processing power to the physics engine since my held object would be just blindly attached to the player by a ent_move command. I feel this actually uses less resources than relying on the PE.

As I've posted, this disengagement approach works perfectly with the exception of residual velocity (or maybe momentum??) at re-engagement.
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 11/05/03 12:33

Wanted to generate a new response to re-emphasize my dilema.

I need to know if this is bug, code, or meant to happen.

PLZ HELP.
Posted By: kopitzki

Re: Physics Engine doesn't disengage?? - 12/02/03 03:16

QUOTE: So it seems to me that while you can turn off the PE, you don't unregister the object and somewhere, it's velocity is stored and thus when the engine is re-engaged, it loads up these old values for velocity and goes from there.

You're right. I've got a PE that constantly orbits around a center. With each frame I turn off/on phent_enable to readjust its pan, and it moves on without the orbiting force renewed. Frankly, the readjusting of the panning doesn't seem to be smooth, despite a high frame rate. Maybe phent_settype ( entity, 0, var hull disengages correctly.

Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 12/02/03 04:51

Thansk freak. I've tried that as well and no go. I thought that since phent_enable just temporeraly disabled and entity that the problem was there. HOwever when I phent_settyped my object to UNREGISTER the object, upon re-registration it's still has it's old velocity.

I think I picked up from somewhere in the manual that once an object is registered with the PE, it's never truly unregistered and thus stays (in memory?) the entire time the prog is running.

Can any more people in the 3DGS community please verify this behaivior on their usage of the PE? If I can get a few more people detailing this problem, I can repost this as a legitamate bug.

Thanks!

Posted By: clone45

Re: Physics Engine doesn't disengage?? - 02/15/04 18:29


I'm running into exactly the same issues. I have a game that's similar to a free kick in to a soccer goal. After a kick, I don't want to have to wait until the ball has completely stopped moving before I reset it on the kicking area. But if I don't wait, once I turn the physics engine on - the ball still has velocity.

It's quite a pain!!
-b
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 02/16/04 02:54

I'm going to focus on this and post this under bugs to get an official response.

Keep an eye out for it so you can post your own experiences there!

Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 02/25/04 09:33

I am replying to this old post because I have the EXACT same problem. The only solution I have found is to unregister and reregister the physics entity which I'd rather not due as I tend to get crashes. If someone from Conitec is reading this I'd like to request that the physics engine have a new function to zero out the forces applied to a physics entity once that entity has been disabled. This way I could apply new forces once the entity was enabled again. I'm going to post this in several appropriate places in hopes of having this issue resolved.
Posted By: Marco_Grubert

Re: Physics Engine doesn't disengage?? - 02/25/04 09:51

Sorry fastlane, I must have missed this post.

Looking at the code I don't see why velocity should still be set. I am deleting all physics parameters associated with the entity, and initalize a brand new one for the second phent_settype call. I still have to double-check that with a script though.
Posted By: Marco_Grubert

Re: Physics Engine doesn't disengage?? - 02/25/04 10:05

No, I just checked it and velocity is not carried over between phent_settype() calls.
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 02/25/04 11:49

Hmmmm....I'll double check my functions and see what I can come up with code-wise.

I'll post back in a few once I rememeber and replicate this behaiviour. Thanks Marco
Posted By: Marco_Grubert

Re: Physics Engine doesn't disengage?? - 02/25/04 12:16

Maybe you have an older version with different behavior. To double-check just write something like
Code:

phent_settype(my, PH_RIGID, PH_SPHERE);
phent_addcentralforce(my,...);
wait(50);
phent_settype(my, 0,0);
wait(50);
phent_settype(my, PH_RIGID, PH_SPHERE);

And see if it still moves.
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 02/25/04 16:58

That's what I had thought my original tests had been, but I'm not 100%.

Will do it exactly as you say and get back to you.
Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 02/26/04 02:08

Okay, what you wrote here was fine. I'm trying to do this:


phent_enable(me,0);
temp.x = cos(my.pan) * force;
temp.y = sin(my.pan) * force;
temp.z = 0;
phent_enable(me,1);
phent_addcentralforce(you,temp);

Now, it seems to work SOMETIMES. But other times it simply won't unless written like this:

wait(1);
phent_settype(me, 0, 0);
temp.x = cos(my.pan) * force;
temp.y = sin(my.pan) * force;
temp.z = 0;
phent_settype(me, PH_RIGID, PH_SPHERE);
phent_addcentralforce(you,temp);

I'd rather not have to totally unregister and reregister as the collison box causes me to crash if I'm touching the entity when it is registered again. Doing this through phent_enable does not cause a crash.

One last observation. If my collision is set to PH_POLY I don't crash as much with the "register/unregister" method.
Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 02/26/04 02:11

Please read my above comments as well but I'm trying to make sure that you know the problem is with phent_enable NOT phent_settype.

phent_enable carries the values over. I just checked it.
Posted By: Marco_Grubert

Re: Physics Engine doesn't disengage?? - 02/27/04 11:48

Quote:


phent_enable(me,0);
temp.x = cos(my.pan) * force;
temp.y = sin(my.pan) * force;
temp.z = 0;
phent_enable(me,1);
phent_addcentralforce(you,temp);
Now, it seems to work SOMETIMES. But other times it simply won't unless written like this:



The above code retains the object's velocity past the phent_enable() calls. A disabled entity is excluded from having its position or velocity change over time. It is not unregistered or reset by that call.

Quote:


wait(1);
phent_settype(me, 0, 0);
temp.x = cos(my.pan) * force;
temp.y = sin(my.pan) * force;
temp.z = 0;
phent_settype(me, PH_RIGID, PH_SPHERE);
phent_addcentralforce(you,temp);



In this example you can think of the first me and the second me (or you due to the typo) as being 2 separate objects that have nothing to do with each other.
What do you want to achieve? If it's just setting the velocity to 0 you could call phent_setmaxspeed(me,0,0) and wait one time unit (== 1.0/PH_FPS_MAX_LOCK)
Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 02/27/04 13:41

Yes, I'm sorry. It was a typo. Here is an explination of my exact situation. I have a space vehicle and a ball. The vehicle touches the ball and disables the physics on the ball using phent_enable because I move the ball around with the vehicle using ent_move. While the vehicle (in this case the player) is flying around with the ball the player may fire the ball. When the player fires the ball I re-enable the ball by using phent_enable and something like the following code to "fire" the ball in the proper direction in relation to the player:

var force[3];

force = 100000;

me = pPlayer;
you = pBall;

phent_enable(you,1);

temp.x = cos(my.pan) * force;
temp.y = sin(my.pan) * force;
temp.z = 0;

phent_addcentralforce(you,temp);

I have noticed that the lower the force variable is set, the less accurate the results. I'm looking for speed as firing can be instant and waiting allows the player to bump back into the ball never releasing it. I've tried your phent_setmaxspeed suggestion and it stops the entity but still doesn't solve the problem. I'd like to be able to manually set the velocities to zero as opposed to waiting until a limit is reached. This way when the player picks up the ball I could set the velocities to zero and change them accuratly during the firing function.
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 02/27/04 14:03

Quote:



phent_enable(me,0);
temp.x = cos(my.pan) * force;
temp.y = sin(my.pan) * force;
temp.z = 0;
phent_enable(me,1);
phent_addcentralforce(you,temp);
Now, it seems to work SOMETIMES. But other times it simply won't unless written like this:


--------------------------------------------------------------------------------


The above code retains the object's velocity past the phent_enable() calls. A disabled entity is excluded from having its position or velocity change over time. It is not unregistered or reset by that call.




First off, YES!!!! Finally recognition that I"m NOT nuts!!!

Secondly, just to make sure, this is expected behaiviour and not a bug?

If its not a bug, then what I takeaway from this is:

1)phent_enable is a PE pause button; it's still "engaged" to the PE (as per your "doesn't change velocity..." statement) while I can use phent_settype calls to actually disengage the engine and thus reset my entity.

2)Even within phent_enable, I can use the velocity govenor (phent_setmaxspeed()) as a way to trick my PE into setting my velocity to 0. This is sneaky...hadn't thought of it..


Finally, this could mean something, Ipro i'm doing the EXACT SAME THING....I'm disengagin my PE so I can move my ball around and then reengaging only when the player Throws the ball!!!!
Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 02/28/04 02:24

I almost missed what Marco_Grubert said and it confirms the phent_enable behavior. Here's what he wrote above:

Quote:


A disabled entity is excluded from having its position or velocity change over time. It is not unregistered or reset by that call.





I believe a new function to change the velocity while an entity is disabled would be nice as phent_settype is slow and will crash if the collision sphere of my physics ball is turned on while it is touching the player ship.
Posted By: Marco_Grubert

Re: Physics Engine doesn't disengage?? - 02/28/04 06:57

Quote:

First off, YES!!!! Finally recognition that I"m NOT nuts!!!
Secondly, just to make sure, this is expected behaiviour and not a bug?



Yes it is expected behavior. phent_enable() is basically just setting a flag putting the object into pause mode- thus it's extremely fast to execute.

I thought you were referring to phent_settype() earlier (which does perform a reset but is slow).

Quote:

2)Even within phent_enable, I can use the velocity govenor (phent_setmaxspeed()) as a way to trick my PE into setting my velocity to 0. This is sneaky...hadn't thought of it..



It is sneaky and not as straight-forward as something like a setvelocity() call would be. I am very concerned that setting velocity directly might screw things up easily. But adding a clearvelocity() function could be a useful additions..or not?
Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 02/28/04 11:27

A clearvelocity() function sounds great!!!

Then I could do something like:

var force[3];

force = 100000;

me = pPlayer;
you = pBall;

clearvelocity(you); //new clear velocity function

phent_enable(you,1);

temp.x = cos(my.pan) * force;
temp.y = sin(my.pan) * force;
temp.z = 0;

phent_addcentralforce(you,temp);
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 02/28/04 11:56

I think that would be GREAT Marco, though if it's going to do nothing diffrent than the velocity governor can do, then I'd stick to an addendum in the manual under phent_setmaxvelocity and perhaps optimize phent_setmaxvel so that on a 0,0,0 parameter pass, it acts like the clear velocity.

What advantages, if any, would there be to a separate call to clear velocity? Maybe a complete kinematic wipe on an entity would be better, with velocity and force set to zero? That could be handy and if you only want vel zeroed, you'd use the governor or if you just want the force zeroed, you'd use a phent_addforce(null) call.

On another note, you said:
Quote:

which does perform a reset but is slow




Slow, huh? In order to completely reset a entities PE record (velocity and force and what else?), how many server frames should I give it? Right now I just have it under a wait(1) command.
Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 02/29/04 03:22

I don't know what code is under the hood but I think altering phent_setmaxvel may cause problems as it's used to stop the entity after it's reached a certain velocity. Altering it the way you suggest would change it's behavior for paramaters of 0,0,0 only and I'm not sure that's such a good idea. It would probably be easier and cleaner to add different behaviors via new functions as opposed to altering existing ones.

Regardless of what code is "under the hood" I think we are both interested in a quick function that simply resets the variables to zero WITHOUT unregistering the entity. This way when we apply forces via phent_addvelocity we will know there are no existing forces already there. Is my assumption correct, because clearvelocity() definatly sounds like what I need.
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 02/29/04 04:04

Spot on Ipro. That's all I think we need, something to clear out all relavant forces and velocities and thus giving a clean slate for a PE without the need to disengage.
Posted By: iprogramgames

Re: Physics Engine doesn't disengage?? - 03/01/04 06:44

Agreed
Posted By: Marco_Grubert

Re: Physics Engine doesn't disengage?? - 03/02/04 06:34

phent_clearvelocity() should be in the next update.
Posted By: fastlane69

Re: Physics Engine doesn't disengage?? - 03/02/04 10:09

schwwweeeeet!
Thanks!

Posted By: iprogramgames2

Re: Physics Engine doesn't disengage?? - 09/09/04 01:27

1. Has our "phent_clearvelocity()" function been added yet. I've been waiting a long time

2. Marco. I need my original forum account's email address reset so I can get my lost password. I've sent several emails that were supposed to be forworded to you. Have they made it?

Al Tucker
Posted By: iprogramgames2

Re: Physics Engine doesn't disengage?? - 09/21/04 13:21

Eh, hem... Anyone there to answer my question above? I've been patient.
© 2024 lite-C Forums