Sphere Physics Problem

Posted By: Locoweed

Sphere Physics Problem - 06/04/05 02:55

Has anyone had problems with pushing a ball into a corner and it going through walls in the corner?

EDIT: Nevermind, I figured it out, the sphere model must not be centered in MED vertically. If the bottom of the sphere is on the center mark it doesn't happen.

EDIT2: Actually I didn't figure it out. So the question still stands.

Here is an example of what I am talking about. If you get the sphere forced into the corner it goes through WED walls. I am guessing it has to do with the sphere model, but I am not sure. It seems that anytime that a continuous force is applied by the player on the sphere phent object it will eventually go through the level geometry when it's trapped.

Thanks for any help,
Loco
Posted By: fastlane69

Re: Sphere Physics Problem - 06/04/05 06:27

Quote:

It seems that anytime that a continuous force is applied by the player on the sphere phent object it will eventually go through the level geometry when it's trapped.





Have you tried this with a cube phent object? Could be inherit to the system. If so we could tweak some physics parameters and try to minimize it.
Posted By: Superjeu3D

Re: Sphere Physics Problem - 06/04/05 13:31

Locoweed hello, I do not manage to open your file zip, I have an error message thus I will try to answer you without your example. I had also this problem with a physical object in cylinder I changed some parameters for phent _ and that functioned very well thereafter. That is all that I can say to you...

@+
Posted By: Locoweed

Re: Sphere Physics Problem - 06/04/05 17:24

Hi,

@ fastlane, No I don't seem to have these problems with cube phent objects.

@ Superjeu3D, I did re-upload the file incase it was corrupt.

I can minimize the problem to a degree. In the example I just uploaded again it is quite hard to make the ball go the level gemetry, but still possible if you get it trapped right.

Here's the basic code that pertains to the phent sphere if you still can't unzip the file for some reason. In WED the phent sphere's skills set to Mass = 30, friction = 75, bounciness = 75, bounce min speed = 5, and no_polygon = on.
These can of course be played around with from WED.

Code:
  
// some entity skills and flags
define group_id, skill2;
define mass, skill3;
define friction, skill4;
define bounciness, skill5;
define Bounce_Min_Speed, skill6;

define NO_POLYGON,flag7;

var earthgravity[3] = 0,0, -250;


function Main()
{
ph_setgravity( earthgravity );
.
}

// uses group_id
// uses Mass
// uses Friction
// uses Bounciness
// uses Bounce_Min_Speed
// uses NO_POLYGON
action PhentSphere
{
// set polygon collision on if flag says so
if(my.NO_POLYGON == OFF)
{
my.polygon = on;
}

// if entity has a phent group ID set it
if(my.GROUP_ID != 0)
{
phent_setgroup( my, my.GROUP_ID);
}

my.dynamic = on;
phent_settype(my, PH_RIGID, PH_SPHERE); // sets the object within the physics engine
phent_setmass(my, my.mass, PH_SPHERE);
phent_setfriction(my,my.friction);
phent_setelasticity(my, my.bounciness, my.bounce_min_speed);
phent_enable(my, ON); // enable the phent enitity

}




I am also using c_move(), which shouldn't matter, but might.
Let me know if you see anything wrong in the code.

Thanks,
Loco
Posted By: fastlane69

Re: Sphere Physics Problem - 06/04/05 19:17

Tweak these settings...see if it helps or hinders....

Quote:

ph_iterations
The higher the value set to PH_ITERATIONS, the more accurate the solution will be (= less jittering) but calculations will also take longer. Try values in the range of 5 to 50.






Quote:

ph_setcorrections (var ERP, var CFM);
Sets global correction factors for the physis simulation. ERP stands for Error Reduction Parameter and defines how quickly misaligned constraints get adjusted. Setting ERP to 0 will have constrained objects drift apart after some time because errors get not corrected. With ERP set to its maximum value any constrained objects that get forced into an unacceptable position/orientation will be corrected within a single frame. This however can cause overshooting and it is thus recommended to use smaller values instead. Constraint Force Mixing on the other hand determines how much a constraint is allowed to be violated. Setting CFM to 0 results in very stiff joints (this will lead to errors though- do not do it). Setting CFM to its maximum value makes constrained objects act as though limited by rubber bands.





Jittering and overshooting are two likely culprits for the behaivior you are seeing. In effect what is happening is that for a frame, the calculation puts the object where it doesn't belong (say past the wall). If this is not corrected by the next frame, then the contact force of having an object embedded in another will cause explosions or the PE it will simply think that it is alright and calculate the next step, possibly sending it deeper into the wall and excacerbating the problem.
Posted By: Locoweed

Re: Sphere Physics Problem - 06/04/05 22:06

Thanks fastlane69,

I will play around with those settings and see what happens. It definately may solve the problem.

I was also thinking that since the example is running at around 200fps, that I might need to sychronize the physics fps with the actual fps somehow. It was a thought that popped into my head. I haven't looked into that yet.

Loco
Posted By: fastlane69

Re: Sphere Physics Problem - 06/04/05 22:12

200 fps? Wow no wonder.

Yeah, lock that bad boy at no more than 100...even less if you can get away with it.

Also read Marco's sticky in this Physics Forum. He talks a little about fps rates as they pertain to the PE.
Posted By: Locoweed

Re: Sphere Physics Problem - 06/04/05 22:17

Hehe,

Thanks for the help. It's going to be probably end up being a timing issue then. I didn't see some of these problems with larger projects, thus lower fps, so thats probably it.

Thanks again for professing the obvious to the unprofessed (don't look that up in the dictionary) .
Loco
Posted By: Marco_Grubert

Re: Sphere Physics Problem - 06/06/05 22:50

Going through walls, or "tunneling" happens for two reasons:
a) the object is moving too fast and located on one side of the wall in frame N and on the other side in frame N+1
b) the object's center is allowed to penetrate the wall and then gets pushed out on the other side

For (a) lower PH_CHECK_DISTANCE, increase PH_FPS_MAX
For (b) modify ph_setcorrections, increase PH_FPS_MAX

In either case be sure to read the stickies and search this forum.
Posted By: Locoweed

Re: Sphere Physics Problem - 06/07/05 02:44

Thanks Marco
Posted By: Anonymous

Re: Sphere Physics Problem - 06/07/05 03:50

I had this problem making my 3d pool game but since I was using spheres, which are all points equidistant from the center, there are ways around this. I got perfect collision detection just by calculating the distance from one sphere to another and when they were 2*radius away, then I would allow a collision to take place, using scan_entity will also work as that can use a spherical "hull" to calculate how far another object is.
Posted By: Anonymous

Re: Sphere Physics Problem - 06/07/05 03:51

By the way, I don't think the human eye can even see any framerates higher than 70 fps...
Posted By: Marco_Grubert

Re: Sphere Physics Problem - 06/08/05 19:40

Quote:

By the way, I don't think the human eye can even see any framerates higher than 70 fps...


Studies have shown that in a few cases (military fighter pilots) perception at a speed of up to 350 fps is possible. The norm is of course much lower than that. The lower limit is in the 20-25 fps range below which animation appears choppy.
© 2024 lite-C Forums