Jump to content

  • Log In with Google      Sign In   
  • Create Account

Irlan Robson

Member Since 08 May 2012
Offline Last Active Today, 03:01 PM

#5302187 What Brings About Linear Complementarity Problem In Rigid Body Dynamics?

Posted by Irlan Robson on 23 July 2016 - 11:44 AM

I should have not posted that paper as Baraff solves for forces globally, sorry. You don't need to relate to force using the SI/PGS if you want.


Thus, the relationship between a force F and an impulse P is simply: P = integral( F dt ) from t1-t2 or P = m * ( v(t2) - v(t1) ) or P ~= F * dt, that is, the change in velocity. 


Kenny Erleben PhD thesis talks about the e/in-equalities your asking.

#5301874 What Brings About Linear Complementarity Problem In Rigid Body Dynamics?

Posted by Irlan Robson on 21 July 2016 - 10:53 PM

No, it means by linearizing an LCP you don't account for vanishing contact points, giving birth to an unplausable and unrealistic simulation.


http://www.cs.cmu.edu/~baraff/papers/sig89.pdf. 227, Section 5.3. (Warning: Predated literature. Still good and valid though.)


In addition, local/iterative solvers and integrators linearize or skip over non-linearities present in some constraints or forces (e.g. "quadratic" friction, air resistency, etc.) but still give sufficient results for the purpose of game physics. They can handle redundant solutions very nicely as well (e.g. a table with 4 legs on a plane).

#5301029 Dx11 Renderstate

Posted by Irlan Robson on 16 July 2016 - 07:18 PM

This might help: 



#5294392 BATMA - tire physics model [Issues]

Posted by Irlan Robson on 31 May 2016 - 08:03 PM

Here're some resources that might help:


1. http://box2d.org/files/GDC2011/GDC2011_Catto_Erin_Soft_Constraints.pdf

2. http://box2d.org/downloads/. Check Dirk's SAT and Contact Creation talks and Erin's talks on GJK. Try to implement them by yourself. 

#5292140 Box 2d Normal Vector for the surface of impact?

Posted by Irlan Robson on 17 May 2016 - 02:13 PM

1. Yes, and generally that would be the normal vector for every physics engine. However, it may be inverted if the wall is not treated as the first object in a collision internally. This is solved by flipping the normal. IIRC in B2D it can be acessed by requesting a world manifold from a contact.


2. Yes, a world has an interface for ray casts and AABB queries, and the former returns the surface normal if the ray/segment hits your vertical wall.

#5289273 Lagrange multiplier in constrained dynamics

Posted by Irlan Robson on 29 April 2016 - 11:37 AM

I haven't watched that video completely, but I see that it follows Baraff's literature to solve for constraint *forces* (impulses / time_step). He uses essentially the same method as found in the constraint-based literature for non-penetration constraints using the LCP formulation. However, he uses quadratic programming (a global solver) to solve for the multipliers.


As Dirk said, you'll need to define your gradients (normals from the SAT for the collision case), each of which will be inserted into a Jacobian matrix for a general constraint-based system. From there you compute the lagrange multipliers as showed in Catto's slides. I think it is important to understand constraints geometrically when implementing these things. So yeah, we do look for a collision normal and point and only then we can find the force magnitude by relating it to the impulse-momentum law in Euler form and then we find the new relative velocities of each body after the collision/contact. 


BTW, different authors use the term impulse and force interchangeble, but assuming the force is constant during the time step then impulse = force * time_step. Therefore the lagrange multipliers both refer to the same thing.


