About Store Forum Documentation Contact



Post Reply 
Physics stuttering...
Author Message
Fluxor Offline
Member

Post: #1
Physics stuttering...
When moving an object via actor.force/impulse/torque etc
I get some regular "stuttering" when running the project.

It looks like the mesh and the actor matrix get out of sync or something
but I don't know if that's really the problem and how to fix this.

I can remember I had this problem in some other engine some time ago too,
but I have no clue how to approach this problem.

Basically, a ball moves smoothly for a second or two, then it has a short "hickup" and
starts to stutter for maybe not even half a second, then smooth movement again, etc.

Any idea what that might be?

Thanks,
tL.



The rough code looks something like this, maybe I did something wrong here?:

Code:
void RBall::create(Object &obj)
{
   scale = obj.scale3();
   mesh = obj.mesh();
   phys = obj.phys();
   _matrix = obj.matrixFinal().normalize();
   _scaledMatrix = _matrix;
   _scaledMatrix.scaleOrnL(scale);
  
if(phys)
   {
      actor.create(*phys, 1, true).matrix(_matrix);
      actor.obj(this);
   }
}


Bool Ball::update()
{
   if(Kb.b(KB_W)) actor.addTorque(Vec(-speed, 0, 0));
   if(Kb.b(KB_S)) actor.addTorque(Vec(speed, 0, 0));
   if(Kb.b(KB_A)) actor.addTorque(Vec(0, 0, speed));
   if(Kb.b(KB_D)) actor.addTorque(Vec(0, 0, -speed));  
   T.pos(actor.matrix().pos);
return 1;

// T.pos --> virtual void pos (C Vec &pos) {_matrix.pos = pos; _scaledMatrix.pos = pos;} //
  
}

UInt Ball::drawPrepare()
{
   actor.draw();
   if(mesh) mesh->draw(actor.matrix());    
   return 1;
}

void RBall::drawShadow()
{
   if(mesh) mesh->drawShadow(actor.matrix());
}




EDIT:
Ok, just tested some more things.


The stutter jitter happens when Physics.stepTime / Physics.updatedTime
change from 0.017 to 0.016 on PHYS_TIMESTEP_ROUND which otherwise has a constant value of 0.017 when logged.

The problem gets much better when I use PHYS_TIMESTEP_VARIABLE,
which constantly changes between 0.017 and 0.016 but I still get these stutters.
But by far not so often/regularly.

Is there anything else I could try?
(This post was last modified: 08-21-2021 08:25 PM by Fluxor.)
08-21-2021 07:54 PM
Find all posts by this user Quote this message in a reply
Post Reply