SlowMotion problem

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

SlowMotion problem

Postby FSA » Sun May 26, 2013 12:34 pm

Hey.
I update Newton as following:
Code: Select all
static bool bNewtonTime = false;
   const float MAX_PHYSICS_FPS = 120.0f;
   const int MAX_PHYSICS_LOOPS = 1;

   if(m_bPhysicOn)
   {
      static long long m_microsecunds = 0;
      
      if(!bNewtonTime)
      {
         bNewtonTime = true;
         m_microsecunds = GetTimeInMicroSeconds();
      }

      float timestepInSecunds = 1.0f / MAX_PHYSICS_FPS;
      long long timestepMicrosecunds = long long (timestepInSecunds * 1000000.0f);

      long long currentTime = GetTimeInMicroSeconds();
      long long nextTime = currentTime - m_microsecunds;
      int loops = 0;

      while ((nextTime >= timestepMicrosecunds) && (loops < MAX_PHYSICS_LOOPS))
      {
         loops ++;
      
         m_pPhysicHandler->Update(m_pPhysicWorld, timestepInSecunds);
            
         nextTime -= timestepMicrosecunds;
         m_microsecunds += timestepMicrosecunds;
      }

      if (loops) {
         float m_physicsTime = dFloat (GetTimeInMicroSeconds () - currentTime) / 1000000.0f;

         if (m_physicsTime >= MAX_PHYSICS_LOOPS * (1.0f / MAX_PHYSICS_FPS)) {
            m_microsecunds = currentTime;
         }
      }
   }
   else
      bNewtonTime = false;

That is the same code like in the sandbox demos.
But for some reasons everything is in slow motion. My gravity is -10. My framerate about 130. What's the problem?
Thank you :)
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: SlowMotion problem

Postby Julio Jerez » Sun May 26, 2013 12:51 pm

if you have very big objects, you world look like is moving in slow motion. It is an optical illusion.
can you show a video?

you can ttest that by making to boxes, one 1 x 1 x 1, and one 0.25 x 0.25 x 0.25 and let then drop for the same high

you will see that the both reach the ground at the same time with the same speed, however the big box will look like Is moving in slow motion
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SlowMotion problem

Postby FSA » Sun May 26, 2013 12:57 pm

I will make a video later. My box is 3x3x1.
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: SlowMotion problem

Postby FSA » Sun May 26, 2013 1:19 pm

Another question: If I have a unnit where 1 meter = 8 units is, how can I perform stable physics? At first gravity is -80. But when I do this, I have to much momentum and forces.
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: SlowMotion problem

Postby JoeJ » Sun May 26, 2013 4:03 pm

I worked with the same scale for a year (1 meter = 10 units).
I don't remember what values i've used, but i maybe it was -50 for gravity and a time scale of 2.
(Yes you can scale the timestep, but there are some defines in newton preventing you to use large or small factors)
There never where problems using that world scale for me, but i ended up tining that stuff by look and feel.

It may be the best option to scale your world down to the recommended 1 meter = 1 unit.
Life's easier then. You can use -9.81 gravity and simulation runs as expected.
Floating point precission may be best.
Some constants elsewhere (joints) work out of the box.
You can exchange assets, cause most people work with that scale, etc...
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: SlowMotion problem

Postby Julio Jerez » Sun May 26, 2013 5:20 pm

letter123 wrote:Another question: If I have a unnit where 1 meter = 8 units is, how can I perform stable physics?


this is why Newton 300 supports scale on all shapes. you can make your collison shape on the same size of the visual meshes, and you can pass a scale of 1.0/8.0 to make them meters.
then you leave gravity as it should and every else will work according to the Meter, Kilograms Secund international system of scale.

Bascially internally the physics world will be smaller than the visual world. Let say when a box travel 1 unit in the system you have not, it looks like one unit visually.
after you ste scale to all shape by 1/8, when a box travelling one unit in the physics world, it will looks 8 time faster in the visual world.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SlowMotion problem

Postby FSA » Mon May 27, 2013 3:33 pm

Sorry I must solve another problem before I can get back to this. :) Video will come when I'm back on this.
User avatar
FSA
 
Posts: 322
Joined: Wed Dec 21, 2011 9:47 am

Re: SlowMotion problem

Postby JoeJ » Mon May 27, 2013 4:16 pm

Julio Jerez wrote:this is why Newton 300 supports scale on all shapes


Is this feature free or is there a small runtime performance cost?

How is it with uniform vs. non-uniform scaling.
I guess it does not matter for polyhedra, but it should matter a lot for spherical shapes?

Which is faster: Collinding a box against poly enviroment, or colliding a ellipsoid agianst poly enviroment?
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: SlowMotion problem

Postby Julio Jerez » Mon May 27, 2013 4:54 pm

there is not cost for The uniform scale on any object. There is a minor cost for non uniform scale on some shapes. but this cost is much lower that in core 200 were we have a full 4 x 4 scale matrix that supported shears, and skew matrices.
Now the matrix is always PSD which mean is always diagnosable as the product of two orthonormal and one diagonal matrix, which mean is very easy to invert by inverting the components separate.

Sphere, capsules, tapered capsule and chamfered cylinders of any scale against any other shape are the fastest collisions, they followed by Box, Convex Hulls, and the slowest are Cylinder, Tapered cylinders and cones.
Polygonal shape and compound has a linear cost, meaning they are proportional to the number of sub shapes faces that collide with the other shape.

I am try to figure out if I can find a close form solution for cylinder, but so far all my attend had failed, therefore Cylinders and all the derived shapes, remains expensive to collide with.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SlowMotion problem

Postby JoeJ » Mon May 27, 2013 5:44 pm

Julio Jerez wrote:Sphere, capsules, Tapered cylinders and chamfered cylinders of any scale against any other shape are the fastest collisions, they followed by Box, Convex Hulls, and the slowest are Cylinder, Tapered cylinders and cones.
Polygonal shape and compound has a linear cost, meaning they are proportional to the number of sub shapes faces that collide with the other shape.


There must be some mistake? Forms of cylinders are listed an the fast and the slow side, and TaperedCapsule is missing.
TaperedCapsule is interesting, could become a nice approx for body parts.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: SlowMotion problem

Postby Julio Jerez » Mon May 27, 2013 7:50 pm

Oh yes I edited the post. I mean tapered Capsule not tapered cylinders

Yes tapered capsules are one step more for approximation human limbs better than capsule, and they are just as fast as capsule.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: SlowMotion problem

Postby JoeJ » Tue May 28, 2013 3:30 am

... good to know :)
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests