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.

268 lines
8.9KB

  1. /*
  2. * Copyright (c) 2011 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 DUMP_SHELL_H
  19. #define DUMP_SHELL_H
  20. // This test holds worlds dumped using b2World::Dump.
  21. class DumpShell : public Test
  22. {
  23. public:
  24. DumpShell()
  25. {
  26. b2Vec2 g(0.000000000000000e+00f, 0.000000000000000e+00f);
  27. m_world->SetGravity(g);
  28. b2Body** bodies = (b2Body**)b2Alloc(3 * sizeof(b2Body*));
  29. b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*));
  30. {
  31. b2BodyDef bd;
  32. bd.type = b2BodyType(2);
  33. bd.position.Set(1.304347801208496e+01f, 2.500000000000000e+00f);
  34. bd.angle = 0.000000000000000e+00f;
  35. bd.linearVelocity.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  36. bd.angularVelocity = 0.000000000000000e+00f;
  37. bd.linearDamping = 5.000000000000000e-01f;
  38. bd.angularDamping = 5.000000000000000e-01f;
  39. bd.allowSleep = bool(4);
  40. bd.awake = bool(2);
  41. bd.fixedRotation = bool(0);
  42. bd.bullet = bool(0);
  43. bd.active = bool(32);
  44. bd.gravityScale = 1.000000000000000e+00f;
  45. bodies[0] = m_world->CreateBody(&bd);
  46. {
  47. b2FixtureDef fd;
  48. fd.friction = 1.000000000000000e+00f;
  49. fd.restitution = 5.000000000000000e-01f;
  50. fd.density = 1.000000000000000e+01f;
  51. fd.isSensor = bool(0);
  52. fd.filter.categoryBits = uint16(1);
  53. fd.filter.maskBits = uint16(65535);
  54. fd.filter.groupIndex = int16(0);
  55. b2PolygonShape shape;
  56. b2Vec2 vs[8];
  57. vs[0].Set(-6.900000095367432e+00f, -3.000000119209290e-01f);
  58. vs[1].Set(2.000000029802322e-01f, -3.000000119209290e-01f);
  59. vs[2].Set(2.000000029802322e-01f, 2.000000029802322e-01f);
  60. vs[3].Set(-6.900000095367432e+00f, 2.000000029802322e-01f);
  61. shape.Set(vs, 4);
  62. fd.shape = &shape;
  63. bodies[0]->CreateFixture(&fd);
  64. }
  65. }
  66. {
  67. b2BodyDef bd;
  68. bd.type = b2BodyType(2);
  69. bd.position.Set(8.478260636329651e-01f, 2.500000000000000e+00f);
  70. bd.angle = 0.000000000000000e+00f;
  71. bd.linearVelocity.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  72. bd.angularVelocity = 0.000000000000000e+00f;
  73. bd.linearDamping = 5.000000000000000e-01f;
  74. bd.angularDamping = 5.000000000000000e-01f;
  75. bd.allowSleep = bool(4);
  76. bd.awake = bool(2);
  77. bd.fixedRotation = bool(0);
  78. bd.bullet = bool(0);
  79. bd.active = bool(32);
  80. bd.gravityScale = 1.000000000000000e+00f;
  81. bodies[1] = m_world->CreateBody(&bd);
  82. {
  83. b2FixtureDef fd;
  84. fd.friction = 1.000000000000000e+00f;
  85. fd.restitution = 5.000000000000000e-01f;
  86. fd.density = 1.000000000000000e+01f;
  87. fd.isSensor = bool(0);
  88. fd.filter.categoryBits = uint16(1);
  89. fd.filter.maskBits = uint16(65535);
  90. fd.filter.groupIndex = int16(0);
  91. b2PolygonShape shape;
  92. b2Vec2 vs[8];
  93. vs[0].Set(-3.228000104427338e-01f, -2.957000136375427e-01f);
  94. vs[1].Set(6.885900020599365e+00f, -3.641000092029572e-01f);
  95. vs[2].Set(6.907599925994873e+00f, 3.271999955177307e-01f);
  96. vs[3].Set(-3.228000104427338e-01f, 2.825999855995178e-01f);
  97. shape.Set(vs, 4);
  98. fd.shape = &shape;
  99. bodies[1]->CreateFixture(&fd);
  100. }
  101. }
  102. {
  103. b2BodyDef bd;
  104. bd.type = b2BodyType(0);
  105. bd.position.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  106. bd.angle = 0.000000000000000e+00f;
  107. bd.linearVelocity.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  108. bd.angularVelocity = 0.000000000000000e+00f;
  109. bd.linearDamping = 0.000000000000000e+00f;
  110. bd.angularDamping = 0.000000000000000e+00f;
  111. bd.allowSleep = bool(4);
  112. bd.awake = bool(2);
  113. bd.fixedRotation = bool(0);
  114. bd.bullet = bool(0);
  115. bd.active = bool(32);
  116. bd.gravityScale = 1.000000000000000e+00f;
  117. bodies[2] = m_world->CreateBody(&bd);
  118. {
  119. b2FixtureDef fd;
  120. fd.friction = 1.000000000000000e+01f;
  121. fd.restitution = 0.000000000000000e+00f;
  122. fd.density = 0.000000000000000e+00f;
  123. fd.isSensor = bool(0);
  124. fd.filter.categoryBits = uint16(1);
  125. fd.filter.maskBits = uint16(65535);
  126. fd.filter.groupIndex = int16(0);
  127. b2EdgeShape shape;
  128. shape.m_radius = 9.999999776482582e-03f;
  129. shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  130. shape.m_vertex1.Set(4.452173995971680e+01f, 1.669565200805664e+01f);
  131. shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f);
  132. shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  133. shape.m_hasVertex0 = bool(0);
  134. shape.m_hasVertex3 = bool(0);
  135. fd.shape = &shape;
  136. bodies[2]->CreateFixture(&fd);
  137. }
  138. {
  139. b2FixtureDef fd;
  140. fd.friction = 1.000000000000000e+01f;
  141. fd.restitution = 0.000000000000000e+00f;
  142. fd.density = 0.000000000000000e+00f;
  143. fd.isSensor = bool(0);
  144. fd.filter.categoryBits = uint16(1);
  145. fd.filter.maskBits = uint16(65535);
  146. fd.filter.groupIndex = int16(0);
  147. b2EdgeShape shape;
  148. shape.m_radius = 9.999999776482582e-03f;
  149. shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  150. shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f);
  151. shape.m_vertex2.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  152. shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  153. shape.m_hasVertex0 = bool(0);
  154. shape.m_hasVertex3 = bool(0);
  155. fd.shape = &shape;
  156. bodies[2]->CreateFixture(&fd);
  157. }
  158. {
  159. b2FixtureDef fd;
  160. fd.friction = 1.000000000000000e+01f;
  161. fd.restitution = 0.000000000000000e+00f;
  162. fd.density = 0.000000000000000e+00f;
  163. fd.isSensor = bool(0);
  164. fd.filter.categoryBits = uint16(1);
  165. fd.filter.maskBits = uint16(65535);
  166. fd.filter.groupIndex = int16(0);
  167. b2EdgeShape shape;
  168. shape.m_radius = 9.999999776482582e-03f;
  169. shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  170. shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f);
  171. shape.m_vertex2.Set(4.452173995971680e+01f, 1.669565200805664e+01f);
  172. shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  173. shape.m_hasVertex0 = bool(0);
  174. shape.m_hasVertex3 = bool(0);
  175. fd.shape = &shape;
  176. bodies[2]->CreateFixture(&fd);
  177. }
  178. {
  179. b2FixtureDef fd;
  180. fd.friction = 1.000000000000000e+01f;
  181. fd.restitution = 0.000000000000000e+00f;
  182. fd.density = 0.000000000000000e+00f;
  183. fd.isSensor = bool(0);
  184. fd.filter.categoryBits = uint16(1);
  185. fd.filter.maskBits = uint16(65535);
  186. fd.filter.groupIndex = int16(0);
  187. b2EdgeShape shape;
  188. shape.m_radius = 9.999999776482582e-03f;
  189. shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  190. shape.m_vertex1.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  191. shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f);
  192. shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  193. shape.m_hasVertex0 = bool(0);
  194. shape.m_hasVertex3 = bool(0);
  195. fd.shape = &shape;
  196. bodies[2]->CreateFixture(&fd);
  197. }
  198. }
  199. {
  200. b2PrismaticJointDef jd;
  201. jd.bodyA = bodies[1];
  202. jd.bodyB = bodies[0];
  203. jd.collideConnected = bool(0);
  204. jd.localAnchorA.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  205. jd.localAnchorB.Set(-1.219565200805664e+01f, 0.000000000000000e+00f);
  206. jd.localAxisA.Set(-1.219565200805664e+01f, 0.000000000000000e+00f);
  207. jd.referenceAngle = 0.000000000000000e+00f;
  208. jd.enableLimit = bool(1);
  209. jd.lowerTranslation = -2.000000000000000e+01f;
  210. jd.upperTranslation = 0.000000000000000e+00f;
  211. jd.enableMotor = bool(1);
  212. jd.motorSpeed = 0.000000000000000e+00f;
  213. jd.maxMotorForce = 1.000000000000000e+01f;
  214. joints[0] = m_world->CreateJoint(&jd);
  215. }
  216. {
  217. b2RevoluteJointDef jd;
  218. jd.bodyA = bodies[1];
  219. jd.bodyB = bodies[2];
  220. jd.collideConnected = bool(0);
  221. jd.localAnchorA.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
  222. jd.localAnchorB.Set(8.478260636329651e-01f, 2.500000000000000e+00f);
  223. jd.referenceAngle = 0.000000000000000e+00f;
  224. jd.enableLimit = bool(0);
  225. jd.lowerAngle = 0.000000000000000e+00f;
  226. jd.upperAngle = 0.000000000000000e+00f;
  227. jd.enableMotor = bool(0);
  228. jd.motorSpeed = 0.000000000000000e+00f;
  229. jd.maxMotorTorque = 0.000000000000000e+00f;
  230. joints[1] = m_world->CreateJoint(&jd);
  231. }
  232. b2Free(joints);
  233. b2Free(bodies);
  234. joints = NULL;
  235. bodies = NULL;
  236. }
  237. static Test* Create()
  238. {
  239. return new DumpShell;
  240. }
  241. };
  242. #endif