The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.4KB

  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. #ifndef PYRAMID_H
  19. #define PYRAMID_H
  20. class Pyramid : public Test
  21. {
  22. public:
  23. enum
  24. {
  25. e_count = 20
  26. };
  27. Pyramid()
  28. {
  29. {
  30. b2BodyDef bd;
  31. b2Body* ground = m_world->CreateBody(&bd);
  32. b2EdgeShape shape;
  33. shape.Set(b2Vec2(-40.0f, 0.0f), b2Vec2(40.0f, 0.0f));
  34. ground->CreateFixture(&shape, 0.0f);
  35. }
  36. {
  37. float32 a = 0.5f;
  38. b2PolygonShape shape;
  39. shape.SetAsBox(a, a);
  40. b2Vec2 x(-7.0f, 0.75f);
  41. b2Vec2 y;
  42. b2Vec2 deltaX(0.5625f, 1.25f);
  43. b2Vec2 deltaY(1.125f, 0.0f);
  44. for (int32 i = 0; i < e_count; ++i)
  45. {
  46. y = x;
  47. for (int32 j = i; j < e_count; ++j)
  48. {
  49. b2BodyDef bd;
  50. bd.type = b2_dynamicBody;
  51. bd.position = y;
  52. b2Body* body = m_world->CreateBody(&bd);
  53. body->CreateFixture(&shape, 5.0f);
  54. y += deltaY;
  55. }
  56. x += deltaX;
  57. }
  58. }
  59. }
  60. void Step(Settings* settings)
  61. {
  62. Test::Step(settings);
  63. //b2DynamicTree* tree = &m_world->m_contactManager.m_broadPhase.m_tree;
  64. //if (m_stepCount == 400)
  65. //{
  66. // tree->RebuildBottomUp();
  67. //}
  68. }
  69. static Test* Create()
  70. {
  71. return new Pyramid;
  72. }
  73. };
  74. #endif