3D Physics with ZgeBullet

Use of external libraries (DLLs) from ZGE.

Moderator: Moderators

User avatar
Ats
Posts: 791
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: 3D Physics with ZgeBullet

Post by Ats »

I have a technical question regarding the update of the bullet simulation.

I always used it like this:

Code: Select all

float t = App.DeltaTime;
zbtStepSimulation(t, 0, 0);
But the documentation is talking about:
@fn void zbtStepSimulation(
float timeStep, int maxSubSteps, float fixedTimeStep)
@brief Proceed the simulation over time step.
@details By default, the @a timeStep is subdivided in constant sub-steps of each
@a fixedTimeStep. In order to keep the simulation real-time, the maximum
number of sub-steps can be clamped to @a maxSubSteps. You can disable
subdividing the time step/sub-stepping by passing @a maxSubSteps=0, but in
that case you have to keep the timeStep constant.
@param timeStep duration of simulation step in seconds
@param maxSubSteps if > 0, it will interpolate motion between fixedTimeStep's
@param fixedTimeStep fixed time step
So I tried this, thinking it would be less demanding than what I used to do:

Code: Select all

// Define a fixed time step for substeps (e.g., 1/60th of a second)
float fixedTimeStep = 1.0f / 60.0f;  // 60Hz

// Calculate the number of substeps needed
int maxSubSteps = (t / fixedTimeStep) + 1;

// Limit maxSubSteps to a reasonable number to avoid performance issues
if (maxSubSteps > 10) maxSubSteps = 10;

// Update the physics simulation
zbtStepSimulation(t, maxSubSteps, fixedTimeStep);
It is working perfectly on PC, but it is utterly broken on Android, leading to random collisions with nothing in the way.
Is there something wrong with what I do, or maybe some technical issue on Android?
User avatar
Ats
Posts: 791
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: 3D Physics with ZgeBullet

Post by Ats »

I tested every setting from rado1's ZGEBullet examples:

Demo 1:
float t = App.DeltaTime;
zbtStepSimulation(t, 0, 0);

Demo 2:
float t = App.DeltaTime;
zbtStepSimulation(t, 3, t/2);

Demo 3:
float t = App.DeltaTime;
zbtStepSimulation(t, 1, t);

Demo 4:
zbtStepSimulation(App.DeltaTime, 0, 0);

zbtStepSimulation(t, 0, 0) is only working on PC. On Android, the plane is passing through walls.
zbtStepSimulation(t, 1, t) works on both systems.

Edit:
Simulation on Android still behave weirdly at times... :?
zbtStepSimulation(t, 1, t*0.5) is working better on Android.
Post Reply