1 /* 2 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org 3 * 4 * This software is provided 'as-is', without any express or implied 5 * warranty. In no event will the authors be held liable for any damages 6 * arising from the use of this software. 7 * Permission is granted to anyone to use this software for any purpose, 8 * including commercial applications, and to alter it and redistribute it 9 * freely, subject to the following restrictions: 10 * 1. The origin of this software must not be misrepresented; you must not 11 * claim that you wrote the original software. If you use this software 12 * in a product, an acknowledgment in the product documentation would be 13 * appreciated but is not required. 14 * 2. Altered source versions must be plainly marked as such, and must not be 15 * misrepresented as being the original software. 16 * 3. This notice may not be removed or altered from any source distribution. 17 */ 18 19 #ifndef PYRAMID_H 20 #define PYRAMID_H 21 22 class Pyramid : public Test 23 { 24 public: 25 enum 26 { 27 e_count = 20 28 }; 29 Pyramid()30 Pyramid() 31 { 32 { 33 b2BodyDef bd; 34 b2Body* ground = m_world->CreateBody(&bd); 35 36 b2EdgeShape shape; 37 shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f)); 38 ground->CreateFixture(&shape, 0.0f); 39 } 40 41 { 42 float32 a = 0.5f; 43 b2PolygonShape shape; 44 shape.SetAsBox(a, a); 45 46 b2Vec2 x(-7.0f, 0.75f); 47 b2Vec2 y; 48 b2Vec2 deltaX(0.5625f, 1.25f); 49 b2Vec2 deltaY(1.125f, 0.0f); 50 51 for (int32 i = 0; i < e_count; ++i) 52 { 53 y = x; 54 55 for (int32 j = i; j < e_count; ++j) 56 { 57 b2BodyDef bd; 58 bd.type = b2_dynamicBody; 59 bd.position = y; 60 b2Body* body = m_world->CreateBody(&bd); 61 body->CreateFixture(&shape, 5.0f); 62 63 y += deltaY; 64 } 65 66 x += deltaX; 67 } 68 } 69 } 70 Step(Settings * settings)71 void Step(Settings* settings) 72 { 73 Test::Step(settings); 74 75 //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree; 76 77 //if (m_stepCount == 400) 78 //{ 79 // tree->RebuildBottomUp(); 80 //} 81 } 82 Create()83 static Test* Create() 84 { 85 return new Pyramid; 86 } 87 }; 88 89 #endif 90