PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 6ms RepoModel.GetById 14ms 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
 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
27#include "llviewerprecompiledheaders.h"
28
29#include "llregionposition.h"
30
31#include "llagent.h"
32#include "llworld.h"
33#include "llviewerregion.h"
34
35LLRegionPosition::LLRegionPosition()
36{
37	mRegionp = NULL;
38}
39
40LLRegionPosition::LLRegionPosition(LLViewerRegion *regionp, const LLVector3 &position)
41{
42	mRegionp = regionp;
43	mPositionRegion = position;
44}
45
46LLRegionPosition::LLRegionPosition(const LLVector3d &global_position)
47{
48	setPositionGlobal(global_position);
49}
50
51LLViewerRegion *LLRegionPosition::getRegion() const
52{
53	return mRegionp;
54}
55
56const LLVector3 &LLRegionPosition::getPositionRegion() const
57{
58	return mPositionRegion;
59}
60
61const LLVector3 LLRegionPosition::getPositionAgent() const
62{
63	return mRegionp->getPosAgentFromRegion( mPositionRegion );
64}
65
66LLVector3d LLRegionPosition::getPositionGlobal() const
67{
68	if (mRegionp)
69	{
70		return mRegionp->getPosGlobalFromRegion(mPositionRegion);
71	}
72	else
73	{
74		LLVector3d pos_global;
75		pos_global.setVec(mPositionRegion);
76		return pos_global;
77	}
78}
79
80
81void LLRegionPosition::setPositionGlobal(const LLVector3d& position_global )
82{
83	mRegionp = LLWorld::getInstance()->getRegionFromPosGlobal(position_global);
84	if (mRegionp)
85	{
86		mPositionRegion = mRegionp->getPosRegionFromGlobal(position_global);
87	}
88	else
89	{
90		mRegionp = gAgent.getRegion();
91		llassert(mRegionp);
92		mPositionRegion = mRegionp->getPosRegionFromGlobal(position_global);
93	}
94}