diff options
author | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:50 -0500 |
commit | 89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch) | |
tree | bcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llvopartgroup.cpp | |
parent | Second Life viewer sources 1.13.3.2 (diff) | |
download | meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2 meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz |
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llvopartgroup.cpp | 404 |
1 files changed, 319 insertions, 85 deletions
diff --git a/linden/indra/newview/llvopartgroup.cpp b/linden/indra/newview/llvopartgroup.cpp index 150f5cd..a51ae9c 100644 --- a/linden/indra/newview/llvopartgroup.cpp +++ b/linden/indra/newview/llvopartgroup.cpp | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | #include "llvopartgroup.h" | 30 | #include "llvopartgroup.h" |
31 | 31 | ||
32 | #include "lldrawpoolalpha.h" | ||
33 | |||
32 | #include "llfasttimer.h" | 34 | #include "llfasttimer.h" |
33 | #include "message.h" | 35 | #include "message.h" |
34 | #include "v2math.h" | 36 | #include "v2math.h" |
@@ -47,7 +49,7 @@ const F32 MAX_PART_LIFETIME = 120.f; | |||
47 | extern U64 gFrameTime; | 49 | extern U64 gFrameTime; |
48 | 50 | ||
49 | LLVOPartGroup::LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) | 51 | LLVOPartGroup::LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) |
50 | : LLViewerObject(id, pcode, regionp), | 52 | : LLAlphaObject(id, pcode, regionp), |
51 | mViewerPartGroupp(NULL) | 53 | mViewerPartGroupp(NULL) |
52 | { | 54 | { |
53 | setNumTEs(1); | 55 | setNumTEs(1); |
@@ -61,37 +63,37 @@ LLVOPartGroup::~LLVOPartGroup() | |||
61 | { | 63 | { |
62 | } | 64 | } |
63 | 65 | ||
66 | |||
64 | BOOL LLVOPartGroup::isActive() const | 67 | BOOL LLVOPartGroup::isActive() const |
65 | { | 68 | { |
66 | return TRUE; | 69 | return TRUE; |
67 | } | 70 | } |
68 | 71 | ||
72 | F32 LLVOPartGroup::getBinRadius() | ||
73 | { | ||
74 | return mScale.mV[0]*2.f; | ||
75 | } | ||
76 | |||
77 | void LLVOPartGroup::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax) | ||
78 | { | ||
79 | LLVector3 pos_agent = getPositionAgent(); | ||
80 | mExtents[0] = pos_agent - mScale; | ||
81 | mExtents[1] = pos_agent + mScale; | ||
82 | newMin = mExtents[0]; | ||
83 | newMax = mExtents[1]; | ||
84 | mDrawable->setPositionGroup(pos_agent); | ||
85 | } | ||
86 | |||
69 | BOOL LLVOPartGroup::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | 87 | BOOL LLVOPartGroup::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) |
70 | { | 88 | { |
71 | if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES)) | ||
72 | { | ||
73 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); | ||
74 | } | ||
75 | |||
76 | // Particle groups don't need any of default idleUpdate velocity interpolation stuff. | ||
77 | //LLViewerObject::idleUpdate(agent, world, time); | ||
78 | return TRUE; | 89 | return TRUE; |
79 | } | 90 | } |
80 | 91 | ||
81 | |||
82 | void LLVOPartGroup::setPixelAreaAndAngle(LLAgent &agent) | 92 | void LLVOPartGroup::setPixelAreaAndAngle(LLAgent &agent) |
83 | { | 93 | { |
84 | // mPixelArea is calculated during render | 94 | // mPixelArea is calculated during render |
85 | |||
86 | LLVector3 viewer_pos_agent = agent.getCameraPositionAgent(); | ||
87 | LLVector3 pos_agent = getRenderPosition(); | ||
88 | |||
89 | F32 dx = viewer_pos_agent.mV[VX] - pos_agent.mV[VX]; | ||
90 | F32 dy = viewer_pos_agent.mV[VY] - pos_agent.mV[VY]; | ||
91 | F32 dz = viewer_pos_agent.mV[VZ] - pos_agent.mV[VZ]; | ||
92 | |||
93 | F32 mid_scale = getMidScale(); | 95 | F32 mid_scale = getMidScale(); |
94 | F32 range = sqrt(dx*dx + dy*dy + dz*dz); | 96 | F32 range = (getRenderPosition()-gCamera->getOrigin()).magVec(); |
95 | 97 | ||
96 | if (range < 0.001f || isHUDAttachment()) // range == zero | 98 | if (range < 0.001f || isHUDAttachment()) // range == zero |
97 | { | 99 | { |
@@ -105,7 +107,7 @@ void LLVOPartGroup::setPixelAreaAndAngle(LLAgent &agent) | |||
105 | 107 | ||
106 | void LLVOPartGroup::updateTextures(LLAgent &agent) | 108 | void LLVOPartGroup::updateTextures(LLAgent &agent) |
107 | { | 109 | { |
108 | // Texture stats for particles will need to be updated in a different way... | 110 | // Texture stats for particles need to be updated in a different way... |
109 | } | 111 | } |
110 | 112 | ||
111 | 113 | ||
@@ -114,37 +116,45 @@ LLDrawable* LLVOPartGroup::createDrawable(LLPipeline *pipeline) | |||
114 | pipeline->allocDrawable(this); | 116 | pipeline->allocDrawable(this); |
115 | mDrawable->setLit(FALSE); | 117 | mDrawable->setLit(FALSE); |
116 | mDrawable->setRenderType(LLPipeline::RENDER_TYPE_PARTICLES); | 118 | mDrawable->setRenderType(LLPipeline::RENDER_TYPE_PARTICLES); |
117 | |||
118 | LLDrawPool *pool = gPipeline.getPool(LLDrawPool::POOL_ALPHA); | ||
119 | mDrawable->setNumFaces(mViewerPartGroupp->getCount(), pool, getTEImage(0)); | ||
120 | return mDrawable; | 119 | return mDrawable; |
121 | } | 120 | } |
122 | 121 | ||
123 | const F32 MAX_PARTICLE_AREA_SCALE = 0.02f; // some tuned constant, limits on how much particle area to draw | 122 | const F32 MAX_PARTICLE_AREA_SCALE = 0.02f; // some tuned constant, limits on how much particle area to draw |
124 | 123 | ||
125 | BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) | 124 | F32 LLVOPartGroup::getPartSize(S32 idx) |
126 | { | 125 | { |
127 | LLFastTimer t(LLFastTimer::FTM_UPDATE_PARTICLES); | 126 | if (idx < (S32) mViewerPartGroupp->mParticles.size()) |
128 | 127 | { | |
129 | LLVector3 at; | 128 | return mViewerPartGroupp->mParticles[idx]->mScale.mV[0]; |
130 | LLVector3 up; | 129 | } |
131 | LLVector3 right; | 130 | |
132 | LLVector3 position_agent; | 131 | return 0.f; |
133 | LLVector3 camera_agent = gAgent.getCameraPositionAgent(); | 132 | } |
134 | LLVector2 uvs[4]; | ||
135 | 133 | ||
136 | uvs[0].setVec(0.f, 1.f); | 134 | BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) |
137 | uvs[1].setVec(0.f, 0.f); | 135 | { |
138 | uvs[2].setVec(1.f, 1.f); | 136 | LLFastTimer ftm(LLFastTimer::FTM_UPDATE_PARTICLES); |
139 | uvs[3].setVec(1.f, 0.f); | ||
140 | 137 | ||
141 | LLDrawPool *drawpool = gPipeline.getPool(LLDrawPool::POOL_ALPHA); | 138 | LLVector3 at; |
139 | LLVector3 position_agent; | ||
140 | LLVector3 camera_agent = gCamera->getOrigin(); | ||
141 | |||
142 | S32 num_parts = mViewerPartGroupp->getCount(); | 142 | S32 num_parts = mViewerPartGroupp->getCount(); |
143 | LLFace *facep; | 143 | LLFace *facep; |
144 | 144 | LLSpatialGroup* group = drawable->getSpatialGroup(); | |
145 | if (!group && num_parts) | ||
146 | { | ||
147 | drawable->movePartition(); | ||
148 | group = drawable->getSpatialGroup(); | ||
149 | } | ||
150 | |||
145 | if (!num_parts) | 151 | if (!num_parts) |
146 | { | 152 | { |
147 | drawable->setNumFaces(0, drawpool, getTEImage(0)); | 153 | if (drawable->getNumFaces()) |
154 | { | ||
155 | group->dirtyGeom(); | ||
156 | } | ||
157 | drawable->setNumFaces(0, NULL, getTEImage(0)); | ||
148 | LLPipeline::sCompiles++; | 158 | LLPipeline::sCompiles++; |
149 | return TRUE; | 159 | return TRUE; |
150 | } | 160 | } |
@@ -154,30 +164,30 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) | |||
154 | return TRUE; | 164 | return TRUE; |
155 | } | 165 | } |
156 | 166 | ||
157 | // drawable->setNumFaces(num_parts, drawpool, getTEImage(0)); | 167 | if (num_parts > drawable->getNumFaces()) |
158 | drawable->setNumFacesFast(num_parts, drawpool, getTEImage(0)); | 168 | { |
159 | 169 | drawable->setNumFacesFast(num_parts+num_parts/4, NULL, getTEImage(0)); | |
160 | LLVector3 normal(-gCamera->getXAxis()); // make point agent face camera | 170 | } |
161 | |||
162 | LLStrider<LLVector3> verticesp; | ||
163 | LLStrider<LLVector3> normalsp; | ||
164 | LLStrider<LLVector2> texCoordsp; | ||
165 | U32 *indicesp = 0; | ||
166 | 171 | ||
167 | S32 vert_offset; | ||
168 | F32 tot_area = 0; | 172 | F32 tot_area = 0; |
173 | BOOL is_particle = isParticle(); | ||
174 | |||
169 | F32 max_area = LLViewerPartSim::getMaxPartCount() * MAX_PARTICLE_AREA_SCALE; | 175 | F32 max_area = LLViewerPartSim::getMaxPartCount() * MAX_PARTICLE_AREA_SCALE; |
170 | 176 | F32 pixel_meter_ratio = gCamera->getPixelMeterRatio(); | |
177 | pixel_meter_ratio *= pixel_meter_ratio; | ||
178 | |||
171 | S32 count=0; | 179 | S32 count=0; |
172 | for (S32 i = 0; i < num_parts; i++) | 180 | S32 i; |
181 | F32 max_width = 0.f; | ||
182 | mDepth = 0.f; | ||
183 | |||
184 | for (i = 0; i < num_parts; i++) | ||
173 | { | 185 | { |
174 | const LLViewerPart &part = mViewerPartGroupp->mParticles[i]; | 186 | const LLViewerPart &part = *((LLViewerPart*) mViewerPartGroupp->mParticles[i]); |
175 | 187 | ||
176 | LLVector3 part_pos_agent(part.mPosAgent); | 188 | LLVector3 part_pos_agent(part.mPosAgent); |
177 | at = part_pos_agent - camera_agent; | 189 | at = part_pos_agent - camera_agent; |
178 | 190 | ||
179 | //F32 invcamdist = 1.0f / at.magVec(); | ||
180 | //area += (part.mScale.mV[0]*invcamdist)*(part.mScale.mV[1]*invcamdist); | ||
181 | F32 camera_dist_squared = at.magVecSquared(); | 191 | F32 camera_dist_squared = at.magVecSquared(); |
182 | F32 inv_camera_dist_squared; | 192 | F32 inv_camera_dist_squared; |
183 | if (camera_dist_squared > 1.f) | 193 | if (camera_dist_squared > 1.f) |
@@ -186,29 +196,124 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) | |||
186 | inv_camera_dist_squared = 1.f; | 196 | inv_camera_dist_squared = 1.f; |
187 | F32 area = part.mScale.mV[0] * part.mScale.mV[1] * inv_camera_dist_squared; | 197 | F32 area = part.mScale.mV[0] * part.mScale.mV[1] * inv_camera_dist_squared; |
188 | tot_area += area; | 198 | tot_area += area; |
189 | if (tot_area > max_area) | 199 | |
200 | if (!is_particle && tot_area > max_area) | ||
190 | { | 201 | { |
191 | break; | 202 | break; |
192 | } | 203 | } |
193 | 204 | ||
194 | count++; | 205 | count++; |
195 | 206 | ||
196 | facep = drawable->getFace(i); | 207 | facep = drawable->getFace(i); |
208 | facep->setTEOffset(i); | ||
197 | const F32 NEAR_PART_DIST_SQ = 5.f*5.f; // Only discard particles > 5 m from the camera | 209 | const F32 NEAR_PART_DIST_SQ = 5.f*5.f; // Only discard particles > 5 m from the camera |
198 | const F32 MIN_PART_AREA = .005f*.005f; // only less than 5 mm x 5 mm at 1 m from camera | 210 | const F32 MIN_PART_AREA = .005f*.005f; // only less than 5 mm x 5 mm at 1 m from camera |
199 | if (camera_dist_squared > NEAR_PART_DIST_SQ && area < MIN_PART_AREA) | 211 | |
212 | if (!is_particle) | ||
200 | { | 213 | { |
201 | facep->setSize(0, 0); | 214 | if (camera_dist_squared > NEAR_PART_DIST_SQ && area < MIN_PART_AREA) |
202 | continue; | 215 | { |
216 | facep->setSize(0, 0); | ||
217 | continue; | ||
218 | } | ||
219 | |||
220 | facep->setSize(4, 6); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | facep->setSize(1,1); | ||
225 | } | ||
226 | |||
227 | facep->setViewerObject(this); | ||
228 | |||
229 | if (part.mFlags & LLPartData::LL_PART_EMISSIVE_MASK) | ||
230 | { | ||
231 | facep->setState(LLFace::FULLBRIGHT); | ||
203 | } | 232 | } |
204 | facep->setSize(4, 6); | 233 | else |
205 | facep->mCenterAgent = part_pos_agent; | ||
206 | vert_offset = facep->getGeometry(verticesp,normalsp,texCoordsp, indicesp); | ||
207 | if (-1 == vert_offset) | ||
208 | { | 234 | { |
209 | return TRUE; | 235 | facep->clearState(LLFace::FULLBRIGHT); |
210 | } | 236 | } |
237 | |||
238 | facep->mCenterLocal = part.mPosAgent; | ||
239 | facep->setFaceColor(part.mColor); | ||
240 | facep->setTexture(part.mImagep); | ||
211 | 241 | ||
242 | if (i == 0) | ||
243 | { | ||
244 | mExtents[0] = mExtents[1] = part.mPosAgent; | ||
245 | } | ||
246 | else | ||
247 | { | ||
248 | update_min_max(mExtents[0], mExtents[1], part.mPosAgent); | ||
249 | } | ||
250 | |||
251 | max_width = llmax(max_width, part.mScale.mV[0]); | ||
252 | max_width = llmax(max_width, part.mScale.mV[1]); | ||
253 | |||
254 | mPixelArea = tot_area * pixel_meter_ratio; | ||
255 | const F32 area_scale = 10.f; // scale area to increase priority a bit | ||
256 | facep->setVirtualSize(mPixelArea*area_scale); | ||
257 | } | ||
258 | for (i = count; i < drawable->getNumFaces(); i++) | ||
259 | { | ||
260 | LLFace* facep = drawable->getFace(i); | ||
261 | facep->setTEOffset(i); | ||
262 | facep->setSize(0,0); | ||
263 | } | ||
264 | |||
265 | LLVector3 y = gCamera->mYAxis; | ||
266 | LLVector3 z = gCamera->mZAxis; | ||
267 | |||
268 | LLVector3 pad; | ||
269 | for (i = 0; i < 3; i++) | ||
270 | { | ||
271 | pad.mV[i] = llmax(max_width, max_width * (fabsf(y.mV[i]) + fabsf(z.mV[i]))); | ||
272 | } | ||
273 | |||
274 | mExtents[0] -= pad; | ||
275 | mExtents[1] += pad; | ||
276 | |||
277 | mDrawable->movePartition(); | ||
278 | LLPipeline::sCompiles++; | ||
279 | return TRUE; | ||
280 | } | ||
281 | |||
282 | void LLVOPartGroup::getGeometry(S32 idx, | ||
283 | LLStrider<LLVector3>& verticesp, | ||
284 | LLStrider<LLVector3>& normalsp, | ||
285 | LLStrider<LLVector2>& texcoordsp, | ||
286 | LLStrider<LLColor4U>& colorsp, | ||
287 | LLStrider<U32>& indicesp) | ||
288 | { | ||
289 | if (idx >= (S32) mViewerPartGroupp->mParticles.size()) | ||
290 | { | ||
291 | return; | ||
292 | } | ||
293 | |||
294 | const LLViewerPart &part = *((LLViewerPart*) (mViewerPartGroupp->mParticles[idx])); | ||
295 | |||
296 | U32 vert_offset = mDrawable->getFace(idx)->getGeomIndex(); | ||
297 | |||
298 | if (isParticle()) | ||
299 | { | ||
300 | LLVector3 part_pos_agent(part.mPosAgent); | ||
301 | |||
302 | const LLVector3& normal = -gCamera->getXAxis(); | ||
303 | |||
304 | *verticesp++ = part_pos_agent; | ||
305 | *normalsp++ = normal; | ||
306 | *colorsp++ = part.mColor; | ||
307 | *texcoordsp++ = LLVector2(0.5f, 0.5f); | ||
308 | *indicesp++ = vert_offset; | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | LLVector3 part_pos_agent(part.mPosAgent); | ||
313 | LLVector3 camera_agent = gAgent.getCameraPositionAgent(); | ||
314 | LLVector3 at = part_pos_agent - camera_agent; | ||
315 | LLVector3 up, right; | ||
316 | |||
212 | right = at % LLVector3(0.f, 0.f, 1.f); | 317 | right = at % LLVector3(0.f, 0.f, 1.f); |
213 | right.normVec(); | 318 | right.normVec(); |
214 | up = right % at; | 319 | up = right % at; |
@@ -236,31 +341,28 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) | |||
236 | right *= 0.5f*part.mScale.mV[0]; | 341 | right *= 0.5f*part.mScale.mV[0]; |
237 | up *= 0.5f*part.mScale.mV[1]; | 342 | up *= 0.5f*part.mScale.mV[1]; |
238 | 343 | ||
344 | const LLVector3& normal = -gCamera->getXAxis(); | ||
345 | |||
239 | *verticesp++ = part_pos_agent + up - right; | 346 | *verticesp++ = part_pos_agent + up - right; |
240 | *verticesp++ = part_pos_agent - up - right; | 347 | *verticesp++ = part_pos_agent - up - right; |
241 | *verticesp++ = part_pos_agent + up + right; | 348 | *verticesp++ = part_pos_agent + up + right; |
242 | *verticesp++ = part_pos_agent - up + right; | 349 | *verticesp++ = part_pos_agent - up + right; |
243 | 350 | ||
244 | *texCoordsp++ = uvs[0]; | 351 | *colorsp++ = part.mColor; |
245 | *texCoordsp++ = uvs[1]; | 352 | *colorsp++ = part.mColor; |
246 | *texCoordsp++ = uvs[2]; | 353 | *colorsp++ = part.mColor; |
247 | *texCoordsp++ = uvs[3]; | 354 | *colorsp++ = part.mColor; |
355 | |||
356 | *texcoordsp++ = LLVector2(0.f, 1.f); | ||
357 | *texcoordsp++ = LLVector2(0.f, 0.f); | ||
358 | *texcoordsp++ = LLVector2(1.f, 1.f); | ||
359 | *texcoordsp++ = LLVector2(1.f, 0.f); | ||
248 | 360 | ||
249 | *normalsp++ = normal; | 361 | *normalsp++ = normal; |
250 | *normalsp++ = normal; | 362 | *normalsp++ = normal; |
251 | *normalsp++ = normal; | 363 | *normalsp++ = normal; |
252 | *normalsp++ = normal; | 364 | *normalsp++ = normal; |
253 | 365 | ||
254 | if (part.mFlags & LLPartData::LL_PART_EMISSIVE_MASK) | ||
255 | { | ||
256 | facep->setState(LLFace::FULLBRIGHT); | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | facep->clearState(LLFace::FULLBRIGHT); | ||
261 | } | ||
262 | facep->setFaceColor(part.mColor); | ||
263 | |||
264 | *indicesp++ = vert_offset + 0; | 366 | *indicesp++ = vert_offset + 0; |
265 | *indicesp++ = vert_offset + 1; | 367 | *indicesp++ = vert_offset + 1; |
266 | *indicesp++ = vert_offset + 2; | 368 | *indicesp++ = vert_offset + 2; |
@@ -269,17 +371,149 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) | |||
269 | *indicesp++ = vert_offset + 3; | 371 | *indicesp++ = vert_offset + 3; |
270 | *indicesp++ = vert_offset + 2; | 372 | *indicesp++ = vert_offset + 2; |
271 | } | 373 | } |
272 | for (S32 j = count; j < drawable->getNumFaces(); j++) | 374 | } |
375 | |||
376 | BOOL LLVOPartGroup::isParticle() | ||
377 | { | ||
378 | return FALSE; //gGLManager.mHasPointParameters && mViewerPartGroupp->mUniformParticles; | ||
379 | } | ||
380 | |||
381 | U32 LLVOPartGroup::getPartitionType() const | ||
382 | { | ||
383 | return LLPipeline::PARTITION_PARTICLE; | ||
384 | } | ||
385 | |||
386 | LLParticlePartition::LLParticlePartition() | ||
387 | : LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK) | ||
388 | { | ||
389 | mRenderPass = LLRenderPass::PASS_ALPHA; | ||
390 | mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; | ||
391 | mPartitionType = LLPipeline::PARTITION_PARTICLE; | ||
392 | mBufferUsage = GL_DYNAMIC_DRAW_ARB; | ||
393 | mSlopRatio = 0.f; | ||
394 | mLODPeriod = 1; | ||
395 | } | ||
396 | |||
397 | void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count) | ||
398 | { | ||
399 | group->mBufferUsage = mBufferUsage; | ||
400 | |||
401 | mFaceList.clear(); | ||
402 | |||
403 | for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i) | ||
273 | { | 404 | { |
274 | drawable->getFace(j)->setSize(0,0); | 405 | LLDrawable* drawablep = *i; |
406 | |||
407 | if (drawablep->isDead()) | ||
408 | { | ||
409 | continue; | ||
410 | } | ||
411 | |||
412 | LLAlphaObject* obj = (LLAlphaObject*) drawablep->getVObj(); | ||
413 | obj->mDepth = 0.f; | ||
414 | |||
415 | if (drawablep->isAnimating()) | ||
416 | { | ||
417 | group->mBufferUsage = GL_STREAM_DRAW_ARB; | ||
418 | } | ||
419 | |||
420 | U32 count = 0; | ||
421 | for (S32 j = 0; j < drawablep->getNumFaces(); ++j) | ||
422 | { | ||
423 | drawablep->updateFaceSize(j); | ||
424 | |||
425 | LLFace* facep = drawablep->getFace(j); | ||
426 | if (!facep->hasGeometry()) | ||
427 | { | ||
428 | continue; | ||
429 | } | ||
430 | |||
431 | count++; | ||
432 | facep->mDistance = (facep->mCenterLocal - gCamera->getOrigin()) * gCamera->getAtAxis(); | ||
433 | obj->mDepth += facep->mDistance; | ||
434 | |||
435 | mFaceList.push_back(facep); | ||
436 | vertex_count += facep->getGeomCount(); | ||
437 | index_count += facep->getIndicesCount(); | ||
438 | } | ||
439 | |||
440 | obj->mDepth /= count; | ||
275 | } | 441 | } |
276 | 442 | } | |
277 | mPixelArea = tot_area * gCamera->getPixelMeterRatio() * gCamera->getPixelMeterRatio(); | ||
278 | const F32 area_scale = 10.f; // scale area to increase priority a bit | ||
279 | getTEImage(0)->addTextureStats(mPixelArea * area_scale); | ||
280 | 443 | ||
281 | LLPipeline::sCompiles++; | 444 | void LLParticlePartition::getGeometry(LLSpatialGroup* group) |
445 | { | ||
446 | LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); | ||
282 | 447 | ||
283 | return TRUE; | 448 | std::sort(mFaceList.begin(), mFaceList.end(), LLFace::CompareDistanceGreater()); |
449 | |||
450 | U32 index_count = 0; | ||
451 | U32 vertex_count = 0; | ||
452 | |||
453 | group->clearDrawMap(); | ||
454 | |||
455 | LLVertexBuffer* buffer = group->mVertexBuffer; | ||
456 | |||
457 | LLStrider<U32> indicesp; | ||
458 | LLStrider<LLVector3> verticesp; | ||
459 | LLStrider<LLVector3> normalsp; | ||
460 | LLStrider<LLVector2> texcoordsp; | ||
461 | LLStrider<LLColor4U> colorsp; | ||
462 | |||
463 | buffer->getVertexStrider(verticesp); | ||
464 | buffer->getNormalStrider(normalsp); | ||
465 | buffer->getColorStrider(colorsp); | ||
466 | buffer->getTexCoordStrider(texcoordsp); | ||
467 | buffer->getIndexStrider(indicesp); | ||
468 | |||
469 | std::vector<LLDrawInfo*>& draw_vec = group->mDrawMap[mRenderPass]; | ||
470 | |||
471 | for (std::vector<LLFace*>::iterator i = mFaceList.begin(); i != mFaceList.end(); ++i) | ||
472 | { | ||
473 | LLFace* facep = *i; | ||
474 | LLAlphaObject* object = (LLAlphaObject*) facep->getViewerObject(); | ||
475 | facep->setGeomIndex(vertex_count); | ||
476 | facep->setIndicesIndex(index_count); | ||
477 | facep->mVertexBuffer = buffer; | ||
478 | facep->setPoolType(LLDrawPool::POOL_ALPHA); | ||
479 | object->getGeometry(facep->getTEOffset(), verticesp, normalsp, texcoordsp, colorsp, indicesp); | ||
480 | |||
481 | vertex_count += facep->getGeomCount(); | ||
482 | index_count += facep->getIndicesCount(); | ||
483 | |||
484 | S32 idx = draw_vec.size()-1; | ||
485 | |||
486 | BOOL fullbright = facep->isState(LLFace::FULLBRIGHT); | ||
487 | F32 vsize = facep->getVirtualSize(); | ||
488 | |||
489 | if (idx >= 0 && draw_vec[idx]->mEnd == facep->getGeomIndex()-1 && | ||
490 | draw_vec[idx]->mTexture == facep->getTexture() && | ||
491 | draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && | ||
492 | draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && | ||
493 | draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() < 4096 && | ||
494 | draw_vec[idx]->mFullbright == fullbright) | ||
495 | { | ||
496 | draw_vec[idx]->mCount += facep->getIndicesCount(); | ||
497 | draw_vec[idx]->mEnd += facep->getGeomCount(); | ||
498 | draw_vec[idx]->mVSize = llmax(draw_vec[idx]->mVSize, vsize); | ||
499 | } | ||
500 | else | ||
501 | { | ||
502 | U32 start = facep->getGeomIndex(); | ||
503 | U32 end = start + facep->getGeomCount()-1; | ||
504 | U32 offset = facep->getIndicesStart(); | ||
505 | U32 count = facep->getIndicesCount(); | ||
506 | LLDrawInfo* info = new LLDrawInfo(start,end,count,offset,facep->getTexture(), buffer, fullbright); | ||
507 | info->mVSize = vsize; | ||
508 | draw_vec.push_back(info); | ||
509 | } | ||
510 | } | ||
511 | |||
512 | mFaceList.clear(); | ||
513 | } | ||
514 | |||
515 | F32 LLParticlePartition::calcPixelArea(LLSpatialGroup* group, LLCamera& camera) | ||
516 | { | ||
517 | return 1024.f; | ||
284 | } | 518 | } |
285 | 519 | ||