(Do not take this too theoretical but here is an example without using Catto's simplification to solve for the multipliers (impulses) for a distance constraint.)

#5288982 Lagrange multiplier in constrained dynamics

Posted by Irlan Robson on 27 April 2016 - 02:16 PM

Yeah, agree with Álvaro, he's mathematically wrong. He meant minimizing C towards zero for his equality (although that is wrong either; he meant keeping the constraint between the constraint bounds). 

#5288898 Lagrange multiplier in constrained dynamics

Posted by Irlan Robson on 27 April 2016 - 05:38 AM

In a velocity-based formulation the Lagrangian multiplier is the magnitude of a constraint impulse, whereas in a acceleration-based formulation is the magnitude of a constraint-force. It is required to put the constraint into a valid state. Having the constraint configuration defined, it shouldn't be difficult to solve for it currently.


I don't understand what is the second question though. For example, an equality constraint (e.g. distance, ball-in-socket, or a revolute joint) is satisfied for C = 0.  A inequality constraint (i.e. contact, angle limits) is satisfied when lo <= C <= hi (actually that is the general form of a constraint). Therefore generally is valid to say we want to minimize C so that it remais satisfied all the time. 


Yeah, minimize g(x(t)).


BTW, that's a good article and he basically summarized some of Catto's and Witkin's papers intuitively.  :)

#5288688 SAT problems (3D)

Posted by Irlan Robson on 25 April 2016 - 06:36 PM

I've found this that may solve your problem:  http://www.gamedev.net/topic/676408-differentiating-between-an-edge-edge-and-something-face-collision/#entry5278632


Take a look at our comments. Randy posted an excelent article for the 3D case along with an implementation which I highly recommend if you want an OBB-OBB colision test that can be used in production.


The matrix majorness is irrelevant as long your basis vectors are unit and describe the faces of a box.  :wink:

#5288677 OOP and DOD

Posted by Irlan Robson on 25 April 2016 - 04:45 PM

In my opinion, and I'm assuming we're talking about high performance software development and C++ (since you've tagged the thread with this language), use DOD whenever possible and OOP when forced to because (even though I'm not sure if DOD has been formally and completely defined) what comes to mind technically when thinking of it is that it help us to tackle a couple of problems with OOP:

1. Inheritance abuse (including CPU costs of virtual function calls although generally that is an optimization).

2. Cache wastage through composition abuse and inheritance.

3. Destructors, constructors, member functions, member operator overloading, etc. leading more functional code writing instead of OOP.

Technically, as been stated before, the main result that you get from this is more POD and less objects, sometimes automagically achieving a better memory usage. Ultimately, you want to balance these things so that your only reason to use the (few) advantages of OOP is convenience.

#5287759 Box2D body position out of sync with sprite

Posted by Irlan Robson on 20 April 2016 - 07:05 AM

Have you read Box2D's documentation, at page 65, section Pixels and Coordinate Systems? You are responsible for defining how many pixels a meter has according to the docs.


I suggest you to read the documentation carefully. It describes how to setup bodies correctly at its initial pages. (Maybe you're setting the rigid body as a sensor object or disabling collision with a collision filter or setting up a polygon incorrectly?). It can be many things.  


Erin also suggests to use MKS in your game and only convert these units in the rendering code because convenience. This way you'd be setting the box as shape.SetAsBox(10.0f, 10.0f), which in this case it'll be a box of 20x20 m (because you pass the 10 half-width/height as parameters).

#5287624 Frame Independent Problem

Posted by Irlan Robson on 19 April 2016 - 10:46 AM

According to Bullet, when you pass maxSubSteps = 0, it will use only step the world once. Therefore, your code seems to be correct.


Try to isolate code sections and compare the elapsed time of their execution using a profiler (scope-based if you'd like convenience; otherwise just measure it manually and dump the elapsed time to the console) to check where is the source of these frame rate spikes. That will save us a couple of words here in trying to guess exactly what is the problem.

#5285689 Keyboard input Windows

Posted by Irlan Robson on 07 April 2016 - 08:02 PM

No. When you press a key, a WM_KEYDOWN is sent, and when you release the key, a WM_KEYUP is sent. The WM_KEYPRESSED message repeats during the hold, but it is less useful for game input.

According to the following documentation,


,"Because of the autorepeat feature, more than one WM_KEYDOWN message may be posted before a WM_KEYUP message is posted. The previous key state (bit 30) can be used to determine whether the WM_KEYDOWN message indicates the first down transition or a repeated down transition."

So both options are valid.

#5285666 Keyboard input Windows

Posted by Irlan Robson on 07 April 2016 - 05:31 PM

How do I handle multiple keystrokes in Windows?

Usually keyboard events are buffered and then the keyboard state is updated using these. You buffer them the closest as possible to the frame rendering in an attempt to decrease input latency.

So is this a Windows thing? Should I do it in another way?

No. There is no Win32 documentation stating such thing. If you're holding a key you'll just receive multiple WM_KEYDOWN events.

I suspect you're processing only one window event per frame. Paste your event loop here please.

IIRC GLFW has a very readable handling of keyboard events. Maybe you check that out if you think that should help.

#5285658 Frame Independent Problem

Posted by Irlan Robson on 07 April 2016 - 05:06 PM

Whatever behaviour you're trying to achieve, normalizing the velocity wouldn't help at all.

Your game loop is correct. Try disabling the v-sync to make sure your problem isn't related to the CPU and check the results. Also, you should rely on elapsed microseconds or miliseconds per frame rather than FPS for measurement accuracy.