Skip to content
This repository
Browse code

ADD Box2D r141 with included fix in b2math.h in b2Transform constructor

  • Loading branch information...
commit 5512bdfd8069bc239e8d38fe955ff4abf8300802 1 parent 9794777
PowerKiKi authored

Showing 656 changed files with 23,884 additions and 0 deletions. Show diff stats Hide diff stats

  1. +65 0 application/lib/box2d/Box2D/Box2D.h
  2. +3 0  application/lib/box2d/Box2D/Box2DConfig.cmake
  3. +191 0 application/lib/box2d/Box2D/CMakeLists.txt
  4. +100 0 application/lib/box2d/Box2D/Collision/Shapes/b2CircleShape.cpp
  5. +91 0 application/lib/box2d/Box2D/Collision/Shapes/b2CircleShape.h
  6. +139 0 application/lib/box2d/Box2D/Collision/Shapes/b2EdgeShape.cpp
  7. +70 0 application/lib/box2d/Box2D/Collision/Shapes/b2EdgeShape.h
  8. +130 0 application/lib/box2d/Box2D/Collision/Shapes/b2LoopShape.cpp
  9. +96 0 application/lib/box2d/Box2D/Collision/Shapes/b2LoopShape.h
  10. +364 0 application/lib/box2d/Box2D/Collision/Shapes/b2PolygonShape.cpp
  11. +95 0 application/lib/box2d/Box2D/Collision/Shapes/b2PolygonShape.h
  12. +103 0 application/lib/box2d/Box2D/Collision/Shapes/b2Shape.h
  13. +117 0 application/lib/box2d/Box2D/Collision/b2BroadPhase.cpp
  14. +229 0 application/lib/box2d/Box2D/Collision/b2BroadPhase.h
  15. +154 0 application/lib/box2d/Box2D/Collision/b2CollideCircle.cpp
  16. +673 0 application/lib/box2d/Box2D/Collision/b2CollideEdge.cpp
  17. +319 0 application/lib/box2d/Box2D/Collision/b2CollidePolygon.cpp
  18. +249 0 application/lib/box2d/Box2D/Collision/b2Collision.cpp
  19. +277 0 application/lib/box2d/Box2D/Collision/b2Collision.h
  20. +603 0 application/lib/box2d/Box2D/Collision/b2Distance.cpp
  21. +141 0 application/lib/box2d/Box2D/Collision/b2Distance.h
  22. +426 0 application/lib/box2d/Box2D/Collision/b2DynamicTree.cpp
  23. +272 0 application/lib/box2d/Box2D/Collision/b2DynamicTree.h
  24. +483 0 application/lib/box2d/Box2D/Collision/b2TimeOfImpact.cpp
  25. +58 0 application/lib/box2d/Box2D/Collision/b2TimeOfImpact.h
  26. +217 0 application/lib/box2d/Box2D/Common/b2BlockAllocator.cpp
  27. +62 0 application/lib/box2d/Box2D/Common/b2BlockAllocator.h
  28. +85 0 application/lib/box2d/Box2D/Common/b2GrowableStack.h
  29. +55 0 application/lib/box2d/Box2D/Common/b2Math.cpp
  30. +640 0 application/lib/box2d/Box2D/Common/b2Math.h
  31. +33 0 application/lib/box2d/Box2D/Common/b2Settings.cpp
  32. +156 0 application/lib/box2d/Box2D/Common/b2Settings.h
  33. +83 0 application/lib/box2d/Box2D/Common/b2StackAllocator.cpp
  34. +60 0 application/lib/box2d/Box2D/Common/b2StackAllocator.h
  35. +53 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2CircleContact.cpp
  36. +39 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2CircleContact.h
  37. +245 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2Contact.cpp
  38. +264 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2Contact.h
  39. +737 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2ContactSolver.cpp
  40. +90 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2ContactSolver.h
  41. +50 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp
  42. +39 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h
  43. +50 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp
  44. +39 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h
  45. +54 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2LoopAndCircleContact.cpp
  46. +39 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2LoopAndCircleContact.h
  47. +54 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2LoopAndPolygonContact.cpp
  48. +39 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2LoopAndPolygonContact.h
  49. +50 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp
  50. +38 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h
  51. +53 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2PolygonContact.cpp
  52. +39 0 application/lib/box2d/Box2D/Dynamics/Contacts/b2PolygonContact.h
  53. +211 0 application/lib/box2d/Box2D/Dynamics/Joints/b2DistanceJoint.cpp
  54. +145 0 application/lib/box2d/Box2D/Dynamics/Joints/b2DistanceJoint.h
  55. +229 0 application/lib/box2d/Box2D/Dynamics/Joints/b2FrictionJoint.cpp
  56. +99 0 application/lib/box2d/Box2D/Dynamics/Joints/b2FrictionJoint.h
  57. +259 0 application/lib/box2d/Box2D/Dynamics/Joints/b2GearJoint.cpp
  58. +111 0 application/lib/box2d/Box2D/Dynamics/Joints/b2GearJoint.h
  59. +198 0 application/lib/box2d/Box2D/Dynamics/Joints/b2Joint.cpp
  60. +234 0 application/lib/box2d/Box2D/Dynamics/Joints/b2Joint.h
  61. +591 0 application/lib/box2d/Box2D/Dynamics/Joints/b2LineJoint.cpp
  62. +175 0 application/lib/box2d/Box2D/Dynamics/Joints/b2LineJoint.h
  63. +197 0 application/lib/box2d/Box2D/Dynamics/Joints/b2MouseJoint.cpp
  64. +114 0 application/lib/box2d/Box2D/Dynamics/Joints/b2MouseJoint.h
  65. +598 0 application/lib/box2d/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp
  66. +175 0 application/lib/box2d/Box2D/Dynamics/Joints/b2PrismaticJoint.h
  67. +427 0 application/lib/box2d/Box2D/Dynamics/Joints/b2PulleyJoint.cpp
  68. +148 0 application/lib/box2d/Box2D/Dynamics/Joints/b2PulleyJoint.h
  69. +478 0 application/lib/box2d/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp
  70. +180 0 application/lib/box2d/Box2D/Dynamics/Joints/b2RevoluteJoint.h
  71. +197 0 application/lib/box2d/Box2D/Dynamics/Joints/b2RopeJoint.cpp
  72. +99 0 application/lib/box2d/Box2D/Dynamics/Joints/b2RopeJoint.h
  73. +219 0 application/lib/box2d/Box2D/Dynamics/Joints/b2WeldJoint.cpp
  74. +82 0 application/lib/box2d/Box2D/Dynamics/Joints/b2WeldJoint.h
  75. +467 0 application/lib/box2d/Box2D/Dynamics/b2Body.cpp
  76. +805 0 application/lib/box2d/Box2D/Dynamics/b2Body.h
  77. +279 0 application/lib/box2d/Box2D/Dynamics/b2ContactManager.cpp
  78. +52 0 application/lib/box2d/Box2D/Dynamics/b2ContactManager.h
  79. +204 0 application/lib/box2d/Box2D/Dynamics/b2Fixture.cpp
  80. +336 0 application/lib/box2d/Box2D/Dynamics/b2Fixture.h
  81. +512 0 application/lib/box2d/Box2D/Dynamics/b2Island.cpp
  82. +105 0 application/lib/box2d/Box2D/Dynamics/b2Island.h
  83. +35 0 application/lib/box2d/Box2D/Dynamics/b2TimeStep.h
  84. +1,182 0 application/lib/box2d/Box2D/Dynamics/b2World.cpp
  85. +315 0 application/lib/box2d/Box2D/Dynamics/b2World.h
  86. +61 0 application/lib/box2d/Box2D/Dynamics/b2WorldCallbacks.cpp
  87. +216 0 application/lib/box2d/Box2D/Dynamics/b2WorldCallbacks.h
  88. +1 0  application/lib/box2d/Build/Readme.txt
  89. +21 0 application/lib/box2d/Building.txt
  90. +36 0 application/lib/box2d/CMakeLists.txt
  91. +58 0 application/lib/box2d/Documentation/API/_box2_d_8h.html
  92. +82 0 application/lib/box2d/Documentation/API/_box2_d_8h_source.html
  93. +129 0 application/lib/box2d/Documentation/API/annotated.html
  94. +42 0 application/lib/box2d/Documentation/API/b2_block_allocator_8cpp.html
  95. +97 0 application/lib/box2d/Documentation/API/b2_block_allocator_8h.html
  96. +89 0 application/lib/box2d/Documentation/API/b2_block_allocator_8h_source.html
  97. +39 0 application/lib/box2d/Documentation/API/b2_body_8cpp.html
  98. +73 0 application/lib/box2d/Documentation/API/b2_body_8h.html
  99. +668 0 application/lib/box2d/Documentation/API/b2_body_8h_source.html
  100. +36 0 application/lib/box2d/Documentation/API/b2_broad_phase_8cpp.html
  101. +76 0 application/lib/box2d/Documentation/API/b2_broad_phase_8h.html
  102. +235 0 application/lib/box2d/Documentation/API/b2_broad_phase_8h_source.html
  103. +41 0 application/lib/box2d/Documentation/API/b2_circle_contact_8cpp.html
  104. +39 0 application/lib/box2d/Documentation/API/b2_circle_contact_8h.html
  105. +68 0 application/lib/box2d/Documentation/API/b2_circle_contact_8h_source.html
  106. +36 0 application/lib/box2d/Documentation/API/b2_circle_shape_8cpp.html
  107. +40 0 application/lib/box2d/Documentation/API/b2_circle_shape_8h.html
  108. +106 0 application/lib/box2d/Documentation/API/b2_circle_shape_8h_source.html
  109. +137 0 application/lib/box2d/Documentation/API/b2_collide_circle_8cpp.html
  110. +87 0 application/lib/box2d/Documentation/API/b2_collide_polygon_8cpp.html
  111. +165 0 application/lib/box2d/Documentation/API/b2_collision_8cpp.html
  112. +416 0 application/lib/box2d/Documentation/API/b2_collision_8h.html
  113. +216 0 application/lib/box2d/Documentation/API/b2_collision_8h_source.html
  114. +46 0 application/lib/box2d/Documentation/API/b2_contact_8cpp.html
  115. +75 0 application/lib/box2d/Documentation/API/b2_contact_8h.html
  116. +247 0 application/lib/box2d/Documentation/API/b2_contact_8h_source.html
  117. +69 0 application/lib/box2d/Documentation/API/b2_contact_manager_8cpp.html
  118. +39 0 application/lib/box2d/Documentation/API/b2_contact_manager_8h.html
  119. +82 0 application/lib/box2d/Documentation/API/b2_contact_manager_8h_source.html
  120. +58 0 application/lib/box2d/Documentation/API/b2_contact_solver_8cpp.html
  121. +43 0 application/lib/box2d/Documentation/API/b2_contact_solver_8h.html
  122. +108 0 application/lib/box2d/Documentation/API/b2_contact_solver_8h_source.html
  123. +121 0 application/lib/box2d/Documentation/API/b2_distance_8cpp.html
  124. +81 0 application/lib/box2d/Documentation/API/b2_distance_8h.html
  125. +153 0 application/lib/box2d/Documentation/API/b2_distance_8h_source.html
  126. +37 0 application/lib/box2d/Documentation/API/b2_distance_joint_8cpp.html
  127. +40 0 application/lib/box2d/Documentation/API/b2_distance_joint_8h.html
  128. +152 0 application/lib/box2d/Documentation/API/b2_distance_joint_8h_source.html
  129. +37 0 application/lib/box2d/Documentation/API/b2_dynamic_tree_8cpp.html
  130. +60 0 application/lib/box2d/Documentation/API/b2_dynamic_tree_8h.html
  131. +283 0 application/lib/box2d/Documentation/API/b2_dynamic_tree_8h_source.html
  132. +41 0 application/lib/box2d/Documentation/API/b2_fixture_8cpp.html
  133. +44 0 application/lib/box2d/Documentation/API/b2_fixture_8h.html
  134. +295 0 application/lib/box2d/Documentation/API/b2_fixture_8h_source.html
  135. +37 0 application/lib/box2d/Documentation/API/b2_friction_joint_8cpp.html
  136. +41 0 application/lib/box2d/Documentation/API/b2_friction_joint_8h.html
  137. +116 0 application/lib/box2d/Documentation/API/b2_friction_joint_8h_source.html
