PhysicsUtils2D.h 681 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. /// \file
  4. /// @nobindfile
  5. #pragma once
  6. #include "../Math/Color.h"
  7. #include "../Math/Vector2.h"
  8. #include "../Math/Vector3.h"
  9. #include <box2d/box2d.h>
  10. namespace Urho3D
  11. {
  12. inline Color ToColor(const b2Color& color)
  13. {
  14. return Color(color.r, color.g, color.b);
  15. }
  16. inline b2Vec2 ToB2Vec2(const Vector2& vector)
  17. {
  18. return {vector.x_, vector.y_};
  19. }
  20. inline Vector2 ToVector2(const b2Vec2& vec2)
  21. {
  22. return Vector2(vec2.x, vec2.y);
  23. }
  24. inline b2Vec2 ToB2Vec2(const Vector3& vector)
  25. {
  26. return {vector.x_, vector.y_};
  27. }
  28. inline Vector3 ToVector3(const b2Vec2& vec2)
  29. {
  30. return Vector3(vec2.x, vec2.y, 0.0f);
  31. }
  32. }