Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (TedMar), 1,420 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Bug note #28002
05/27/04 07:22
05/27/04 07:22
Joined: Sep 2003
Posts: 3,236
San Diego, CA
M
Marco_Grubert Offline OP
Expert
Marco_Grubert  Offline OP
Expert
M

Joined: Sep 2003
Posts: 3,236
San Diego, CA
I just realized that there is a bug in applying forces/torques to bodies. When phent_addcentralforce() or a similar function is called, the force will only be applied for one physics frame (usually running at 70Hz, i.e. force will last for 1/70th of a second). If the rendering framerate is less than 70Hz additional physics frames will be executed for each rendering frame. E.g. if running at 35 frames render speed for every "wait(1)" two physics frames will be calculated, the first one has user-specified forces/torques, the second one only has gravity and constraint forces.
On slower systems this means that forces appear to have less of an impact on a body's motion. I will change this behavior so that user forces are applied throughout the entire time of a "wait()" statement. Please note that this is likely to break existing code if you explicitely set forces/torques in your script.

Re: Bug note [Re: Marco_Grubert] #28003
05/27/04 08:16
05/27/04 08:16
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
So if I read you correctly, the PE stepsize wasn't tied into the Graphics stepsize hence the problem.
Thus, the Physics Simulation was taking steps at 70Hz irregardless of the simulation clock (render clock), allowing multiple PE steps for every one Graphics step or vice versa, too few Physics steps for every one graphics step (if fps_max=140 for example). Something like this?

If this is the case, is this bug related to our stepsize discussion from before?

Quote:

I will change this behavior so that user forces are applied throughout the entire time of a "wait()" statement.




I would be interested in hearing more details of the solution once the above problem is more fully understood by us "out here".
If the above is the problem, I would suggest a scheme that explicitly ties in the Physics and Graphics clock in discrete intervals. For example, so you can set the PE clock to run twice as fast as teh Graphics clock when accuracy is desired or half as fast if your simulation values performance over accuracy.

Quote:

Please note that this is likely to break existing code if you explicitely set forces/torques in your script.




Marco, I'm guessing that would be EVERYONE using the PE?
Here's looking forward to THAT!

Re: Bug note [Re: fastlane69] #28004
05/27/04 09:18
05/27/04 09:18
Joined: Sep 2003
Posts: 3,236
San Diego, CA
M
Marco_Grubert Offline OP
Expert
Marco_Grubert  Offline OP
Expert
M

Joined: Sep 2003
Posts: 3,236
San Diego, CA
Quote:

Please note that this is likely to break existing code if you explicitely set forces/torques in your script.
-----------------
Marco, I'm guessing that would be EVERYONE using the PE?



Not necessarily; my car script only used gravity and constraints and thus is frame rate independent. (It's when I added jumping to that script that I noticed the bug). So if you only rely on constraints you're fine.

Here's how the system works:
every force/torque manually applied to bodies gets stored in an accumulator to later be executed. Once all current functions have been executed (i.e. terminated or reached a wait() statement) the physics engine is taking over and has as its input the time expired since last update (e.g. 1/35th of a second). It then splits this time into slices of 1/70th seconds (2 in this example). The simulator then applies the stored forces/torques, gravity and calculated constraint forces for each time slice, polygons get rendered and control is returned to C-Script.

Notes: Physics time is sliced to increase stability, and should not be tied to render time. The size of the timeslices is controlled by the variable PH_FPS_MAX_LOCK and defaults to 70 (Hz). Higher values means more stability and CPU time, lower values equals less stability and less CPU usage. In the current A6 release the user force accumulators would get reset to 0 after the first time slice (that's the bug), which means that when your rendering frame rate is 70 Hz or higher you won't notice any problems. If it is less than that, for each render frame multiple physics frames will be executed, but only the first of these has your custom forces, whereas all of them have gravity and constraint forces. In my jump example on a slow system the car would jump up for one frame and then fall down for two. The next A6 release will have custom forces applied throughout the interval, during each time slice as it was meant to be.

Quote:

If the above is the problem, I would suggest a scheme that explicitly ties in the Physics and Graphics clock in discrete intervals. For example, so you can set the PE clock to run twice as fast as teh Graphics clock when accuracy is desired or half as fast if your simulation values performance over accuracy.


You can do that and it has always been like that. Just change PH_FPS_MAX_LOCK. However, when using custom forces the results may be off until the mentioned bugfix has been added.

Re: Bug note [Re: Marco_Grubert] #28005
05/27/04 10:21
05/27/04 10:21
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
I see now. You were resetting the user forces prematurely then. This closer to the truth?
Well at least it's an easy fix on your end.




Quote:

You can do that and it has always been like that. Just change PH_FPS_MAX_LOCK




Dang forgot about that! Out of the manual, out of sight.


Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1