Sorry, we could not display the entire diff because too many files (656) changed.
65 application/lib/box2d/Box2D/Box2D.h
... ... @@ -0,0 +1,65 @@
  1 +/*
  2 +* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
  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 BOX2D_H
  20 +#define BOX2D_H
  21 +
  22 +/**
  23 +\mainpage Box2D API Documentation
  24 +
  25 +\section intro_sec Getting Started
  26 +
  27 +For documentation please see http://box2d.org/documentation.html
  28 +
  29 +For discussion please visit http://box2d.org/forum
  30 +*/
  31 +
  32 +// These include files constitute the main Box2D API
  33 +
  34 +#include <Box2D/Common/b2Settings.h>
  35 +
  36 +#include <Box2D/Collision/Shapes/b2CircleShape.h>
  37 +#include <Box2D/Collision/Shapes/b2EdgeShape.h>
  38 +#include <Box2D/Collision/Shapes/b2LoopShape.h>
  39 +#include <Box2D/Collision/Shapes/b2PolygonShape.h>
  40 +
  41 +#include <Box2D/Collision/b2BroadPhase.h>
  42 +#include <Box2D/Collision/b2Distance.h>
  43 +#include <Box2D/Collision/b2DynamicTree.h>
  44 +#include <Box2D/Collision/b2TimeOfImpact.h>
  45 +
  46 +#include <Box2D/Dynamics/b2Body.h>
  47 +#include <Box2D/Dynamics/b2Fixture.h>
  48 +#include <Box2D/Dynamics/b2WorldCallbacks.h>
  49 +#include <Box2D/Dynamics/b2TimeStep.h>
  50 +#include <Box2D/Dynamics/b2World.h>
  51 +
  52 +#include <Box2D/Dynamics/Contacts/b2Contact.h>
  53 +
  54 +#include <Box2D/Dynamics/Joints/b2DistanceJoint.h>
  55 +#include <Box2D/Dynamics/Joints/b2FrictionJoint.h>
  56 +#include <Box2D/Dynamics/Joints/b2GearJoint.h>
  57 +#include <Box2D/Dynamics/Joints/b2LineJoint.h>
  58 +#include <Box2D/Dynamics/Joints/b2MouseJoint.h>
  59 +#include <Box2D/Dynamics/Joints/b2PrismaticJoint.h>
  60 +#include <Box2D/Dynamics/Joints/b2PulleyJoint.h>
  61 +#include <Box2D/Dynamics/Joints/b2RevoluteJoint.h>
  62 +#include <Box2D/Dynamics/Joints/b2RopeJoint.h>
  63 +#include <Box2D/Dynamics/Joints/b2WeldJoint.h>
  64 +
  65 +#endif
