OffMeshConnection.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "../Scene/Component.h"
  5. namespace Urho3D
  6. {
  7. /// A link between otherwise unconnected regions of the navigation mesh.
  8. class URHO3D_API OffMeshConnection : public Component
  9. {
  10. URHO3D_OBJECT(OffMeshConnection, Component);
  11. public:
  12. /// Construct.
  13. explicit OffMeshConnection(Context* context);
  14. /// Destruct.
  15. ~OffMeshConnection() override;
  16. /// Register object factory.
  17. /// @nobind
  18. static void RegisterObject(Context* context);
  19. /// Apply attribute changes that can not be applied immediately. Called after scene load or a network update.
  20. void ApplyAttributes() override;
  21. /// Visualize the component as debug geometry.
  22. void DrawDebugGeometry(DebugRenderer* debug, bool depthTest) override;
  23. /// Set endpoint node.
  24. /// @property
  25. void SetEndPoint(Node* node);
  26. /// Set radius.
  27. /// @property
  28. void SetRadius(float radius);
  29. /// Set bidirectional flag. Default true.
  30. /// @property
  31. void SetBidirectional(bool enabled);
  32. /// Set a user assigned mask.
  33. /// @property
  34. void SetMask(unsigned newMask);
  35. /// Sets the assigned area Id for the connection.
  36. /// @property
  37. void SetAreaID(unsigned newAreaID);
  38. /// Return endpoint node.
  39. /// @property
  40. Node* GetEndPoint() const;
  41. /// Return radius.
  42. /// @property
  43. float GetRadius() const { return radius_; }
  44. /// Return whether is bidirectional.
  45. /// @property
  46. bool IsBidirectional() const { return bidirectional_; }
  47. /// Return the user assigned mask.
  48. /// @property
  49. unsigned GetMask() const { return mask_; }
  50. /// Return the user assigned area ID.
  51. /// @property
  52. unsigned GetAreaID() const { return areaId_; }
  53. private:
  54. /// Mark end point dirty.
  55. void MarkEndPointDirty() { endPointDirty_ = true; }
  56. /// Endpoint node.
  57. WeakPtr<Node> endPoint_;
  58. /// Endpoint node ID.
  59. unsigned endPointID_;
  60. /// Radius.
  61. float radius_;
  62. /// Bidirectional flag.
  63. bool bidirectional_;
  64. /// Endpoint changed flag.
  65. bool endPointDirty_;
  66. /// Flags mask to represent properties of this mesh.
  67. unsigned mask_;
  68. /// Area id to be used for this off mesh connection's internal poly.
  69. unsigned areaId_;
  70. };
  71. }