• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
sobeit

Help with box stacking instability

7 posts in this topic

Hi, I'm trying to implement my own physics simulation, but get stuck on jittering problem even if I only put one box on the infinite plane. I use sequential impulse to solve contact constraint, and I also add some penetration slop.

 

after some debugging I found out that when the box is resting on the infinite plane the collision point isn't exactly the center of the contact surface of the box, about 1e-8 error grade off the center.  And that is generating some rotation impulse which I think is the problem (if I comment out the application of rotation impulse, the box would rest still). How can I solve this? I don't think I can further improve collision point accuracy it's the numerical limit of floating point. and I haven't implemented contact caching. 

 

Thanks in advance.

0

Share this post


Link to post
Share on other sites

You should try using 2 contact points, not just one. You'll also want to have some penetration tolerance instead of trying to achieve exactly zero penetration. You should also verify your own code against Box2D Lite (not recent Box2D, but the Lite version). This version only has OBBs and accomplishes what you are trying to achieve.

0

Share this post


Link to post
Share on other sites
Thank you for the reply.

You should try using 2 contact points, not just one.

I work in 3d, I'm not sure how to generate more than one contact point, maybe using some convex shape clipping algorithm? But as far as what I searched on the internet, it seems finding the deepest penetrating point is enough. maybe I miss something.

You'll also want to have some penetration tolerance instead of trying to achieve exactly zero penetration.

Yes, I've already added the tolerance

You should also verify your own code against Box2D Lite (not recent Box2D, but the Lite version)

Thanks for the suggestion. I actually followed Erin's 09 GDC talk, I will download that and try to find out what I did wrong.
 

one more question. If I do contact caching, how would I use the cached contact points? find the average of them? 

Edited by sobeit
0

Share this post


Link to post
Share on other sites

You can look at dBoxBox() in the ODE to find an example of a clipping algorithm. In a nutshell you find the axis of minimum penetration using e.g. SAT. I gave a presentation how to do this here: https://box2d.googlecode.com/files/DGregorius_GDC2013.zip. The axis of minimum penetration defines the reference face. Then you find the most anti-parallel face on the other shape. This defines the incident face. Finally you clip the incident face against the side planes of the reference face and keep all contact points below the reference face. You could also clip against the reference face, but those additional contact points don't add stability to the manifold from my experience.

 

Clipping can create more than four points, so you usually need to reduce the manifold. There is a good description how this can be achieved in GPG 4 by Pierre Terdiman and Adam Moravansky (both PhysX).

 

But as far as what I searched on the internet, it seems finding the deepest penetrating point is enough. maybe I miss something.

 

You can basically use incremental manifolds or full manifolds. Incremental manifolds were popular in earlier days, because they are easy to implement and relatively fast. Modern engines (e.g. also commercial ones) use full manifolds these days. This is not only for stacking stability. When you build an incremental manifold you need four frames to build a stable manifold. A manifold is stable if the mass centers project inside of it. You can see that even for a simple box on a plane you can get a manifold where the mass center projects onto an edge and the shape can rotate through the ground. This is the major issue with contact manifolds. From my experience objects don't fall out of the world because of high linear velocity as shown in text books. This is actually a trivial problem, but real world problems are much more subtle. 

Edited by Dirk Gregorius
0

Share this post


Link to post
Share on other sites

Thanks Dirk, that's really helpful.

do you know where I can find more information on this topic, especially discussion about stability? books or websites?

Edited by sobeit
0

Share this post


Link to post
Share on other sites

You can look at *all* presentations of Erin Catto and also at Box2D / Box2D Lite. You can find everything in the downloads section here: www.box2d.org

I gave GDC presentations about SAT and Quickhull which can be found there as well.

I have written a lot about these topics in public forums so searching for e.g. manifold, SAT, contact, clipping either here or in the Bullet forum might create some helpful results as well. The ODE mailing list archives might have also some useful stuff. 

 

Finally, Randy might have some links to some relevant discussions and can share them here.. 

Edited by Dirk Gregorius
0

Share this post


Link to post
Share on other sites

dBoxBox is a perfect place to figure out how to generate all the contact points. The code is hard to read so I wrote an article about it (see below). The trick for making contact points is to transform both OBBs into the model space of one of them. If you understand this all then you can greatly simplify the face clipping. This should all be in the ODE. Another place with an easier to read OBB to OBB manifold creation is in Ian Millington's Cyclone physics engine. There are like 4 or 5 different smaller easy to read functions that gather up the contact points. IIRC I don't think he did any clipping optimizations and does calculation in world space.

 

If you want stability then you'll just want to read Erin's stuff on solving constraints. Stability is largely about solving a system of equations, assuming you have proper collision detection. If you run sequential impulses on all the contact points you should have pretty good stability for starting out. You probably won't need to do manifold reduction immediately (reducing from a large number of contact points to only a few of the more preferable contact points), and can implement this later if needed.

 

For generating the contact points and doing collision detection for OBBs I wrote an article about this: http://www.randygaul.net/2014/05/22/deriving-obb-to-obb-intersection-sat/

 

But really if you don't understand the impulse solving and how to make it stable you should start with Box2D Lite and make sure you understand the contact caching, warm starting, and the contact constraint. Then, if you can write this code yourself and do the math, it will make sense when you try to do things in 3D. If you want to make sure you really understand the math you can take this naive solver here: https://github.com/RandyGaul/ImpulseEngine and convert it to use sequential impulses. It can be noted that the equations being solved are actually identical between the naive implementation and Erin's Box2D, but how they are solved (iteratively with solution caching, or naively) makes a big difference.

0

Share this post


Link to post
Share on other sites

Dirk and Randy, thank you for the information, I think that's enough to get me started.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0