llpathfindingmanager.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /**
  2. * @file llpathfindingmanager.h
  3. * @brief Header file for llpathfindingmanager
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewergpl$
  6. *
  7. * Copyright (c) 2012, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLPATHFINDINGMANAGER_H
  33. #define LL_LLPATHFINDINGMANAGER_H
  34. #include <string>
  35. #include "boost/function.hpp"
  36. #include "boost/signals2.hpp"
  37. #include "llcorehttpheaders.h"
  38. #include "llcorehttpoptions.h"
  39. #include "hbfastmap.h"
  40. #include "llsingleton.h"
  41. #include "llpathfindinglinkset.h"
  42. #include "llpathfindingnavmesh.h"
  43. #include "llpathfindingobjectlist.h"
  44. // We do not have access to the closed source Havok library for path-finding GL
  45. // drawing. *TODO: find an Open Source equivalent.
  46. #define HAVE_PATHINGLIB 0
  47. class LinksetsResponder;
  48. class LLPathfindingNavMeshStatus;
  49. class LLViewerRegion;
  50. class LLPathfindingManager : public LLSingleton<LLPathfindingManager>
  51. {
  52. friend class LLSingleton<LLPathfindingManager>;
  53. friend class LLNavMeshSimStateChangeNode;
  54. friend class NavMeshStatusResponder;
  55. friend class LLAgentStateChangeNode;
  56. friend class AgentStateResponder;
  57. protected:
  58. LOG_CLASS(LLPathfindingManager);
  59. public:
  60. typedef enum {
  61. kRequestStarted,
  62. kRequestCompleted,
  63. kRequestNotEnabled,
  64. kRequestError
  65. } ERequestStatus;
  66. LLPathfindingManager();
  67. virtual ~LLPathfindingManager();
  68. bool isPathfindingEnabledForCurrentRegion() const;
  69. bool isPathfindingEnabledForRegion(LLViewerRegion* region) const;
  70. #if HAVE_PATHINGLIB
  71. bool isPathfindingViewEnabled() const;
  72. #endif
  73. bool isAllowViewTerrainProperties() const;
  74. LLPathfindingNavMesh::navmesh_slot_t registerNavMeshListenerForRegion(LLViewerRegion* region,
  75. LLPathfindingNavMesh::navmesh_cb_t cb);
  76. void requestGetNavMeshForRegion(LLViewerRegion* region,
  77. bool get_status_only);
  78. typedef U32 request_id_t;
  79. typedef boost::function<void(request_id_t, ERequestStatus,
  80. LLPathfindingObjectList::ptr_t)> object_request_cb_t;
  81. void requestGetLinksets(request_id_t req_id, object_request_cb_t cb) const;
  82. void requestSetLinksets(request_id_t req_id,
  83. const LLPathfindingObjectList::ptr_t& pobjects,
  84. LLPathfindingLinkset::ELinksetUse use,
  85. S32 pA, S32 pB, S32 pC, S32 pD,
  86. object_request_cb_t cb) const;
  87. void requestGetCharacters(request_id_t req_id,
  88. object_request_cb_t cb) const;
  89. typedef boost::function<void(bool)> agent_state_cb_t;
  90. typedef boost::signals2::signal<void(bool)> agent_state_signal_t;
  91. typedef boost::signals2::connection agent_state_slot_t;
  92. agent_state_slot_t registerAgentStateListener(agent_state_cb_t cb);
  93. void requestGetAgentState();
  94. typedef boost::function<void (bool)> rebake_navmesh_cb_t;
  95. void requestRebakeNavMesh(rebake_navmesh_cb_t cb);
  96. private:
  97. void handleDeferredGetAgentStateForRegion(const LLUUID& region_id);
  98. void handleDeferredGetNavMeshForRegion(const LLUUID& region_id,
  99. bool get_status_only);
  100. void handleDeferredGetLinksetsForRegion(const LLUUID& region_id,
  101. request_id_t req_id,
  102. object_request_cb_t cb) const;
  103. void handleDeferredGetCharactersForRegion(const LLUUID& region_id,
  104. request_id_t req_id,
  105. object_request_cb_t cb) const;
  106. void navMeshStatusRequestCoro(const std::string& url, U64 region_handle,
  107. bool get_status_only);
  108. void navAgentStateRequestCoro(const std::string& url);
  109. void navMeshRebakeCoro(const std::string& url, rebake_navmesh_cb_t cb);
  110. void linksetObjectsCoro(const std::string& url,
  111. std::shared_ptr<LinksetsResponder> responder,
  112. LLSD put_data) const;
  113. void linksetTerrainCoro(const std::string& url,
  114. std::shared_ptr<LinksetsResponder> responder,
  115. LLSD put_data) const;
  116. void charactersCoro(const std::string& url, request_id_t req_id,
  117. object_request_cb_t cb) const;
  118. void handleNavMeshStatusUpdate(const LLPathfindingNavMeshStatus& status);
  119. void handleAgentState(bool can_rebake_region);
  120. LLPathfindingNavMesh::ptr_t getNavMeshForRegion(const LLUUID& region_id);
  121. LLPathfindingNavMesh::ptr_t getNavMeshForRegion(LLViewerRegion* region);
  122. const std::string getNavMeshStatusURLForCurrentRegion() const;
  123. const std::string getNavMeshStatusURLForRegion(LLViewerRegion* r) const;
  124. const std::string getRetrieveNavMeshURLForRegion(LLViewerRegion* r) const;
  125. const std::string getRetrieveObjectLinksetsURLForCurrentRegion() const;
  126. const std::string getChangeObjectLinksetsURLForCurrentRegion() const;
  127. const std::string getTerrainLinksetsURLForCurrentRegion() const;
  128. const std::string getCharactersURLForCurrentRegion() const;
  129. const std::string getAgentStateURLForRegion(LLViewerRegion* region) const;
  130. const std::string getRegionCapability(LLViewerRegion* region,
  131. const char* cap_name) const;
  132. private:
  133. LLCore::HttpOptions::ptr_t mHttpOptions;
  134. LLCore::HttpHeaders::ptr_t mHttpHeaders;
  135. typedef fast_hmap<LLUUID, LLPathfindingNavMesh::ptr_t> map_t;
  136. map_t mNavMeshMap;
  137. agent_state_signal_t mAgentStateSignal;
  138. };
  139. #endif // LL_LLPATHFINDINGMANAGER_H