Jump to content

Physics Drag?


Michael_J
 Share

Recommended Posts

From the testing I've done over the past couple of days, it seems that if I apply a force to an object that does not use gravity (regardless of the friction value) the object will eventually come to a stop.

 

My only conclusion is that there is a global drag or other resistance occurring that is causing this (or some other form of forced restitution perhaps?). If this is the case is there any way to change this on either a global or per-object level (per-object preferably)?

 

In the environment I'm working in (space) once an object is in motion it should remain in motion until something interferes with it, of course. Hence, I need to alter this behavior...

 

Thanks...

  • Upvote 1

--"There is no spoon"

Link to comment
Share on other sites

I did this a while back for a projectile and I'm pretty sure it works like you need, it might help ya...

 

This is called when the entity is created

 

Shape *shape = Shape::Box(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.3F,0.3F, 0.3F);
entity->SetShape(shape);
shape->Release();
entity->SetPhysicsMode(Entity::RigidBodyPhysics);
entity->SetMass(1);
entity->SetCollisionType(Collision::Trigger);
entity->SetGravityMode(0);
entity->AddForce(GetProjectileVelocity());

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

I remember back in the day someone was having physics issues with a miniature golf game they were doing. Not sure if it's strictly related or if it was solved but may be worth a search.

 

Edit: come to think of it I think it was that the golf ball stopped instantly on hitting a wall. Probably not related.

Link to comment
Share on other sites

In the environment I'm working in (space) once an object is in motion it should remain in motion until something interferes with it, of course. Hence, I need to alter this behavior...

 

 

AddForce will add a force and the objects will finish to stop after some time.

SetVelocity : the object will move at constant speed , it's what i use for bullets : No gravity, a mass , and SetVelocity

 

What do you need ? object always moving in space , even without any force applied ?

If that you'll have to code it yourself like :

- detect object velocity

- if very slow velocity or 0 almot velocity : apply some rotating or moving continuous small forces to simulate space

For example :

SetOmega() : to make it turns slowly and constantly in space

Stop toying and make games

Link to comment
Share on other sites

Ok I just did a quick test myself. You are right Michael, over time with SetVelocity() the entity does slow down indeed.

 

I had Friction = 0, Mass = 1, Gravity Mode = 0.

 

Is it possible its a bug? Maybe it behaved the way I expedted the last time I used the function in an earlier build?

 

Anyway Calling SetVelocity() every update does work.

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

  • 5 months later...
  • 4 weeks later...

All computer physics simulations use a small amount of linear and angular damping. The reason for this is that floating point calculations are never 100% precise. Each frame they will be slightly too much or slightly too little. The worst situation is when they consistently get to be more and more energetic each frame, because it can accumulate and cause explosive creation of energy. Damping ensures that the calculations are always on the conservative side, and it also acts as an approximation of friction. Of course in a perfect frictionless vacuum this can cause behavior that was not intended.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Yeah, I figured that's what was going on. Out of curiosity, I believe Newton allows for collision detection without updating physics (using this thread as a basis for this assumption: http://newtondynamics.com/forum/viewtopic.php?f=9&t=4475&p=36406&hilit=+collision+only+#p36406).

 

Is this possible via Leadwerks integration? I mean I know I could set my on collision responses with type trigger and use the callback; but does this cause only the collision to be updated via NewtonCollisionUpdate() instead of calling NewtonUpdate() (which updates collision AND physics)? If not, could a bool flag for "collisions only" be added to Leadwerks::World?

 

http://newtondynamics.com/wiki/index.php5?title=NewtonCollisionUpdate From remarks: "

  • This function shall be used ONLY when Newton is used as a standalone collision library. Use NewtonUpdate if you are also using rigid body dynamics"

 

Thanks...

--"There is no spoon"

Link to comment
Share on other sites

If you can dive into C++, you can do anything Newton supports. However, I wonder if lessening the angular and linear damping might be enough. That's certainly easier than creating your own physics simulation. There presently are not Leadwerks commands for this, but it's just two Newton commands to call.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...