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/llflexibleobject.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/llflexibleobject.cpp | 314 |
1 files changed, 111 insertions, 203 deletions
diff --git a/linden/indra/newview/llflexibleobject.cpp b/linden/indra/newview/llflexibleobject.cpp index 7e37c4c..4ce1614 100644 --- a/linden/indra/newview/llflexibleobject.cpp +++ b/linden/indra/newview/llflexibleobject.cpp | |||
@@ -44,11 +44,6 @@ | |||
44 | #include "llviewerregion.h" | 44 | #include "llviewerregion.h" |
45 | #include "llworld.h" | 45 | #include "llworld.h" |
46 | 46 | ||
47 | /*static*/ LLVolumeImplFlexible::lodset_t LLVolumeImplFlexible::sLODBins[ FLEXIBLE_OBJECT_MAX_LOD ]; | ||
48 | /*static*/ U64 LLVolumeImplFlexible::sCurrentUpdateFrame = 0; | ||
49 | /*static*/ U32 LLVolumeImplFlexible::sDebugInserted = 0; | ||
50 | /*static*/ U32 LLVolumeImplFlexible::sDebugVisible = 0; | ||
51 | |||
52 | /*static*/ F32 LLVolumeImplFlexible::sUpdateFactor = 1.0f; | 47 | /*static*/ F32 LLVolumeImplFlexible::sUpdateFactor = 1.0f; |
53 | 48 | ||
54 | // LLFlexibleObjectData::pack/unpack now in llprimitive.cpp | 49 | // LLFlexibleObjectData::pack/unpack now in llprimitive.cpp |
@@ -59,14 +54,13 @@ | |||
59 | LLVolumeImplFlexible::LLVolumeImplFlexible(LLViewerObject* vo, LLFlexibleObjectData* attributes) : | 54 | LLVolumeImplFlexible::LLVolumeImplFlexible(LLViewerObject* vo, LLFlexibleObjectData* attributes) : |
60 | mVO(vo), mAttributes(attributes) | 55 | mVO(vo), mAttributes(attributes) |
61 | { | 56 | { |
57 | static U32 seed = 0; | ||
58 | mID = seed++; | ||
62 | mInitialized = FALSE; | 59 | mInitialized = FALSE; |
63 | mUpdated = FALSE; | 60 | mUpdated = FALSE; |
64 | mJustShifted = FALSE; | ||
65 | mInitializedRes = -1; | 61 | mInitializedRes = -1; |
66 | mSimulateRes = 0; | 62 | mSimulateRes = 0; |
67 | mFrameNum = 0; | 63 | mFrameNum = 0; |
68 | mLastUpdate = 0; | ||
69 | |||
70 | }//----------------------------------------------- | 64 | }//----------------------------------------------- |
71 | 65 | ||
72 | LLVector3 LLVolumeImplFlexible::getFramePosition() const | 66 | LLVector3 LLVolumeImplFlexible::getFramePosition() const |
@@ -94,7 +88,6 @@ void LLVolumeImplFlexible::onShift(const LLVector3 &shift_vector) | |||
94 | { | 88 | { |
95 | mSection[section].mPosition += shift_vector; | 89 | mSection[section].mPosition += shift_vector; |
96 | } | 90 | } |
97 | mVO->getVolume()->mBounds[0] += shift_vector; | ||
98 | } | 91 | } |
99 | 92 | ||
100 | //----------------------------------------------------------------------------------------------- | 93 | //----------------------------------------------------------------------------------------------- |
@@ -107,7 +100,7 @@ void LLVolumeImplFlexible::setParentPositionAndRotationDirectly( LLVector3 p, LL | |||
107 | 100 | ||
108 | void LLVolumeImplFlexible::remapSections(LLFlexibleObjectSection *source, S32 source_sections, | 101 | void LLVolumeImplFlexible::remapSections(LLFlexibleObjectSection *source, S32 source_sections, |
109 | LLFlexibleObjectSection *dest, S32 dest_sections) | 102 | LLFlexibleObjectSection *dest, S32 dest_sections) |
110 | { | 103 | { |
111 | S32 num_output_sections = 1<<dest_sections; | 104 | S32 num_output_sections = 1<<dest_sections; |
112 | LLVector3 scale = mVO->mDrawable->getScale(); | 105 | LLVector3 scale = mVO->mDrawable->getScale(); |
113 | F32 source_section_length = scale.mV[VZ] / (F32)(1<<source_sections); | 106 | F32 source_section_length = scale.mV[VZ] / (F32)(1<<source_sections); |
@@ -228,6 +221,7 @@ void LLVolumeImplFlexible::setAttributesOfAllSections() | |||
228 | 221 | ||
229 | F32 t_inc = 1.f/F32(num_sections); | 222 | F32 t_inc = 1.f/F32(num_sections); |
230 | F32 t = t_inc; | 223 | F32 t = t_inc; |
224 | |||
231 | for ( int i=1; i<= num_sections; i++) | 225 | for ( int i=1; i<= num_sections; i++) |
232 | { | 226 | { |
233 | mSection[i].mAxisRotation.setQuat(lerp(begin_rot,end_rot,t),0,0,1); | 227 | mSection[i].mAxisRotation.setQuat(lerp(begin_rot,end_rot,t),0,0,1); |
@@ -236,18 +230,17 @@ void LLVolumeImplFlexible::setAttributesOfAllSections() | |||
236 | scale.mV[VY] * lerp(bottom_scale.mV[1], top_scale.mV[1], t)); | 230 | scale.mV[VY] * lerp(bottom_scale.mV[1], top_scale.mV[1], t)); |
237 | t += t_inc; | 231 | t += t_inc; |
238 | } | 232 | } |
239 | mLastUpdate = 0; | ||
240 | }//----------------------------------------------------------------------------------- | 233 | }//----------------------------------------------------------------------------------- |
241 | 234 | ||
242 | 235 | ||
243 | void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, const S32 detail) | 236 | void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, const S32 detail) |
244 | { | 237 | { |
245 | doIdleUpdate(gAgent, *gWorldp, 0.0); | 238 | /*doIdleUpdate(gAgent, *gWorldp, 0.0); |
246 | if (mVO && mVO->mDrawable.notNull()) | 239 | if (mVO && mVO->mDrawable.notNull()) |
247 | { | 240 | { |
248 | gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); | 241 | gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); |
249 | gPipeline.markMoved(mVO->mDrawable); | 242 | gPipeline.markMoved(mVO->mDrawable); |
250 | } | 243 | }*/ |
251 | } | 244 | } |
252 | 245 | ||
253 | //--------------------------------------------------------------------------------- | 246 | //--------------------------------------------------------------------------------- |
@@ -257,6 +250,13 @@ void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, cons | |||
257 | //--------------------------------------------------------------------------------- | 250 | //--------------------------------------------------------------------------------- |
258 | BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | 251 | BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) |
259 | { | 252 | { |
253 | if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE)) | ||
254 | { | ||
255 | return TRUE; | ||
256 | } | ||
257 | |||
258 | LLFastTimer ftm(LLFastTimer::FTM_FLEXIBLE_UPDATE); | ||
259 | |||
260 | if (mVO->mDrawable.isNull()) | 260 | if (mVO->mDrawable.isNull()) |
261 | { | 261 | { |
262 | // Don't do anything until we have a drawable | 262 | // Don't do anything until we have a drawable |
@@ -267,46 +267,17 @@ BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F6 | |||
267 | mVO->mDrawable->mQuietCount = 0; | 267 | mVO->mDrawable->mQuietCount = 0; |
268 | if (!mVO->mDrawable->isRoot()) | 268 | if (!mVO->mDrawable->isRoot()) |
269 | { | 269 | { |
270 | mVO->mDrawable->getParent()->mQuietCount = 0; | 270 | LLViewerObject* parent = (LLViewerObject*) mVO->getParent(); |
271 | parent->mDrawable->mQuietCount = 0; | ||
271 | } | 272 | } |
272 | 273 | ||
273 | if (((LLVOVolume*)mVO)->mLODChanged || | 274 | S32 new_res = mAttributes->getSimulateLOD(); |
274 | mVO->mDrawable->isState(LLDrawable::IN_REBUILD_Q1)) | ||
275 | { | ||
276 | mLastUpdate = 0; // Force an immediate update | ||
277 | } | ||
278 | // Relegate invisible objects to the lowest priority bin | ||
279 | S32 lod = 0; | ||
280 | F32 app_angle = mVO->getAppAngle()*DEG_TO_RAD/gCamera->getView(); | ||
281 | if (mVO->mDrawable->isVisible()) | ||
282 | { | ||
283 | sDebugVisible++; | ||
284 | if (mVO->isSelected()) | ||
285 | { | ||
286 | // Force selected objects to update *every* frame | ||
287 | lod = FLEXIBLE_OBJECT_MAX_LOD-1; | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | if (app_angle > 0) | ||
292 | { | ||
293 | lod = 5 - (S32)(1.0f/sqrtf(app_angle)); | ||
294 | if (lod < 1) | ||
295 | { | ||
296 | lod = 1; | ||
297 | } | ||
298 | } | ||
299 | 275 | ||
300 | if (mVO->isAttachment()) | 276 | //number of segments only cares about z axis |
301 | { | 277 | F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, mVO->mDrawable->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f); |
302 | lod += 3; | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | 278 | ||
307 | S32 new_res = mAttributes->getSimulateLOD(); | ||
308 | // Rendering sections increases with visible angle on the screen | 279 | // Rendering sections increases with visible angle on the screen |
309 | mRenderRes = (S32)(FLEXIBLE_OBJECT_MAX_SECTIONS*4*app_angle); | 280 | mRenderRes = (S32)(FLEXIBLE_OBJECT_MAX_SECTIONS*4*app_angle*DEG_TO_RAD/gCamera->getView()); |
310 | if (mRenderRes > FLEXIBLE_OBJECT_MAX_SECTIONS) | 281 | if (mRenderRes > FLEXIBLE_OBJECT_MAX_SECTIONS) |
311 | { | 282 | { |
312 | mRenderRes = FLEXIBLE_OBJECT_MAX_SECTIONS; | 283 | mRenderRes = FLEXIBLE_OBJECT_MAX_SECTIONS; |
@@ -329,22 +300,32 @@ BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F6 | |||
329 | mInitialized = TRUE; | 300 | mInitialized = TRUE; |
330 | } | 301 | } |
331 | 302 | ||
332 | sLODBins[lod].insert(this); | 303 | if (mVO->mDrawable->isVisible() && |
333 | sDebugInserted++; | 304 | !mVO->mDrawable->isState(LLDrawable::IN_REBUILD_Q1) && |
334 | return TRUE; | 305 | mVO->getPixelArea() > 256.f) |
335 | } | ||
336 | |||
337 | // static | ||
338 | void LLVolumeImplFlexible::resetUpdateBins() | ||
339 | { | ||
340 | U32 lod; | ||
341 | for (lod=0; lod<FLEXIBLE_OBJECT_MAX_LOD; ++lod) | ||
342 | { | 306 | { |
343 | sLODBins[lod].clear(); | 307 | U32 id; |
308 | F32 pixel_area = mVO->getPixelArea(); | ||
309 | |||
310 | if (mVO->isRootEdit()) | ||
311 | { | ||
312 | id = mID; | ||
313 | } | ||
314 | else | ||
315 | { | ||
316 | LLVOVolume* parent = (LLVOVolume*) mVO->getParent(); | ||
317 | id = parent->getVolumeInterfaceID(); | ||
318 | } | ||
319 | |||
320 | U32 update_period = (U32) (gCamera->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1; | ||
321 | |||
322 | if ((LLDrawable::getCurrentFrame()+id)%update_period == 0) | ||
323 | { | ||
324 | gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_POSITION, FALSE); | ||
325 | } | ||
344 | } | 326 | } |
345 | ++sCurrentUpdateFrame; | 327 | |
346 | sDebugInserted = 0; | 328 | return TRUE; |
347 | sDebugVisible = 0; | ||
348 | } | 329 | } |
349 | 330 | ||
350 | inline S32 log2(S32 x) | 331 | inline S32 log2(S32 x) |
@@ -358,80 +339,15 @@ inline S32 log2(S32 x) | |||
358 | return ret; | 339 | return ret; |
359 | } | 340 | } |
360 | 341 | ||
361 | // static | ||
362 | void LLVolumeImplFlexible::doFlexibleUpdateBins() | ||
363 | { | ||
364 | U32 lod; | ||
365 | U32 updated = 0; | ||
366 | U32 regen = 0; | ||
367 | U32 newflexies = 0; | ||
368 | F32 time_alloc[FLEXIBLE_OBJECT_MAX_LOD]; | ||
369 | F32 total_time_alloc = 0; | ||
370 | |||
371 | bool new_objects_only = false; | ||
372 | |||
373 | if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE)) | ||
374 | { | ||
375 | new_objects_only = true; | ||
376 | } | ||
377 | |||
378 | for (lod=0; lod<FLEXIBLE_OBJECT_MAX_LOD; ++lod) | ||
379 | { | ||
380 | int count = sLODBins[lod].size(); | ||
381 | if (count > 0) | ||
382 | { | ||
383 | time_alloc[lod] = (F32)((lod+1)*(log2(count))); | ||
384 | } | ||
385 | else | ||
386 | { | ||
387 | time_alloc[lod] = 0; | ||
388 | } | ||
389 | total_time_alloc += time_alloc[lod]; | ||
390 | } | ||
391 | total_time_alloc = FLEXIBLE_OBJECT_TIMESLICE * (sUpdateFactor+0.01f) / total_time_alloc; | ||
392 | |||
393 | { | ||
394 | LLFastTimer t(LLFastTimer::FTM_FLEXIBLE_UPDATE); | ||
395 | LLTimer timer; | ||
396 | for (lod=0; lod<FLEXIBLE_OBJECT_MAX_LOD; ++lod) | ||
397 | { | ||
398 | LLVolumeImplFlexible::lodset_t::iterator itor = sLODBins[lod].begin(); | ||
399 | int bin_count = 0; | ||
400 | if (!new_objects_only) | ||
401 | { | ||
402 | timer.reset(); | ||
403 | double end_time = time_alloc[lod] * total_time_alloc; | ||
404 | for (; itor!=sLODBins[lod].end(); ++itor) | ||
405 | { | ||
406 | |||
407 | (*itor)->doFlexibleUpdate(); | ||
408 | ++updated; | ||
409 | (*itor)->doFlexibleRebuild(); | ||
410 | ++bin_count; | ||
411 | ++regen; | ||
412 | if (timer.getElapsedTimeF64() > end_time) | ||
413 | { | ||
414 | break; | ||
415 | } | ||
416 | } | ||
417 | } | ||
418 | for (; itor != sLODBins[lod].end(); ++itor) | ||
419 | { | ||
420 | if ((*itor)->getLastUpdate() == 0) | ||
421 | { | ||
422 | // *Always* update newly-created objects, or objects which have changed LOD | ||
423 | (*itor)->doFlexibleUpdate(); | ||
424 | (*itor)->doFlexibleRebuild(); | ||
425 | ++newflexies; | ||
426 | } | ||
427 | } | ||
428 | } | ||
429 | } | ||
430 | } | ||
431 | |||
432 | void LLVolumeImplFlexible::doFlexibleUpdate() | 342 | void LLVolumeImplFlexible::doFlexibleUpdate() |
433 | { | 343 | { |
434 | LLPath *path = &mVO->getVolume()->getPath(); | 344 | LLPath *path = &mVO->getVolume()->getPath(); |
345 | if (mSimulateRes == 0) | ||
346 | { | ||
347 | mVO->markForUpdate(TRUE); | ||
348 | doIdleUpdate(gAgent, *gWorldp, 0.0); | ||
349 | } | ||
350 | |||
435 | S32 num_sections = 1 << mSimulateRes; | 351 | S32 num_sections = 1 << mSimulateRes; |
436 | 352 | ||
437 | F32 secondsThisFrame = mTimer.getElapsedTimeAndResetF32(); | 353 | F32 secondsThisFrame = mTimer.getElapsedTimeAndResetF32(); |
@@ -603,6 +519,10 @@ void LLVolumeImplFlexible::doFlexibleUpdate() | |||
603 | // calculate velocity | 519 | // calculate velocity |
604 | //------------------------------------------------------------------------------------------ | 520 | //------------------------------------------------------------------------------------------ |
605 | mSection[i].mVelocity = mSection[i].mPosition - lastPosition; | 521 | mSection[i].mVelocity = mSection[i].mPosition - lastPosition; |
522 | if (mSection[i].mVelocity.magVecSquared() > 1.f) | ||
523 | { | ||
524 | mSection[i].mVelocity.normVec(); | ||
525 | } | ||
606 | } | 526 | } |
607 | 527 | ||
608 | // Calculate derivatives (not necessary until normals are automagically generated) | 528 | // Calculate derivatives (not necessary until normals are automagically generated) |
@@ -643,11 +563,38 @@ void LLVolumeImplFlexible::doFlexibleUpdate() | |||
643 | LLFlexibleObjectSection newSection[ (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1 ]; | 563 | LLFlexibleObjectSection newSection[ (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1 ]; |
644 | remapSections(mSection, mSimulateRes, newSection, mRenderRes); | 564 | remapSections(mSection, mSimulateRes, newSection, mRenderRes); |
645 | 565 | ||
566 | //generate transform from global to prim space | ||
567 | LLVector3 delta_scale = LLVector3(1,1,1); | ||
568 | LLVector3 delta_pos; | ||
569 | LLQuaternion delta_rot; | ||
570 | |||
571 | delta_rot = ~getFrameRotation(); | ||
572 | delta_pos = -getFramePosition()*delta_rot; | ||
573 | |||
574 | // Vertex transform (4x4) | ||
575 | LLVector3 x_axis = LLVector3(delta_scale.mV[VX], 0.f, 0.f) * delta_rot; | ||
576 | LLVector3 y_axis = LLVector3(0.f, delta_scale.mV[VY], 0.f) * delta_rot; | ||
577 | LLVector3 z_axis = LLVector3(0.f, 0.f, delta_scale.mV[VZ]) * delta_rot; | ||
578 | |||
579 | LLMatrix4 rel_xform; | ||
580 | rel_xform.initRows(LLVector4(x_axis, 0.f), | ||
581 | LLVector4(y_axis, 0.f), | ||
582 | LLVector4(z_axis, 0.f), | ||
583 | LLVector4(delta_pos, 1.f)); | ||
584 | |||
646 | for (i=0; i<=num_render_sections; ++i) | 585 | for (i=0; i<=num_render_sections; ++i) |
647 | { | 586 | { |
648 | new_point = &path->mPath[i]; | 587 | new_point = &path->mPath[i]; |
649 | new_point->mPos = newSection[i].mPosition; | 588 | LLVector3 pos = newSection[i].mPosition * rel_xform; |
650 | new_point->mRot = mSection[i].mAxisRotation * newSection[i].mRotation; | 589 | LLQuaternion rot = mSection[i].mAxisRotation * newSection[i].mRotation * delta_rot; |
590 | |||
591 | if (!mUpdated || (new_point->mPos-pos).magVecSquared() > 0.000001f) | ||
592 | { | ||
593 | new_point->mPos = newSection[i].mPosition * rel_xform; | ||
594 | mUpdated = FALSE; | ||
595 | } | ||
596 | |||
597 | new_point->mRot = rot; | ||
651 | new_point->mScale = newSection[i].mScale; | 598 | new_point->mScale = newSection[i].mScale; |
652 | new_point->mTexT = ((F32)i)/(num_render_sections); | 599 | new_point->mTexT = ((F32)i)/(num_render_sections); |
653 | } | 600 | } |
@@ -658,13 +605,10 @@ void LLVolumeImplFlexible::doFlexibleUpdate() | |||
658 | void LLVolumeImplFlexible::doFlexibleRebuild() | 605 | void LLVolumeImplFlexible::doFlexibleRebuild() |
659 | { | 606 | { |
660 | mVO->getVolume()->regen(); | 607 | mVO->getVolume()->regen(); |
661 | |||
662 | mVO->markForUpdate(TRUE); | ||
663 | |||
664 | mUpdated = TRUE; | 608 | mUpdated = TRUE; |
609 | } | ||
665 | 610 | ||
666 | mLastUpdate = sCurrentUpdateFrame; | 611 | //------------------------------------------------------------------ |
667 | }//------------------------------------------------------------------ | ||
668 | 612 | ||
669 | void LLVolumeImplFlexible::onSetScale(const LLVector3& scale, BOOL damped) | 613 | void LLVolumeImplFlexible::onSetScale(const LLVector3& scale, BOOL damped) |
670 | { | 614 | { |
@@ -673,8 +617,6 @@ void LLVolumeImplFlexible::onSetScale(const LLVector3& scale, BOOL damped) | |||
673 | 617 | ||
674 | BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable) | 618 | BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable) |
675 | { | 619 | { |
676 | BOOL compiled = FALSE; | ||
677 | |||
678 | LLVOVolume *volume = (LLVOVolume*)mVO; | 620 | LLVOVolume *volume = (LLVOVolume*)mVO; |
679 | 621 | ||
680 | if (volume->mDrawable.isNull()) // Not sure why this is happening, but it is... | 622 | if (volume->mDrawable.isNull()) // Not sure why this is happening, but it is... |
@@ -682,60 +624,36 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable) | |||
682 | return TRUE; // No update to complete | 624 | return TRUE; // No update to complete |
683 | } | 625 | } |
684 | 626 | ||
685 | volume->calcAllTEsSame(); | 627 | if (volume->mLODChanged) |
686 | |||
687 | if (volume->mVolumeChanged || volume->mFaceMappingChanged) | ||
688 | { | 628 | { |
689 | compiled = TRUE; | 629 | LLVolumeParams volume_params = volume->getVolume()->getParams(); |
690 | volume->regenFaces(); | ||
691 | } | ||
692 | else if (volume->mLODChanged) | ||
693 | { | ||
694 | LLPointer<LLVolume> old_volumep, new_volumep; | ||
695 | F32 old_lod, new_lod; | ||
696 | |||
697 | old_volumep = volume->getVolume(); | ||
698 | old_lod = old_volumep->getDetail(); | ||
699 | |||
700 | LLVolumeParams volume_params = volume->getVolume()->getParams(); | ||
701 | volume->setVolume(volume_params, 0); | 630 | volume->setVolume(volume_params, 0); |
702 | doFlexibleUpdate(); | 631 | mUpdated = FALSE; |
703 | volume->getVolume()->regen(); | ||
704 | |||
705 | new_volumep = volume->getVolume(); | ||
706 | new_lod = new_volumep->getDetail(); | ||
707 | |||
708 | if (new_lod != old_lod) | ||
709 | { | ||
710 | compiled = TRUE; | ||
711 | if (new_volumep->getNumFaces() != old_volumep->getNumFaces()) | ||
712 | { | ||
713 | volume->regenFaces(); | ||
714 | } | ||
715 | } | ||
716 | } | 632 | } |
717 | 633 | ||
718 | if (mUpdated) | 634 | volume->updateRelativeXform(); |
635 | doFlexibleUpdate(); | ||
636 | |||
637 | if (volume->mLODChanged || volume->mFaceMappingChanged || | ||
638 | volume->mVolumeChanged) | ||
719 | { | 639 | { |
720 | compiled = TRUE; | 640 | volume->regenFaces(); |
721 | mUpdated = FALSE; | 641 | volume->mDrawable->setState(LLDrawable::REBUILD_VOLUME); |
722 | } | 642 | } |
723 | 643 | ||
724 | if(compiled) | 644 | if (!mUpdated || volume->mFaceMappingChanged || volume->mVolumeChanged) |
725 | { | 645 | { |
726 | volume->updateRelativeXform(isVolumeGlobal()); | 646 | doFlexibleRebuild(); |
727 | volume->genTriangles(isVolumeGlobal()); | 647 | volume->genBBoxes(isVolumeGlobal()); |
728 | LLPipeline::sCompiles++; | ||
729 | } | 648 | } |
730 | 649 | ||
731 | volume->mVolumeChanged = FALSE; | 650 | volume->mVolumeChanged = FALSE; |
732 | volume->mLODChanged = FALSE; | 651 | volume->mLODChanged = FALSE; |
733 | volume->mFaceMappingChanged = FALSE; | 652 | volume->mFaceMappingChanged = FALSE; |
734 | 653 | ||
654 | |||
735 | // clear UV flag | 655 | // clear UV flag |
736 | drawable->clearState(LLDrawable::UV); | 656 | drawable->clearState(LLDrawable::UV); |
737 | |||
738 | drawable->movePartition(); | ||
739 | 657 | ||
740 | return TRUE; | 658 | return TRUE; |
741 | } | 659 | } |
@@ -811,42 +729,32 @@ LLQuaternion LLVolumeImplFlexible::getEndRotation() | |||
811 | }//------------------------------------------------------------------ | 729 | }//------------------------------------------------------------------ |
812 | 730 | ||
813 | 731 | ||
814 | void LLVolumeImplFlexible::updateRelativeXform(BOOL global_volume) | 732 | void LLVolumeImplFlexible::updateRelativeXform() |
815 | { | 733 | { |
816 | LLVOVolume* vo = (LLVOVolume*) mVO; | ||
817 | |||
818 | LLVector3 delta_scale = LLVector3(1,1,1); | ||
819 | LLVector3 delta_pos; | ||
820 | LLQuaternion delta_rot; | 734 | LLQuaternion delta_rot; |
735 | LLVector3 delta_pos, delta_scale; | ||
736 | LLVOVolume* vo = (LLVOVolume*) mVO; | ||
737 | |||
738 | //matrix from local space to parent relative/global space | ||
739 | delta_rot = vo->mDrawable->isSpatialRoot() ? LLQuaternion() : vo->mDrawable->getRotation(); | ||
740 | delta_pos = vo->mDrawable->isSpatialRoot() ? LLVector3(0,0,0) : vo->mDrawable->getPosition(); | ||
741 | delta_scale = LLVector3(1,1,1); | ||
821 | 742 | ||
822 | if (!mVO->mDrawable->isRoot()) | ||
823 | { //global to parent relative | ||
824 | LLViewerObject* parent = (LLViewerObject*) vo->getParent(); | ||
825 | delta_rot = ~parent->getRenderRotation(); | ||
826 | delta_pos = -parent->getRenderPosition()*delta_rot; | ||
827 | } | ||
828 | else | ||
829 | { //global to local | ||
830 | delta_rot = ~getFrameRotation(); | ||
831 | delta_pos = -getFramePosition()*delta_rot; | ||
832 | } | ||
833 | |||
834 | // Vertex transform (4x4) | 743 | // Vertex transform (4x4) |
835 | LLVector3 x_axis = LLVector3(delta_scale.mV[VX], 0.f, 0.f) * delta_rot; | 744 | LLVector3 x_axis = LLVector3(delta_scale.mV[VX], 0.f, 0.f) * delta_rot; |
836 | LLVector3 y_axis = LLVector3(0.f, delta_scale.mV[VY], 0.f) * delta_rot; | 745 | LLVector3 y_axis = LLVector3(0.f, delta_scale.mV[VY], 0.f) * delta_rot; |
837 | LLVector3 z_axis = LLVector3(0.f, 0.f, delta_scale.mV[VZ]) * delta_rot; | 746 | LLVector3 z_axis = LLVector3(0.f, 0.f, delta_scale.mV[VZ]) * delta_rot; |
838 | 747 | ||
839 | vo->mRelativeXform.initRows(LLVector4(x_axis, 0.f), | 748 | vo->mRelativeXform.initRows(LLVector4(x_axis, 0.f), |
840 | LLVector4(y_axis, 0.f), | 749 | LLVector4(y_axis, 0.f), |
841 | LLVector4(z_axis, 0.f), | 750 | LLVector4(z_axis, 0.f), |
842 | LLVector4(delta_pos, 1.f)); | 751 | LLVector4(delta_pos, 1.f)); |
843 | 752 | ||
844 | x_axis.normVec(); | 753 | x_axis.normVec(); |
845 | y_axis.normVec(); | 754 | y_axis.normVec(); |
846 | z_axis.normVec(); | 755 | z_axis.normVec(); |
847 | 756 | ||
848 | vo->mRelativeXformInvTrans.setRows(x_axis, y_axis, z_axis); | 757 | vo->mRelativeXformInvTrans.setRows(x_axis, y_axis, z_axis); |
849 | |||
850 | } | 758 | } |
851 | 759 | ||
852 | const LLMatrix4& LLVolumeImplFlexible::getWorldMatrix(LLXformMatrix* xform) const | 760 | const LLMatrix4& LLVolumeImplFlexible::getWorldMatrix(LLXformMatrix* xform) const |