aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwaterpatch.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llwaterpatch.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llwaterpatch.cpp131
1 files changed, 131 insertions, 0 deletions
diff --git a/linden/indra/newview/llwaterpatch.cpp b/linden/indra/newview/llwaterpatch.cpp
new file mode 100644
index 0000000..6c71861
--- /dev/null
+++ b/linden/indra/newview/llwaterpatch.cpp
@@ -0,0 +1,131 @@
1/**
2 * @file llwaterpatch.cpp
3 * @brief LLWaterTri class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llwaterpatch.h"
31
32#include "llvowater.h"
33
34U32 LLWaterTri::sMinStep;
35LL2Coord LLWaterTri::sCam;
36F32 LLWaterTri::sClipFar;
37U32 LLWaterTri::sMaxDivLevel;
38BOOL LLWaterTri::sCurrRound = FALSE;
39
40
41LLWaterTri::LLWaterTri (U8 level, S8 type, LLWaterTri* par): LLRoamTriNode(level, type, par), mRefine(FALSE)
42{
43 if (!parent() || type == 0)
44 {
45 mSize = mLvtx.distance(mRvtx) * sMinStep;
46 mCurr = sCurrRound;
47 setNotUpToDate();
48 return;
49 }
50
51 mSize = par->size() * OO_SQRT2;
52 setPatch(par->patch());
53 // LL2Coord c1 = par->Lvtx();
54 // LL2Coord c2 = par->Rvtx();
55
56 // if (c1.x() - c2.x() == 1 || c1.y() - c2.y() == 1)
57 // bool stophere = true;
58
59 if (type < 0) // left child
60 {
61 mLvtx = par->Tvtx();
62 mRvtx = par->Lvtx();
63 //mTvtx = middle(c1, c2);
64 } else {
65 mRvtx = par->Tvtx();
66 mLvtx = par->Rvtx();
67 //mTvtx = middle(c1, c2);
68 }
69 mTvtx = par->middleSide();
70 mMiddle = mLvtx.middle(mRvtx);
71 if (((LLWaterPatch*)patch())->visible())
72 setNotUpToDate();
73 else
74 setUpToDate();
75}
76
77
78void LLWaterTri::updatePassive()
79{
80 setUpToDate();
81 if (!leaf())
82 {
83 mLchild->updatePassive();
84 mRchild->updatePassive();
85 }
86}
87
88
89BOOL LLWaterTri::refine()
90{
91 if (upToDate())
92 return mRefine;
93
94 if (!patch()->refine(this))
95 {
96 setUpToDate();
97 mRefine = FALSE;
98 return mRefine;
99 }
100
101 const static F32 a = 0.6f;
102 const static F32 K = sMinStep / 50.f;//0.08f;
103 const static F32 eps = K;//0.01f;
104
105 const F32 tri_dist = llmin(sCam.distance(middleSide()) * sMinStep, sClipFar);
106 const F32 func = K * (1 - (1 - eps) * exp(a * (tri_dist - sClipFar)));
107
108
109 //const F32 tri_size = distance(mLvtx, mRvtx) * sMinStep;// * min_step2;
110 const F32 ratio = mSize / (tri_dist + 1);
111
112 if (tri_dist > 0.8 * sClipFar)
113 mRefine = ratio > func;
114 else
115 mRefine = (ratio > func) && (mLevel < sMaxDivLevel);
116
117 if (!mRefine && !mLeaf)
118 {
119 if (mLchild->refine())
120 mRefine = TRUE;
121 else if (mRchild->refine())
122 mRefine = TRUE;
123 }
124
125 setUpToDate();
126 return mRefine;
127
128 //return mGrid->refine(this);
129 //return FALSE;
130}
131