- Main Page
- Classes
- Files

- File List
- File Members

# Box2D/Box2D/Dynamics/Contacts/b2ContactSolver.h

Go to the documentation of this file.

    00001 /*
    00002 * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
    00003 *
    00004 * This software is provided 'as-is', without any express or implied
    00005 * warranty.  In no event will the authors be held liable for any damages
    00006 * arising from the use of this software.
    00007 * Permission is granted to anyone to use this software for any purpose,
    00008 * including commercial applications, and to alter it and redistribute it
    00009 * freely, subject to the following restrictions:
    00010 * 1. The origin of this software must not be misrepresented; you must not
    00011 * claim that you wrote the original software. If you use this software
    00012 * in a product, an acknowledgment in the product documentation would be
    00013 * appreciated but is not required.
    00014 * 2. Altered source versions must be plainly marked as such, and must not be
    00015 * misrepresented as being the original software.
    00016 * 3. This notice may not be removed or altered from any source distribution.
    00017 */
    00018
    00019 #ifndef B2_CONTACT_SOLVER_H
    00020 #define B2_CONTACT_SOLVER_H
    00021
    00022 #include <Box2D/Common/b2Math.h>
    00023 #include <Box2D/Collision/b2Collision.h>
    00024 #include <Box2D/Dynamics/b2Island.h>
    00025
    00026 class b2Contact;
    00027 class b2Body;
    00028 class b2StackAllocator;
    00029
    00030 struct b2ContactConstraintPoint
    00031 {
    00032         b2Vec2 localPoint;
    00033         b2Vec2 rA;
    00034         b2Vec2 rB;
    00035         float32 normalImpulse;
    00036         float32 tangentImpulse;
    00037         float32 normalMass;
    00038         float32 tangentMass;
    00039         float32 velocityBias;
    00040 };
    00041
    00042 struct b2ContactConstraint
    00043 {
    00044         b2ContactConstraintPoint points[b2_maxManifoldPoints];
    00045         b2Vec2 localNormal;
    00046         b2Vec2 localPoint;
    00047         b2Vec2 normal;
    00048         b2Mat22 normalMass;
    00049         b2Mat22 K;
    00050         b2Body* bodyA;
    00051         b2Body* bodyB;
    00052         b2Manifold::Type type;
    00053         float32 radius;
    00054         float32 friction;
    00055         int32 pointCount;
    00056         b2Manifold* manifold;
    00057 };
    00058
    00059 class b2ContactSolver
    00060 {
    00061 public:
    00062         b2ContactSolver(b2Contact** contacts, int32 contactCount,
    00063                                         b2StackAllocator* allocator, float32 impulseRatio);
    00064
    00065         ~b2ContactSolver();
    00066
    00067         void WarmStart();
    00068         void SolveVelocityConstraints();
    00069         void StoreImpulses();
    00070
    00071         bool SolvePositionConstraints(float32 baumgarte);
    00072
    00073         b2StackAllocator* m_allocator;
    00074         b2ContactConstraint* m_constraints;
    00075         int m_constraintCount;
    00076 };
    00077
    00078 #endif