3  application/lib/box2d/Box2D/Box2DConfig.cmake
... ... @@ -0,0 +1,3 @@
  1 +get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
  2 +include(${SELF_DIR}/Box2D-targets.cmake)
  3 +get_filename_component(Box2D_INCLUDE_DIRS "${SELF_DIR}/../../include" ABSOLUTE)
191 application/lib/box2d/Box2D/CMakeLists.txt
... ... @@ -0,0 +1,191 @@
  1 +set(BOX2D_Collision_SRCS
  2 + Collision/b2BroadPhase.cpp
  3 + Collision/b2CollideCircle.cpp
  4 + Collision/b2CollideEdge.cpp
  5 + Collision/b2CollidePolygon.cpp
  6 + Collision/b2Collision.cpp
  7 + Collision/b2Distance.cpp
  8 + Collision/b2DynamicTree.cpp
  9 + Collision/b2TimeOfImpact.cpp
  10 +)
  11 +set(BOX2D_Collision_HDRS
  12 + Collision/b2BroadPhase.h
  13 + Collision/b2Collision.h
  14 + Collision/b2Distance.h
  15 + Collision/b2DynamicTree.h
  16 + Collision/b2TimeOfImpact.h
  17 +)
  18 +set(BOX2D_Shapes_SRCS
  19 + Collision/Shapes/b2CircleShape.cpp
  20 + Collision/Shapes/b2EdgeShape.cpp
  21 + Collision/Shapes/b2LoopShape.cpp
  22 + Collision/Shapes/b2PolygonShape.cpp
  23 +)
  24 +set(BOX2D_Shapes_HDRS
  25 + Collision/Shapes/b2CircleShape.h
  26 + Collision/Shapes/b2EdgeShape.h
  27 + Collision/Shapes/b2LoopShape.h
  28 + Collision/Shapes/b2PolygonShape.h
  29 + Collision/Shapes/b2Shape.h
  30 +)
  31 +set(BOX2D_Common_SRCS
  32 + Common/b2BlockAllocator.cpp
  33 + Common/b2Math.cpp
  34 + Common/b2Settings.cpp
  35 + Common/b2StackAllocator.cpp
  36 +)
  37 +set(BOX2D_Common_HDRS
  38 + Common/b2BlockAllocator.h
  39 + Common/b2GrowableStack.h
  40 + Common/b2Math.h
  41 + Common/b2Settings.h
  42 + Common/b2StackAllocator.h
  43 +)
  44 +set(BOX2D_Dynamics_SRCS
  45 + Dynamics/b2Body.cpp
  46 + Dynamics/b2ContactManager.cpp
  47 + Dynamics/b2Fixture.cpp
  48 + Dynamics/b2Island.cpp
  49 + Dynamics/b2World.cpp
  50 + Dynamics/b2WorldCallbacks.cpp
  51 +)
  52 +set(BOX2D_Dynamics_HDRS
  53 + Dynamics/b2Body.h
  54 + Dynamics/b2ContactManager.h
  55 + Dynamics/b2Fixture.h
  56 + Dynamics/b2Island.h
  57 + Dynamics/b2TimeStep.h
  58 + Dynamics/b2World.h
  59 + Dynamics/b2WorldCallbacks.h
  60 +)
  61 +set(BOX2D_Contacts_SRCS
  62 + Dynamics/Contacts/b2CircleContact.cpp
  63 + Dynamics/Contacts/b2Contact.cpp
  64 + Dynamics/Contacts/b2ContactSolver.cpp
  65 + Dynamics/Contacts/b2PolygonAndCircleContact.cpp
  66 + Dynamics/Contacts/b2EdgeAndCircleContact.cpp
  67 + Dynamics/Contacts/b2EdgeAndPolygonContact.cpp
  68 + Dynamics/Contacts/b2LoopAndCircleContact.cpp
  69 + Dynamics/Contacts/b2LoopAndPolygonContact.cpp
  70 + Dynamics/Contacts/b2PolygonContact.cpp
  71 +)
  72 +set(BOX2D_Contacts_HDRS
  73 + Dynamics/Contacts/b2CircleContact.h
  74 + Dynamics/Contacts/b2Contact.h
  75 + Dynamics/Contacts/b2ContactSolver.h
  76 + Dynamics/Contacts/b2PolygonAndCircleContact.h
  77 + Dynamics/Contacts/b2EdgeAndCircleContact.h
  78 + Dynamics/Contacts/b2EdgeAndPolygonContact.h
  79 + Dynamics/Contacts/b2LoopAndCircleContact.h
  80 + Dynamics/Contacts/b2LoopAndPolygonContact.h
  81 + Dynamics/Contacts/b2PolygonContact.h
  82 +)
  83 +set(BOX2D_Joints_SRCS
  84 + Dynamics/Joints/b2DistanceJoint.cpp
  85 + Dynamics/Joints/b2FrictionJoint.cpp
  86 + Dynamics/Joints/b2GearJoint.cpp
  87 + Dynamics/Joints/b2Joint.cpp
  88 + Dynamics/Joints/b2LineJoint.cpp
  89 + Dynamics/Joints/b2MouseJoint.cpp
  90 + Dynamics/Joints/b2PrismaticJoint.cpp
  91 + Dynamics/Joints/b2PulleyJoint.cpp
  92 + Dynamics/Joints/b2RevoluteJoint.cpp
  93 + Dynamics/Joints/b2RopeJoint.cpp
  94 + Dynamics/Joints/b2WeldJoint.cpp
  95 +)
  96 +set(BOX2D_Joints_HDRS
  97 + Dynamics/Joints/b2DistanceJoint.h
  98 + Dynamics/Joints/b2FrictionJoint.h
  99 + Dynamics/Joints/b2GearJoint.h
  100 + Dynamics/Joints/b2Joint.h
  101 + Dynamics/Joints/b2LineJoint.h
  102 + Dynamics/Joints/b2MouseJoint.h
  103 + Dynamics/Joints/b2PrismaticJoint.h
  104 + Dynamics/Joints/b2PulleyJoint.h
  105 + Dynamics/Joints/b2RevoluteJoint.h
  106 + Dynamics/Joints/b2RopeJoint.h
  107 + Dynamics/Joints/b2WeldJoint.h
  108 +)
  109 +set(BOX2D_General_HDRS
  110 + Box2D.h
  111 +)
  112 +include_directories( ../ )
  113 +
  114 +if(BOX2D_BUILD_SHARED)
  115 + add_library(Box2D_shared SHARED
  116 + ${BOX2D_General_HDRS}
  117 + ${BOX2D_Joints_SRCS}
  118 + ${BOX2D_Joints_HDRS}
  119 + ${BOX2D_Contacts_SRCS}
  120 + ${BOX2D_Contacts_HDRS}
  121 + ${BOX2D_Dynamics_SRCS}
  122 + ${BOX2D_Dynamics_HDRS}
  123 + ${BOX2D_Common_SRCS}
  124 + ${BOX2D_Common_HDRS}
  125 + ${BOX2D_Shapes_SRCS}
  126 + ${BOX2D_Shapes_HDRS}
  127 + ${BOX2D_Collision_SRCS}
  128 + ${BOX2D_Collision_HDRS}
  129 + )
  130 + set_target_properties(Box2D_shared PROPERTIES
  131 + OUTPUT_NAME "Box2D"
  132 + CLEAN_DIRECT_OUTPUT 1
  133 + VERSION ${BOX2D_VERSION}
  134 + )
  135 +endif()
  136 +
  137 +if(BOX2D_BUILD_STATIC)
  138 + add_library(Box2D STATIC
  139 + ${BOX2D_General_HDRS}
  140 + ${BOX2D_Joints_SRCS}
  141 + ${BOX2D_Joints_HDRS}
  142 + ${BOX2D_Contacts_SRCS}
  143 + ${BOX2D_Contacts_HDRS}
  144 + ${BOX2D_Dynamics_SRCS}
  145 + ${BOX2D_Dynamics_HDRS}
  146 + ${BOX2D_Common_SRCS}
  147 + ${BOX2D_Common_HDRS}
  148 + ${BOX2D_Shapes_SRCS}
  149 + ${BOX2D_Shapes_HDRS}
  150 + ${BOX2D_Collision_SRCS}
  151 + ${BOX2D_Collision_HDRS}
  152 + )
  153 + set_target_properties(Box2D PROPERTIES
  154 + CLEAN_DIRECT_OUTPUT 1
  155 + VERSION ${BOX2D_VERSION}
  156 + )
  157 +endif()
  158 +
  159 +if(MSVC)
  160 + # These are used to create visual studio folders.
  161 + source_group(Collision FILES ${BOX2D_Collision_SRCS} ${BOX2D_Collision_HDRS})
  162 + source_group(Collision\\Shapes FILES ${BOX2D_Shapes_SRCS} ${BOX2D_Shapes_HDRS})
  163 + source_group(Common FILES ${BOX2D_Common_SRCS} ${BOX2D_Common_HDRS})
  164 + source_group(Dynamics FILES ${BOX2D_Dynamics_SRCS} ${BOX2D_Dynamics_HDRS})
  165 + source_group(Dynamics\\Contacts FILES ${BOX2D_Contacts_SRCS} ${BOX2D_Contacts_HDRS})
  166 + source_group(Dynamics\\Joints FILES ${BOX2D_Joints_SRCS} ${BOX2D_Joints_HDRS})
  167 + source_group(Include FILES ${BOX2D_General_HDRS})
  168 +endif()
  169 +
  170 +if(BOX2D_INSTALL)
  171 + # install headers
  172 + install(FILES ${BOX2D_General_HDRS} DESTINATION include/Box2D)
  173 + install(FILES ${BOX2D_Collision_HDRS} DESTINATION include/Box2D/Collision)
  174 + install(FILES ${BOX2D_Shapes_HDRS} DESTINATION include/Box2D/Collision/Shapes)
  175 + install(FILES ${BOX2D_Common_HDRS} DESTINATION include/Box2D/Common)
  176 + install(FILES ${BOX2D_Dynamics_HDRS} DESTINATION include/Box2D/Dynamics)
  177 + install(FILES ${BOX2D_Contacts_HDRS} DESTINATION include/Box2D/Dynamics/Contacts)
  178 + install(FILES ${BOX2D_Joints_HDRS} DESTINATION include/Box2D/Dynamics/Joints)
  179 +
  180 + # install libraries
  181 + if(BOX2D_BUILD_SHARED)
  182 + install(TARGETS Box2D_shared EXPORT Box2D-targets DESTINATION lib)
  183 + endif()
  184 + if(BOX2D_BUILD_STATIC)
  185 + install(TARGETS Box2D EXPORT Box2D-targets DESTINATION lib)
  186 + endif()
  187 +
  188 + # install build system hooks for third-party apps
  189 + install(EXPORT Box2D-targets DESTINATION lib/Box2D)
  190 + install(FILES Box2DConfig.cmake DESTINATION lib/Box2D)
  191 +endif(BOX2D_INSTALL)
