OffMeshConnection.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../Scene/Component.h"
  24. namespace Urho3D
  25. {
  26. /// A link between otherwise unconnected regions of the navigation mesh.
  27. class URHO3D_API OffMeshConnection : public Component
  28. {
  29. URHO3D_OBJECT(OffMeshConnection, Component);
  30. public:
  31. /// Construct.
  32. explicit OffMeshConnection(Context* context);
  33. /// Destruct.
  34. ~OffMeshConnection() override;
  35. /// Register object factory.
  36. static void RegisterObject(Context* context);
  37. /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
  38. void ApplyAttributes() override;
  39. /// Visualize the component as debug geometry.
  40. void DrawDebugGeometry(DebugRenderer* debug, bool depthTest) override;
  41. /// Set endpoint node.
  42. /// @property
  43. void SetEndPoint(Node* node);
  44. /// Set radius.
  45. /// @property
  46. void SetRadius(float radius);
  47. /// Set bidirectional flag. Default true.
  48. /// @property
  49. void SetBidirectional(bool enabled);
  50. /// Set a user assigned mask.
  51. /// @property
  52. void SetMask(unsigned newMask);
  53. /// Sets the assigned area Id for the connection.
  54. /// @property
  55. void SetAreaID(unsigned newAreaID);
  56. /// Return endpoint node.
  57. /// @property
  58. Node* GetEndPoint() const;
  59. /// Return radius.
  60. /// @property
  61. float GetRadius() const { return radius_; }
  62. /// Return whether is bidirectional.
  63. /// @property
  64. bool IsBidirectional() const { return bidirectional_; }
  65. /// Return the user assigned mask.
  66. /// @property
  67. unsigned GetMask() const { return mask_; }
  68. /// Return the user assigned area ID.
  69. /// @property
  70. unsigned GetAreaID() const { return areaId_; }
  71. private:
  72. /// Mark end point dirty.
  73. void MarkEndPointDirty() { endPointDirty_ = true; }
  74. /// Endpoint node.
  75. WeakPtr<Node> endPoint_;
  76. /// Endpoint node ID.
  77. unsigned endPointID_;
  78. /// Radius.
  79. float radius_;
  80. /// Bidirectional flag.
  81. bool bidirectional_;
  82. /// Endpoint changed flag.
  83. bool endPointDirty_;
  84. /// Flags mask to represent properties of this mesh.
  85. unsigned mask_;
  86. /// Area id to be used for this off mesh connection's internal poly.
  87. unsigned areaId_;
  88. };
  89. }