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.

75 lines
2.4KB

  1. /*
  2. * Copyright (c) 2006-2010 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 B2_EDGE_SHAPE_H
  19. #define B2_EDGE_SHAPE_H
  20. #include "b2Shape.h"
  21. /// A line segment (edge) shape. These can be connected in chains or loops
  22. /// to other edge shapes. The connectivity information is used to ensure
  23. /// correct contact normals.
  24. class b2EdgeShape : public b2Shape
  25. {
  26. public:
  27. b2EdgeShape();
  28. /// Set this as an isolated edge.
  29. void Set(const b2Vec2& v1, const b2Vec2& v2);
  30. /// Implement b2Shape.
  31. b2Shape* Clone(b2BlockAllocator* allocator) const;
  32. /// @see b2Shape::GetChildCount
  33. juce::int32 GetChildCount() const;
  34. /// @see b2Shape::TestPoint
  35. bool TestPoint(const b2Transform& transform, const b2Vec2& p) const;
  36. /// Implement b2Shape.
  37. bool RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
  38. const b2Transform& transform, juce::int32 childIndex) const;
  39. /// @see b2Shape::ComputeAABB
  40. void ComputeAABB(b2AABB* aabb, const b2Transform& transform, juce::int32 childIndex) const;
  41. /// @see b2Shape::ComputeMass
  42. void ComputeMass(b2MassData* massData, float32 density) const;
  43. /// These are the edge vertices
  44. b2Vec2 m_vertex1, m_vertex2;
  45. /// Optional adjacent vertices. These are used for smooth collision.
  46. b2Vec2 m_vertex0, m_vertex3;
  47. bool m_hasVertex0, m_hasVertex3;
  48. };
  49. inline b2EdgeShape::b2EdgeShape()
  50. {
  51. m_type = e_edge;
  52. m_radius = b2_polygonRadius;
  53. m_vertex0.x = 0.0f;
  54. m_vertex0.y = 0.0f;
  55. m_vertex3.x = 0.0f;
  56. m_vertex3.y = 0.0f;
  57. m_hasVertex0 = false;
  58. m_hasVertex3 = false;
  59. }
  60. #endif