| Box2D 2.2.1 A 2D Physics Engine for Games

- Main Page
- Classes
- Files

- File List
- File Members

b2Island.h

    00001 /*
    00002 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
    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_ISLAND_H
    00020 #define B2_ISLAND_H
    00021
    00022 #include <Box2D/Common/b2Math.h>
    00023 #include <Box2D/Dynamics/b2Body.h>
    00024 #include <Box2D/Dynamics/b2TimeStep.h>
    00025
    00026 class b2Contact;
    00027 class b2Joint;
    00028 class b2StackAllocator;
    00029 class b2ContactListener;
    00030 struct b2ContactVelocityConstraint;
    00031 struct b2Profile;
    00032
    00034 class b2Island
    00035 {
    00036 public:
    00037         b2Island(int32 bodyCapacity, int32 contactCapacity, int32 jointCapacity,
    00038                         b2StackAllocator* allocator, b2ContactListener* listener);
    00039         ~b2Island();
    00040
    00041         void Clear()
    00042         {
    00043                 m_bodyCount = 0;
    00044                 m_contactCount = 0;
    00045                 m_jointCount = 0;
    00046         }
    00047
    00048         void Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep);
    00049
    00050         void SolveTOI(const b2TimeStep& subStep, int32 toiIndexA, int32 toiIndexB);
    00051
    00052         void Add(b2Body* body)
    00053         {
    00054                 b2Assert(m_bodyCount < m_bodyCapacity);
    00055                 body->m_islandIndex = m_bodyCount;
    00056                 m_bodies[m_bodyCount] = body;
    00057                 ++m_bodyCount;
    00058         }
    00059
    00060         void Add(b2Contact* contact)
    00061         {
    00062                 b2Assert(m_contactCount < m_contactCapacity);
    00063                 m_contacts[m_contactCount++] = contact;
    00064         }
    00065
    00066         void Add(b2Joint* joint)
    00067         {
    00068                 b2Assert(m_jointCount < m_jointCapacity);
    00069                 m_joints[m_jointCount++] = joint;
    00070         }
    00071
    00072         void Report(const b2ContactVelocityConstraint* constraints);
    00073
    00074         b2StackAllocator* m_allocator;
    00075         b2ContactListener* m_listener;
    00076
    00077         b2Body** m_bodies;
    00078         b2Contact** m_contacts;
    00079         b2Joint** m_joints;
    00080
    00081         b2Position* m_positions;
    00082         b2Velocity* m_velocities;
    00083
    00084         int32 m_bodyCount;
    00085         int32 m_jointCount;
    00086         int32 m_contactCount;
    00087
    00088         int32 m_bodyCapacity;
    00089         int32 m_contactCapacity;
    00090         int32 m_jointCapacity;
    00091 };
    00092
    00093 #endif

All Classes Files Functions Variables Enumerations Enumerator Defines