PageRenderTime 28ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llregionposition.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 94 lines | 57 code | 12 blank | 25 comment | 2 complexity | 25e0f209b42f5936546a7021f1861496 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llregionposition.cpp
  3. * @brief Region position storing class definition
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llregionposition.h"
  28. #include "llagent.h"
  29. #include "llworld.h"
  30. #include "llviewerregion.h"
  31. LLRegionPosition::LLRegionPosition()
  32. {
  33. mRegionp = NULL;
  34. }
  35. LLRegionPosition::LLRegionPosition(LLViewerRegion *regionp, const LLVector3 &position)
  36. {
  37. mRegionp = regionp;
  38. mPositionRegion = position;
  39. }
  40. LLRegionPosition::LLRegionPosition(const LLVector3d &global_position)
  41. {
  42. setPositionGlobal(global_position);
  43. }
  44. LLViewerRegion *LLRegionPosition::getRegion() const
  45. {
  46. return mRegionp;
  47. }
  48. const LLVector3 &LLRegionPosition::getPositionRegion() const
  49. {
  50. return mPositionRegion;
  51. }
  52. const LLVector3 LLRegionPosition::getPositionAgent() const
  53. {
  54. return mRegionp->getPosAgentFromRegion( mPositionRegion );
  55. }
  56. LLVector3d LLRegionPosition::getPositionGlobal() const
  57. {
  58. if (mRegionp)
  59. {
  60. return mRegionp->getPosGlobalFromRegion(mPositionRegion);
  61. }
  62. else
  63. {
  64. LLVector3d pos_global;
  65. pos_global.setVec(mPositionRegion);
  66. return pos_global;
  67. }
  68. }
  69. void LLRegionPosition::setPositionGlobal(const LLVector3d& position_global )
  70. {
  71. mRegionp = LLWorld::getInstance()->getRegionFromPosGlobal(position_global);
  72. if (mRegionp)
  73. {
  74. mPositionRegion = mRegionp->getPosRegionFromGlobal(position_global);
  75. }
  76. else
  77. {
  78. mRegionp = gAgent.getRegion();
  79. llassert(mRegionp);
  80. mPositionRegion = mRegionp->getPosRegionFromGlobal(position_global);
  81. }
  82. }