100 application/lib/box2d/Box2D/Collision/Shapes/b2CircleShape.cpp
... ... @@ -0,0 +1,100 @@
  1 +/*
  2 +* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
  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 +#include <Box2D/Collision/Shapes/b2CircleShape.h>
  20 +#include <new>
  21 +using namespace std;
  22 +
  23 +b2Shape* b2CircleShape::Clone(b2BlockAllocator* allocator) const
  24 +{
  25 + void* mem = allocator->Allocate(sizeof(b2CircleShape));
  26 + b2CircleShape* clone = new (mem) b2CircleShape;
  27 + *clone = *this;
  28 + return clone;
  29 +}
  30 +
  31 +int32 b2CircleShape::GetChildCount() const
  32 +{
  33 + return 1;
  34 +}
  35 +
  36 +bool b2CircleShape::TestPoint(const b2Transform& transform, const b2Vec2& p) const
  37 +{
  38 + b2Vec2 center = transform.position + b2Mul(transform.R, m_p);
  39 + b2Vec2 d = p - center;
  40 + return b2Dot(d, d) <= m_radius * m_radius;
  41 +}
  42 +
  43 +// Collision Detection in Interactive 3D Environments by Gino van den Bergen
  44 +// From Section 3.1.2
  45 +// x = s + a * r
  46 +// norm(x) = radius
  47 +bool b2CircleShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
  48 + const b2Transform& transform, int32 childIndex) const
  49 +{
  50 + B2_NOT_USED(childIndex);
  51 +
  52 + b2Vec2 position = transform.position + b2Mul(transform.R, m_p);
  53 + b2Vec2 s = input.p1 - position;
  54 + float32 b = b2Dot(s, s) - m_radius * m_radius;
  55 +
  56 + // Solve quadratic equation.
  57 + b2Vec2 r = input.p2 - input.p1;
  58 + float32 c = b2Dot(s, r);
  59 + float32 rr = b2Dot(r, r);
  60 + float32 sigma = c * c - rr * b;
  61 +
  62 + // Check for negative discriminant and short segment.
  63 + if (sigma < 0.0f || rr < b2_epsilon)
  64 + {
  65 + return false;
  66 + }
  67 +
  68 + // Find the point of intersection of the line with the circle.
  69 + float32 a = -(c + b2Sqrt(sigma));
  70 +
  71 + // Is the intersection point on the segment?
  72 + if (0.0f <= a && a <= input.maxFraction * rr)
  73 + {
  74 + a /= rr;
  75 + output->fraction = a;
  76 + output->normal = s + a * r;
  77 + output->normal.Normalize();
  78 + return true;
  79 + }
  80 +
  81 + return false;
  82 +}
  83 +
  84 +void b2CircleShape::ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const
  85 +{
  86 + B2_NOT_USED(childIndex);
  87 +
  88 + b2Vec2 p = transform.position + b2Mul(transform.R, m_p);
  89 + aabb->lowerBound.Set(p.x - m_radius, p.y - m_radius);
  90 + aabb->upperBound.Set(p.x + m_radius, p.y + m_radius);
  91 +}
  92 +
  93 +void b2CircleShape::ComputeMass(b2MassData* massData, float32 density) const
  94 +{
  95 + massData->mass = density * b2_pi * m_radius * m_radius;
  96 + massData->center = m_p;
  97 +
  98 + // inertia about the local origin
  99 + massData->I = massData->mass * (0.5f * m_radius * m_radius + b2Dot(m_p, m_p));
  100 +}
91 application/lib/box2d/Box2D/Collision/Shapes/b2CircleShape.h
... ... @@ -0,0 +1,91 @@
  1 +/*
  2 +* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
  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 B2_CIRCLE_SHAPE_H
  20 +#define B2_CIRCLE_SHAPE_H
  21 +
  22 +#include <Box2D/Collision/Shapes/b2Shape.h>
  23 +
  24 +/// A circle shape.
  25 +class b2CircleShape : public b2Shape
  26 +{
  27 +public:
  28 + b2CircleShape();
  29 +
  30 + /// Implement b2Shape.
  31 + b2Shape* Clone(b2BlockAllocator* allocator) const;
  32 +
  33 + /// @see b2Shape::GetChildCount
  34 + int32 GetChildCount() const;
  35 +
  36 + /// Implement b2Shape.
  37 + bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
  38 +
  39 + /// Implement b2Shape.
  40 + bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
  41 + const b2Transform& transform, int32 childIndex) const;
  42 +
  43 + /// @see b2Shape::ComputeAABB
  44 + void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
  45 +
  46 + /// @see b2Shape::ComputeMass
  47 + void ComputeMass(b2MassData* massData, float32 density) const;
  48 +
  49 + /// Get the supporting vertex index in the given direction.
  50 + int32 GetSupport(const b2Vec2& d) const;
  51 +
  52 + /// Get the supporting vertex in the given direction.
  53 + const b2Vec2& GetSupportVertex(const b2Vec2& d) const;
  54 +
  55 + /// Get the vertex count.
  56 + int32 GetVertexCount() const { return 1; }
  57 +
  58 + /// Get a vertex by index. Used by b2Distance.
  59 + const b2Vec2& GetVertex(int32 index) const;
  60 +
  61 + /// Position
  62 + b2Vec2 m_p;
  63 +};
  64 +
  65 +inline b2CircleShape::b2CircleShape()
  66 +{
  67 + m_type = e_circle;
  68 + m_radius = 0.0f;
  69 + m_p.SetZero();
  70 +}
  71 +
  72 +inline int32 b2CircleShape::GetSupport(const b2Vec2 &d) const
  73 +{
  74 + B2_NOT_USED(d);
  75 + return 0;
  76 +}
  77 +
  78 +inline const b2Vec2& b2CircleShape::GetSupportVertex(const b2Vec2 &d) const
  79 +{
  80 + B2_NOT_USED(d);
  81 + return m_p;
  82 +}
  83 +
  84 +inline const b2Vec2& b2CircleShape::GetVertex(int32 index) const
  85 +{
  86 + B2_NOT_USED(index);
  87 + b2Assert(index == 0);
  88 + return m_p;
  89 +}
  90 +
  91 +#endif
139 application/lib/box2d/Box2D/Collision/Shapes/b2EdgeShape.cpp
... ... @@ -0,0 +1,139 @@
  1 +/*
  2 +* Copyright (c) 2006-2010 Erin Catto http://www.gphysics.com
  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 +#include <Box2D/Collision/Shapes/b2EdgeShape.h>
  20 +#include <new>
  21 +using namespace std;
  22 +
  23 +void b2EdgeShape::Set(const b2Vec2& v1, const b2Vec2& v2)
  24 +{
  25 + m_vertex1 = v1;
  26 + m_vertex2 = v2;
  27 + m_hasVertex0 = false;
  28 + m_hasVertex3 = false;
  29 +}
  30 +
  31 +b2Shape* b2EdgeShape::Clone(b2BlockAllocator* allocator) const
  32 +{
  33 + void* mem = allocator->Allocate(sizeof(b2EdgeShape));
  34 + b2EdgeShape* clone = new (mem) b2EdgeShape;
  35 + *clone = *this;
  36 + return clone;
  37 +}
  38 +
  39 +int32 b2EdgeShape::GetChildCount() const
  40 +{
  41 + return 1;
  42 +}
  43 +
  44 +bool b2EdgeShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
  45 +{
  46 + B2_NOT_USED(xf);
  47 + B2_NOT_USED(p);
  48 + return false;
  49 +}
  50 +
  51 +// p = p1 + t * d
  52 +// v = v1 + s * e
  53 +// p1 + t * d = v1 + s * e
  54 +// s * e - t * d = p1 - v1
  55 +bool b2EdgeShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
  56 + const b2Transform& xf, int32 childIndex) const
  57 +{
  58 + B2_NOT_USED(childIndex);
  59 +
  60 + // Put the ray into the edge's frame of reference.
  61 + b2Vec2 p1 = b2MulT(xf.R, input.p1 - xf.position);
  62 + b2Vec2 p2 = b2MulT(xf.R, input.p2 - xf.position);
  63 + b2Vec2 d = p2 - p1;
  64 +
  65 + b2Vec2 v1 = m_vertex1;
  66 + b2Vec2 v2 = m_vertex2;
  67 + b2Vec2 e = v2 - v1;
  68 + b2Vec2 normal(e.y, -e.x);
  69 + normal.Normalize();
  70 +
  71 + // q = p1 + t * d
  72 + // dot(normal, q - v1) = 0
  73 + // dot(normal, p1 - v1) + t * dot(normal, d) = 0
  74 + float32 numerator = b2Dot(normal, v1 - p1);
  75 + float32 denominator = b2Dot(normal, d);
  76 +
  77 + if (denominator == 0.0f)
  78 + {
  79 + return false;
  80 + }
  81 +
  82 + float32 t = numerator / denominator;
  83 + if (t < 0.0f || 1.0f < t)
  84 + {
  85 + return false;
  86 + }
  87 +
  88 + b2Vec2 q = p1 + t * d;
  89 +
  90 + // q = v1 + s * r
  91 + // s = dot(q - v1, r) / dot(r, r)
  92 + b2Vec2 r = v2 - v1;
  93 + float32 rr = b2Dot(r, r);
  94 + if (rr == 0.0f)
  95 + {
  96 + return false;
  97 + }
  98 +
  99 + float32 s = b2Dot(q - v1, r) / rr;
  100 + if (s < 0.0f || 1.0f < s)
  101 + {
  102 + return false;
  103 + }
  104 +
  105 + output->fraction = t;
  106 + if (numerator > 0.0f)
  107 + {
  108 + output->normal = -normal;
  109 + }
  110 + else
  111 + {
  112 + output->normal = normal;
  113 + }
  114 + return true;
  115 +}
  116 +
  117 +void b2EdgeShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
  118 +{
  119 + B2_NOT_USED(childIndex);
  120 +
  121 + b2Vec2 v1 = b2Mul(xf, m_vertex1);
  122 + b2Vec2 v2 = b2Mul(xf, m_vertex2);
  123 +
  124 + b2Vec2 lower = b2Min(v1, v2);
  125 + b2Vec2 upper = b2Max(v1, v2);
  126 +
  127 + b2Vec2 r(m_radius, m_radius);
  128 + aabb->lowerBound = lower - r;
  129 + aabb->upperBound = upper + r;
  130 +}
  131 +
  132 +void b2EdgeShape::ComputeMass(b2MassData* massData, float32 density) const
  133 +{
  134 + B2_NOT_USED(density);
  135 +
  136 + massData->mass = 0.0f;
  137 + massData->center = 0.5f * (m_vertex1 + m_vertex2);
  138 + massData->I = 0.0f;
  139 +}
70 application/lib/box2d/Box2D/Collision/Shapes/b2EdgeShape.h
... ... @@ -0,0 +1,70 @@
  1 +/*
  2 +* Copyright (c) 2006-2010 Erin Catto http://www.gphysics.com
  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 B2_EDGE_SHAPE_H
  20 +#define B2_EDGE_SHAPE_H
  21 +
  22 +#include <Box2D/Collision/Shapes/b2Shape.h>
  23 +
  24 +/// A line segment (edge) shape. These can be connected in chains or loops
  25 +/// to other edge shapes. The connectivity information is used to ensure
  26 +/// correct contact normals.
  27 +class b2EdgeShape : public b2Shape
  28 +{
  29 +public:
  30 + b2EdgeShape();
  31 +
  32 + /// Set this as an isolated edge.
  33 + void Set(const b2Vec2& v1, const b2Vec2& v2);
  34 +
  35 + /// Implement b2Shape.
  36 + b2Shape* Clone(b2BlockAllocator* allocator) const;
  37 +
  38 + /// @see b2Shape::GetChildCount
  39 + int32 GetChildCount() const;
  40 +
  41 + /// @see b2Shape::TestPoint
  42 + bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
  43 +
  44 + /// Implement b2Shape.
  45 + bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
  46 + const b2Transform& transform, int32 childIndex) const;
  47 +
  48 + /// @see b2Shape::ComputeAABB
  49 + void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
  50 +
  51 + /// @see b2Shape::ComputeMass
  52 + void ComputeMass(b2MassData* massData, float32 density) const;
  53 +
  54 + /// These are the edge vertices
  55 + b2Vec2 m_vertex1, m_vertex2;
  56 +
  57 + /// Optional adjacent vertices. These are used for smooth collision.
  58 + b2Vec2 m_vertex0, m_vertex3;
  59 + bool m_hasVertex0, m_hasVertex3;
  60 +};
  61 +
  62 +inline b2EdgeShape::b2EdgeShape()
  63 +{
  64 + m_type = e_edge;
  65 + m_radius = b2_polygonRadius;
  66 + m_hasVertex0 = false;
  67 + m_hasVertex3 = false;
  68 +}
  69 +
  70 +#endif
130 application/lib/box2d/Box2D/Collision/Shapes/b2LoopShape.cpp
... ... @@ -0,0 +1,130 @@
  1 +/*
  2 +* Copyright (c) 2006-2010 Erin Catto http://www.gphysics.com
  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 +#include <Box2D/Collision/Shapes/b2LoopShape.h>
  20 +#include <Box2D/Collision/Shapes/b2EdgeShape.h>
  21 +#include <new>
  22 +#include <cstring>
  23 +using namespace std;
  24 +
  25 +b2LoopShape::~b2LoopShape()
  26 +{
  27 + b2Free(m_vertices);
  28 + m_vertices = NULL;
  29 + m_count = 0;
  30 +}
  31 +
  32 +void b2LoopShape::Create(const b2Vec2* vertices, int32 count)
  33 +{
  34 + b2Assert(m_vertices == NULL && m_count == 0);
  35 + b2Assert(count >= 2);
  36 + m_count = count;
  37 + m_vertices = (b2Vec2*)b2Alloc(count * sizeof(b2Vec2));
  38 + memcpy(m_vertices, vertices, m_count * sizeof(b2Vec2));
  39 +}
  40 +
  41 +b2Shape* b2LoopShape::Clone(b2BlockAllocator* allocator) const
  42 +{
  43 + void* mem = allocator->Allocate(sizeof(b2LoopShape));
  44 + b2LoopShape* clone = new (mem) b2LoopShape;
  45 + clone->Create(m_vertices, m_count);
  46 + return clone;
  47 +}
  48 +
  49 +int32 b2LoopShape::GetChildCount() const
  50 +{
  51 + return m_count;
  52 +}
  53 +
  54 +void b2LoopShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
  55 +{
  56 + b2Assert(2 <= m_count);
  57 + b2Assert(0 <= index && index < m_count);
  58 + edge->m_type = b2Shape::e_edge;
  59 + edge->m_radius = m_radius;
  60 + edge->m_hasVertex0 = true;
  61 + edge->m_hasVertex3 = true;
  62 +
  63 + int32 i0 = index - 1 >= 0 ? index - 1 : m_count - 1;
  64 + int32 i1 = index;
  65 + int32 i2 = index + 1 < m_count ? index + 1 : 0;
  66 + int32 i3 = index + 2;
  67 + while (i3 >= m_count)
  68 + {
  69 + i3 -= m_count;
  70 + }
  71 +
  72 + edge->m_vertex0 = m_vertices[i0];
  73 + edge->m_vertex1 = m_vertices[i1];
  74 + edge->m_vertex2 = m_vertices[i2];
  75 + edge->m_vertex3 = m_vertices[i3];
  76 +}
  77 +
  78 +bool b2LoopShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
  79 +{
  80 + B2_NOT_USED(xf);
  81 + B2_NOT_USED(p);
  82 + return false;
  83 +}
  84 +
  85 +bool b2LoopShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
  86 + const b2Transform& xf, int32 childIndex) const
  87 +{
  88 + b2Assert(childIndex < m_count);
  89 +
  90 + b2EdgeShape edgeShape;
  91 +
  92 + int32 i1 = childIndex;
  93 + int32 i2 = childIndex + 1;
  94 + if (i2 == m_count)
  95 + {
  96 + i2 = 0;
  97 + }
  98 +
  99 + edgeShape.m_vertex1 = m_vertices[i1];
  100 + edgeShape.m_vertex2 = m_vertices[i2];
  101 +
  102 + return edgeShape.RayCast(output, input, xf, 0);
  103 +}
  104 +
  105 +void b2LoopShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIndex) const
  106 +{
  107 + b2Assert(childIndex < m_count);
  108 +
  109 + int32 i1 = childIndex;
  110 + int32 i2 = childIndex + 1;
  111 + if (i2 == m_count)
  112 + {
  113 + i2 = 0;
  114 + }
  115 +
  116 + b2Vec2 v1 = b2Mul(xf, m_vertices[i1]);
  117 + b2Vec2 v2 = b2Mul(xf, m_vertices[i2]);
  118 +
  119 + aabb->lowerBound = b2Min(v1, v2);
  120 + aabb->upperBound = b2Max(v1, v2);
  121 +}
  122 +
  123 +void b2LoopShape::ComputeMass(b2MassData* massData, float32 density) const
  124 +{
  125 + B2_NOT_USED(density);
  126 +
  127 + massData->mass = 0.0f;
  128 + massData->center.SetZero();
  129 + massData->I = 0.0f;
  130 +}
96 application/lib/box2d/Box2D/Collision/Shapes/b2LoopShape.h
... ... @@ -0,0 +1,96 @@
  1 +/*
  2 +* Copyright (c) 2006-2010 Erin Catto http://www.gphysics.com
  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 B2_LOOP_SHAPE_H
  20 +#define B2_LOOP_SHAPE_H
  21 +
  22 +#include <Box2D/Collision/Shapes/b2Shape.h>
  23 +
  24 +class b2EdgeShape;
  25 +
  26 +/// A loop shape is a free form sequence of line segments that form a circular list.
  27 +/// The loop may cross upon itself, but this is not recommended for smooth collision.
  28 +/// The loop has double sided collision, so you can use inside and outside collision.
  29 +/// Therefore, you may use any winding order.
  30 +/// Since there may be many vertices, they are allocated using b2Alloc.
  31 +class b2LoopShape : public b2Shape
  32 +{
  33 +public:
  34 + b2LoopShape();
  35 +
  36 + /// The destructor frees the vertices using b2Free.
  37 + ~b2LoopShape();
  38 +
  39 + /// Create the loop shape, copy all vertices.
  40 + void Create(const b2Vec2* vertices, int32 count);
  41 +
  42 + /// Implement b2Shape. Vertices are cloned using b2Alloc.
  43 + b2Shape* Clone(b2BlockAllocator* allocator) const;
  44 +
  45 + /// @see b2Shape::GetChildCount
  46 + int32 GetChildCount() const;
  47 +
  48 + /// Get a child edge.
  49 + void GetChildEdge(b2EdgeShape* edge, int32 index) const;
  50 +
  51 + /// This always return false.
  52 + /// @see b2Shape::TestPoint
  53 + bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
  54 +
  55 + /// Implement b2Shape.
  56 + bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
  57 + const b2Transform& transform, int32 childIndex) const;
  58 +
  59 + /// @see b2Shape::ComputeAABB
  60 + void ComputeAABB(b2AABB* aabb, const b2Transform& transform, int32 childIndex) const;
  61 +
  62 + /// Chains have zero mass.
  63 + /// @see b2Shape::ComputeMass
  64 + void ComputeMass(b2MassData* massData, float32 density) const;
  65 +
  66 + /// Get the number of vertices.
  67 + int32 GetCount() const { return m_count; }
  68 +
  69 + /// Get the vertices (read-only).
  70 + const b2Vec2& GetVertex(int32 index) const
  71 + {
  72 + b2Assert(0 <= index && index < m_count);
  73 + return m_vertices[index];
  74 + }
  75 +
  76 + /// Get the vertices (read-only).
  77 + const b2Vec2* GetVertices() const { return m_vertices; }
  78 +
  79 +protected:
  80 +
  81 + /// The vertices. Owned by this class.
  82 + b2Vec2* m_vertices;
  83 +
  84 + /// The vertex count.
  85 + int32 m_count;
  86 +};
  87 +
  88 +inline b2LoopShape::b2LoopShape()
  89 +{
  90 + m_type = e_loop;
  91 + m_radius = b2_polygonRadius;
  92 + m_vertices = NULL;
  93 + m_count = 0;
  94 +}
  95 +
  96 +#endif
364 application/lib/box2d/Box2D/Collision/Shapes/b2PolygonShape.cpp
... ... @@ -0,0 +1,364 @@
  1 +/*
  2 +* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
  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 +#include <Box2D/Collision/Shapes/b2PolygonShape.h>
  20 +#include <new>
  21 +
  22 +b2Shape* b2PolygonShape::Clone(b2BlockAllocator* allocator) const
  23 +{
  24 + void* mem = allocator->Allocate(sizeof(b2PolygonShape));
  25 + b2PolygonShape* clone = new (mem) b2PolygonShape;
  26 + *clone = *this;
  27 + return clone;
  28 +}
  29 +
  30 +void b2PolygonShape::SetAsBox(float32 hx, float32 hy)
  31 +{
  32 + m_vertexCount = 4;
  33 + m_vertices[0].Set(-hx, -hy);
  34 + m_vertices[1].Set( hx, -hy);
  35 + m_vertices[2].Set( hx, hy);
  36 + m_vertices[3].Set(-hx, hy);
  37 + m_normals[0].Set(0.0f, -1.0f);
  38 + m_normals[1].Set(1.0f, 0.0f);
  39 + m_normals[2].Set(0.0f, 1.0f);
  40 + m_normals[3].Set(-1.0f, 0.0f);
  41 + m_centroid.SetZero();
  42 +}
  43 +
  44 +void b2PolygonShape::SetAsBox(float32 hx, float32 hy, const b2Vec2& center, float32 angle)
  45 +{
  46 + m_vertexCount = 4;
  47 + m_vertices[0].Set(-hx, -hy);
  48 + m_vertices[1].Set( hx, -hy);
  49 + m_vertices[2].Set( hx, hy);
  50 + m_vertices[3].Set(-hx, hy);
  51 + m_normals[0].Set(0.0f, -1.0f);
  52 + m_normals[1].Set(1.0f, 0.0f);
  53 + m_normals[2].Set(0.0f, 1.0f);
  54 + m_normals[3].Set(-1.0f, 0.0f);
  55 + m_centroid = center;
  56 +
  57 + b2Transform xf;
  58 + xf.position = center;
  59 + xf.R.Set(angle);
  60 +
  61 + // Transform vertices and normals.
  62 + for (int32 i = 0; i < m_vertexCount; ++i)
  63 + {
  64 + m_vertices[i] = b2Mul(xf, m_vertices[i]);
  65 + m_normals[i] = b2Mul(xf.R, m_normals[i]);
  66 + }
  67 +}
  68 +
  69 +int32 b2PolygonShape::GetChildCount() const
  70 +{
  71 + return 1;
  72 +}
  73 +
  74 +static b2Vec2 ComputeCentroid(const b2Vec2* vs, int32 count)
  75 +{
  76 + b2Assert(count >= 3);
  77 +
  78 + b2Vec2 c; c.Set(0.0f, 0.0f);
  79 + float32 area = 0.0f;
  80 +
  81 + // pRef is the reference point for forming triangles.
  82 + // It's location doesn't change the result (except for rounding error).
  83 + b2Vec2 pRef(0.0f, 0.0f);
  84 +#if 0
  85 + // This code would put the reference point inside the polygon.
  86 + for (int32 i = 0; i < count; ++i)
  87 + {
  88 + pRef += vs[i];
  89 + }