aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llcloud.h
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/llcloud.h
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/llcloud.h201
1 files changed, 201 insertions, 0 deletions
diff --git a/linden/indra/newview/llcloud.h b/linden/indra/newview/llcloud.h
new file mode 100644
index 0000000..8567792
--- /dev/null
+++ b/linden/indra/newview/llcloud.h
@@ -0,0 +1,201 @@
1/**
2 * @file llcloud.h
3 * @brief Description of viewer LLCloudLayer class
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#ifndef LL_LLCLOUD_H
29#define LL_LLCLOUD_H
30
31// Some ideas on how clouds should work
32//
33// Each region has a cloud layer
34// Each cloud layer has pre-allocated space for N clouds
35// The LLSky class knows the max number of clouds to render M.
36// All clouds use the same texture, but the tex-coords can take on 8 configurations
37// (four rotations, front and back)
38//
39// The sky's part
40// --------------
41// The sky knows that A clouds have been assigned to regions and there are B left over.
42// Divide B by number of active regions to get C.
43// Ask each region to add C more clouds and return total number D.
44// Add up all the D's to get a new A.
45//
46// The cloud layer's part
47// ----------------------
48// The cloud layer is a grid of possibility. Each grid's value represents the probablility
49// (0.0 to 1.0) that a cloud placement query will succeed.
50//
51// The sky asks the region to add C more clouds.
52// The cloud layer tries a total of E times to place clouds and returns total cloud count.
53//
54// Clouds move according to local wind velocity.
55// If a cloud moves out of region then it's location is sent to neighbor region
56// or it is allowed to drift and decay.
57//
58// The clouds in non-visible regions do not propagate every frame.
59// Each frame one non-visible region is allowed to propagate it's clouds
60// (might have to check to see if incoming cloud was already visible or not).
61//
62//
63
64#include "llmath.h"
65//#include "vmath.h"
66#include "v3math.h"
67#include "v3dmath.h"
68#include "v4math.h"
69#include "v4color.h"
70#include "llmemory.h"
71#include "lldarray.h"
72
73#include "llframetimer.h"
74
75const U32 CLOUD_GRIDS_PER_EDGE = 16;
76
77const F32 CLOUD_PUFF_WIDTH = 64.f;
78const F32 CLOUD_PUFF_HEIGHT = 48.f;
79
80class LLWind;
81class LLVOClouds;
82class LLViewerRegion;
83class LLCloudLayer;
84class LLBitPack;
85class LLGroupHeader;
86
87const S32 CLOUD_GROUPS_PER_EDGE = 4;
88
89class LLCloudPuff
90{
91public:
92 LLCloudPuff();
93
94 const LLVector3d &getPositionGlobal() const { return mPositionGlobal; }
95 friend class LLCloudGroup;
96
97 void updatePuffs(const F32 dt);
98 void updatePuffOwnership();
99
100 F32 getAlpha() const { return mAlpha; }
101 U32 getLifeState() const { return mLifeState; }
102 void setLifeState(const U32 state) { mLifeState = state; }
103 BOOL isDead() const { return mAlpha <= 0.f; }
104
105
106 static S32 sPuffCount;
107protected:
108 F32 mAlpha;
109 F32 mRate;
110 LLVector3d mPositionGlobal;
111
112 BOOL mLifeState;
113};
114
115class LLCloudGroup
116{
117public:
118 LLCloudGroup();
119
120 void cleanup();
121
122 void setCloudLayerp(LLCloudLayer *clp) { mCloudLayerp = clp; }
123 void setCenterRegion(const LLVector3 &center);
124
125 void updatePuffs(const F32 dt);
126 void updatePuffOwnership();
127 void updatePuffCount();
128
129 BOOL inGroup(const LLCloudPuff &puff) const;
130
131 F32 getDensity() const { return mDensity; }
132 S32 getNumPuffs() const { return mCloudPuffs.count(); }
133 const LLCloudPuff &getPuff(const S32 i) { return mCloudPuffs[i]; }
134protected:
135 LLCloudLayer *mCloudLayerp;
136 LLVector3 mCenterRegion;
137 F32 mDensity;
138 S32 mTargetPuffCount;
139
140 LLDynamicArray<LLCloudPuff> mCloudPuffs;
141 LLPointer<LLVOClouds> mVOCloudsp;
142};
143
144
145class LLCloudLayer
146{
147public:
148 LLCloudLayer();
149 ~LLCloudLayer();
150
151 void create(LLViewerRegion *regionp);
152 void destroy();
153
154 void reset(); // Clears all active cloud puffs
155
156
157 void updatePuffs(const F32 dt);
158 void updatePuffOwnership();
159 void updatePuffCount();
160
161 LLCloudGroup *findCloudGroup(const LLCloudPuff &puff);
162
163 void setRegion(LLViewerRegion *regionp);
164 LLViewerRegion* getRegion() const { return mRegionp; }
165 void setWindPointer(LLWind *windp);
166 void setOriginGlobal(const LLVector3d &origin_global) { mOriginGlobal = origin_global; }
167 void setWidth(F32 width);
168
169 void setBrightness(F32 brightness);
170 void setSunColor(const LLColor4 &color);
171
172 F32 getDensityRegion(const LLVector3 &pos_region); // "position" is in local coordinates
173
174 void renderDensityField();
175 void decompress(LLBitPack &bitpack, LLGroupHeader *group_header);
176
177 LLCloudLayer* getNeighbor(const S32 n) const { return mNeighbors[n]; }
178
179 void connectNeighbor(LLCloudLayer *cloudp, U32 direction);
180 void disconnectNeighbor(U32 direction);
181 void disconnectAllNeighbors();
182
183public:
184 LLVector3d mOriginGlobal;
185 F32 mMetersPerEdge;
186 F32 mMetersPerGrid;
187
188
189 F32 mMaxAlpha; // The max cloud puff _render_ alpha
190
191protected:
192 LLCloudLayer *mNeighbors[4];
193 LLWind *mWindp;
194 LLViewerRegion *mRegionp;
195 F32 *mDensityp; // the probability density grid
196
197 LLCloudGroup mCloudGroups[CLOUD_GROUPS_PER_EDGE][CLOUD_GROUPS_PER_EDGE];
198};
199
200
201#endif