diff options
author | Jacek Antonelli | 2008-08-15 23:44:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:57 -0500 |
commit | da68d3a57ecb27eba5d7efb8ff77d9640c0be65e (patch) | |
tree | f2fa2b9ed6e8cf49c8a3cb2a1893c4e5c61916a1 /linden/indra/newview/llvovolume.cpp | |
parent | Second Life viewer sources 1.15.1.3 (diff) | |
download | meta-impy-da68d3a57ecb27eba5d7efb8ff77d9640c0be65e.zip meta-impy-da68d3a57ecb27eba5d7efb8ff77d9640c0be65e.tar.gz meta-impy-da68d3a57ecb27eba5d7efb8ff77d9640c0be65e.tar.bz2 meta-impy-da68d3a57ecb27eba5d7efb8ff77d9640c0be65e.tar.xz |
Second Life viewer sources 1.16.0.5
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llvovolume.cpp | 126 |
1 files changed, 118 insertions, 8 deletions
diff --git a/linden/indra/newview/llvovolume.cpp b/linden/indra/newview/llvovolume.cpp index 0a778e4..b9bdddc 100644 --- a/linden/indra/newview/llvovolume.cpp +++ b/linden/indra/newview/llvovolume.cpp | |||
@@ -89,6 +89,8 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re | |||
89 | mGlobalVolume = FALSE; | 89 | mGlobalVolume = FALSE; |
90 | mVObjRadius = LLVector3(1,1,0.5f).magVec(); | 90 | mVObjRadius = LLVector3(1,1,0.5f).magVec(); |
91 | mNumFaces = 0; | 91 | mNumFaces = 0; |
92 | mLODChanged = FALSE; | ||
93 | mSculptChanged = FALSE; | ||
92 | } | 94 | } |
93 | 95 | ||
94 | LLVOVolume::~LLVOVolume() | 96 | LLVOVolume::~LLVOVolume() |
@@ -116,6 +118,15 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, | |||
116 | // Do base class updates... | 118 | // Do base class updates... |
117 | U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp); | 119 | U32 retval = LLViewerObject::processUpdateMessage(mesgsys, user_data, block_num, update_type, dp); |
118 | 120 | ||
121 | LLUUID sculpt_id; | ||
122 | U8 sculpt_type = 0; | ||
123 | if (isSculpted()) | ||
124 | { | ||
125 | LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); | ||
126 | sculpt_id = sculpt_params->getSculptTexture(); | ||
127 | sculpt_type = sculpt_params->getSculptType(); | ||
128 | } | ||
129 | |||
119 | if (!dp) | 130 | if (!dp) |
120 | { | 131 | { |
121 | if (update_type == OUT_FULL) | 132 | if (update_type == OUT_FULL) |
@@ -157,6 +168,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, | |||
157 | // Unpack volume data | 168 | // Unpack volume data |
158 | LLVolumeParams volume_params; | 169 | LLVolumeParams volume_params; |
159 | LLVolumeMessage::unpackVolumeParams(&volume_params, mesgsys, _PREHASH_ObjectData, block_num); | 170 | LLVolumeMessage::unpackVolumeParams(&volume_params, mesgsys, _PREHASH_ObjectData, block_num); |
171 | volume_params.setSculptID(sculpt_id, sculpt_type); | ||
160 | 172 | ||
161 | if (setVolume(volume_params, 0)) | 173 | if (setVolume(volume_params, 0)) |
162 | { | 174 | { |
@@ -186,7 +198,9 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys, | |||
186 | llwarns << "Bogus volume parameters in object " << getID() << llendl; | 198 | llwarns << "Bogus volume parameters in object " << getID() << llendl; |
187 | llwarns << getRegion()->getOriginGlobal() << llendl; | 199 | llwarns << getRegion()->getOriginGlobal() << llendl; |
188 | } | 200 | } |
189 | 201 | ||
202 | volume_params.setSculptID(sculpt_id, sculpt_type); | ||
203 | |||
190 | if (setVolume(volume_params, 0)) | 204 | if (setVolume(volume_params, 0)) |
191 | { | 205 | { |
192 | markForUpdate(TRUE); | 206 | markForUpdate(TRUE); |
@@ -462,6 +476,28 @@ void LLVOVolume::updateTextures() | |||
462 | if (pri > max_vsize) max_vsize = pri; | 476 | if (pri > max_vsize) max_vsize = pri; |
463 | } | 477 | } |
464 | } | 478 | } |
479 | |||
480 | if (isSculpted()) | ||
481 | { | ||
482 | LLSculptParams *sculpt_params = (LLSculptParams *)getParameterEntry(LLNetworkData::PARAMS_SCULPT); | ||
483 | LLUUID id = sculpt_params->getSculptTexture(); | ||
484 | mSculptTexture = gImageList.getImage(id); | ||
485 | if (mSculptTexture.notNull()) | ||
486 | { | ||
487 | mSculptTexture->addTextureStats(mPixelArea); | ||
488 | } | ||
489 | |||
490 | S32 desired_discard = MAX_LOD - mLOD; | ||
491 | S32 current_discard = getVolume()->getSculptLevel(); | ||
492 | |||
493 | if (desired_discard != current_discard) | ||
494 | { | ||
495 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, FALSE); | ||
496 | mSculptChanged = TRUE; | ||
497 | } | ||
498 | |||
499 | } | ||
500 | |||
465 | 501 | ||
466 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) | 502 | if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_TEXTURE_AREA)) |
467 | { | 503 | { |
@@ -624,22 +660,79 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams &volume_params, const S32 detail | |||
624 | } | 660 | } |
625 | } | 661 | } |
626 | } | 662 | } |
663 | |||
627 | mGlobalVolume = (mVolumeImpl && mVolumeImpl->isVolumeGlobal()); | 664 | mGlobalVolume = (mVolumeImpl && mVolumeImpl->isVolumeGlobal()); |
628 | 665 | ||
629 | if (LLPrimitive::setVolume(volume_params, mLOD, (mVolumeImpl && mVolumeImpl->isVolumeUnique()))) | 666 | if ((LLPrimitive::setVolume(volume_params, mLOD, (mVolumeImpl && mVolumeImpl->isVolumeUnique()))) || mSculptChanged) |
630 | { | 667 | { |
631 | mFaceMappingChanged = TRUE; | 668 | mFaceMappingChanged = TRUE; |
632 | 669 | ||
633 | if (mVolumeImpl) | 670 | if (mVolumeImpl) |
634 | { | 671 | { |
635 | mVolumeImpl->onSetVolume(volume_params, detail); | 672 | mVolumeImpl->onSetVolume(volume_params, detail); |
636 | } | 673 | } |
674 | |||
675 | if (isSculpted()) | ||
676 | { | ||
677 | mSculptTexture = gImageList.getImage(volume_params.getSculptID()); | ||
678 | if (mSculptTexture.notNull()) | ||
679 | { | ||
680 | sculpt(); | ||
681 | } | ||
682 | } | ||
683 | else | ||
684 | { | ||
685 | mSculptTexture = NULL; | ||
686 | } | ||
637 | 687 | ||
638 | return TRUE; | 688 | return TRUE; |
639 | } | 689 | } |
640 | return FALSE; | 690 | return FALSE; |
641 | } | 691 | } |
642 | 692 | ||
693 | // sculpt replaces generate() for sculpted surfaces | ||
694 | void LLVOVolume::sculpt() | ||
695 | { | ||
696 | U16 sculpt_height = 0; | ||
697 | U16 sculpt_width = 0; | ||
698 | S8 sculpt_components = 0; | ||
699 | const U8* sculpt_data = NULL; | ||
700 | |||
701 | if (mSculptTexture.notNull()) | ||
702 | { | ||
703 | S32 discard_level; | ||
704 | S32 desired_discard = MAX_LOD - mLOD; // desired | ||
705 | |||
706 | discard_level = desired_discard; | ||
707 | |||
708 | S32 max_discard = mSculptTexture->getMaxDiscardLevel(); | ||
709 | if (discard_level > max_discard) | ||
710 | discard_level = max_discard; // clamp to the best we can do | ||
711 | |||
712 | S32 best_discard = mSculptTexture->getDiscardLevel(); | ||
713 | if (discard_level < best_discard) | ||
714 | discard_level = best_discard; // clamp to what we have | ||
715 | |||
716 | if (best_discard == -1) | ||
717 | discard_level = -1; // and if we have nothing, set to nothing | ||
718 | |||
719 | |||
720 | S32 current_discard = getVolume()->getSculptLevel(); | ||
721 | if (current_discard == discard_level) // no work to do here | ||
722 | return; | ||
723 | |||
724 | LLPointer<LLImageRaw> raw_image = new LLImageRaw(); | ||
725 | mSculptTexture->readBackRaw(discard_level, raw_image, TRUE); | ||
726 | |||
727 | sculpt_height = raw_image->getHeight(); | ||
728 | sculpt_width = raw_image->getWidth(); | ||
729 | |||
730 | sculpt_components = raw_image->getComponents(); | ||
731 | sculpt_data = raw_image->getData(); | ||
732 | getVolume()->sculpt(sculpt_width, sculpt_height, sculpt_components, sculpt_data, discard_level); | ||
733 | } | ||
734 | } | ||
735 | |||
643 | S32 LLVOVolume::computeLODDetail(F32 distance, F32 radius) | 736 | S32 LLVOVolume::computeLODDetail(F32 distance, F32 radius) |
644 | { | 737 | { |
645 | S32 cur_detail; | 738 | S32 cur_detail; |
@@ -978,7 +1071,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) | |||
978 | genBBoxes(FALSE); | 1071 | genBBoxes(FALSE); |
979 | } | 1072 | } |
980 | } | 1073 | } |
981 | else if (mLODChanged) | 1074 | else if ((mLODChanged) || (mSculptChanged)) |
982 | { | 1075 | { |
983 | LLPointer<LLVolume> old_volumep, new_volumep; | 1076 | LLPointer<LLVolume> old_volumep, new_volumep; |
984 | F32 old_lod, new_lod; | 1077 | F32 old_lod, new_lod; |
@@ -994,7 +1087,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) | |||
994 | new_volumep = getVolume(); | 1087 | new_volumep = getVolume(); |
995 | new_lod = new_volumep->getDetail(); | 1088 | new_lod = new_volumep->getDetail(); |
996 | 1089 | ||
997 | if (new_lod != old_lod) | 1090 | if ((new_lod != old_lod) || mSculptChanged) |
998 | { | 1091 | { |
999 | compiled = TRUE; | 1092 | compiled = TRUE; |
1000 | sNumLODChanges += getVolume()->getNumFaces(); | 1093 | sNumLODChanges += getVolume()->getNumFaces(); |
@@ -1030,6 +1123,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) | |||
1030 | 1123 | ||
1031 | mVolumeChanged = FALSE; | 1124 | mVolumeChanged = FALSE; |
1032 | mLODChanged = FALSE; | 1125 | mLODChanged = FALSE; |
1126 | mSculptChanged = FALSE; | ||
1033 | mFaceMappingChanged = FALSE; | 1127 | mFaceMappingChanged = FALSE; |
1034 | 1128 | ||
1035 | return TRUE; | 1129 | return TRUE; |
@@ -1037,9 +1131,16 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) | |||
1037 | 1131 | ||
1038 | void LLVOVolume::updateFaceSize(S32 idx) | 1132 | void LLVOVolume::updateFaceSize(S32 idx) |
1039 | { | 1133 | { |
1040 | const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx); | ||
1041 | LLFace* facep = mDrawable->getFace(idx); | 1134 | LLFace* facep = mDrawable->getFace(idx); |
1042 | facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size()); | 1135 | if (idx >= getVolume()->getNumVolumeFaces()) |
1136 | { | ||
1137 | facep->setSize(0,0); | ||
1138 | } | ||
1139 | else | ||
1140 | { | ||
1141 | const LLVolumeFace& vol_face = getVolume()->getVolumeFace(idx); | ||
1142 | facep->setSize(vol_face.mVertices.size(), vol_face.mIndices.size()); | ||
1143 | } | ||
1043 | } | 1144 | } |
1044 | 1145 | ||
1045 | BOOL LLVOVolume::isRootEdit() const | 1146 | BOOL LLVOVolume::isRootEdit() const |
@@ -1469,7 +1570,6 @@ BOOL LLVOVolume::isFlexible() const | |||
1469 | { | 1570 | { |
1470 | if (getVolume()->getParams().getPathParams().getCurveType() != LL_PCODE_PATH_FLEXIBLE) | 1571 | if (getVolume()->getParams().getPathParams().getCurveType() != LL_PCODE_PATH_FLEXIBLE) |
1471 | { | 1572 | { |
1472 | llwarns << "wtf" << llendl; | ||
1473 | LLVolumeParams volume_params = getVolume()->getParams(); | 1573 | LLVolumeParams volume_params = getVolume()->getParams(); |
1474 | U8 profile_and_hole = volume_params.getProfileParams().getCurveType(); | 1574 | U8 profile_and_hole = volume_params.getProfileParams().getCurveType(); |
1475 | volume_params.setType(profile_and_hole, LL_PCODE_PATH_FLEXIBLE); | 1575 | volume_params.setType(profile_and_hole, LL_PCODE_PATH_FLEXIBLE); |
@@ -1482,6 +1582,16 @@ BOOL LLVOVolume::isFlexible() const | |||
1482 | } | 1582 | } |
1483 | } | 1583 | } |
1484 | 1584 | ||
1585 | BOOL LLVOVolume::isSculpted() const | ||
1586 | { | ||
1587 | if (getParameterEntryInUse(LLNetworkData::PARAMS_SCULPT)) | ||
1588 | { | ||
1589 | return TRUE; | ||
1590 | } | ||
1591 | |||
1592 | return FALSE; | ||
1593 | } | ||
1594 | |||
1485 | BOOL LLVOVolume::isVolumeGlobal() const | 1595 | BOOL LLVOVolume::isVolumeGlobal() const |
1486 | { | 1596 | { |
1487 | if (mVolumeImpl) | 1597 | if (mVolumeImpl) |