diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-05-01 08:16:58 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-05-01 08:16:58 +0300 |
commit | 38c2a5bde985a6a8a96d912d432f8bdf7e5b60be (patch) | |
tree | b3469444ea8dabe4e76a8a265ac086a9db78891c /indra/newview/llfloaterimagepreview.cpp | |
parent | 9bf2dfbb39032d7407295089cf181de0987083e5 (diff) | |
parent | e7eced3c87310b15ac20cc3cd470d67686104a14 (diff) |
Merge branch 'marchcat/w-whitespace' into marchcat/x-ws-merge
Diffstat (limited to 'indra/newview/llfloaterimagepreview.cpp')
-rw-r--r-- | indra/newview/llfloaterimagepreview.cpp | 1216 |
1 files changed, 608 insertions, 608 deletions
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index 6da1481c7e..7851c5403b 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -1,25 +1,25 @@ -/** +/** * @file llfloaterimagepreview.cpp * @brief LLFloaterImagePreview class implementation * * $LicenseInfo:firstyear=2004&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -64,23 +64,23 @@ const S32 PREVIEW_BORDER_WIDTH = 2; const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH; const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE; -const S32 PREVIEW_VPAD = -24 + 35; // yuk, hard coded +const S32 PREVIEW_VPAD = -24 + 35; // yuk, hard coded const S32 PREF_BUTTON_HEIGHT = 16 + 7 + 16 + 35; const S32 PREVIEW_TEXTURE_HEIGHT = 320; //----------------------------------------------------------------------------- // LLFloaterImagePreview() //----------------------------------------------------------------------------- -LLFloaterImagePreview::LLFloaterImagePreview(const std::string& filename) : - LLFloaterNameDesc(filename), +LLFloaterImagePreview::LLFloaterImagePreview(const std::string& filename) : + LLFloaterNameDesc(filename), - mAvatarPreview(NULL), - mSculptedPreview(NULL), - mLastMouseX(0), - mLastMouseY(0), - mImagep(NULL) + mAvatarPreview(NULL), + mSculptedPreview(NULL), + mLastMouseX(0), + mLastMouseY(0), + mImagep(NULL) { - loadImage(mFilenameAndPath); + loadImage(mFilenameAndPath); } //----------------------------------------------------------------------------- @@ -88,33 +88,33 @@ LLFloaterImagePreview::LLFloaterImagePreview(const std::string& filename) : //----------------------------------------------------------------------------- BOOL LLFloaterImagePreview::postBuild() { - if (!LLFloaterNameDesc::postBuild()) - { - return FALSE; - } - - LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); - if (iface) - { - iface->selectFirstItem(); - } - childSetCommitCallback("clothing_type_combo", onPreviewTypeCommit, this); - - mPreviewRect.set(PREVIEW_HPAD, - PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD, - getRect().getWidth() - PREVIEW_HPAD, - PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); - mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f); - - getChildView("bad_image_text")->setVisible(FALSE); - - if (mRawImagep.notNull() && gAgent.getRegion() != NULL) - { - mAvatarPreview = new LLImagePreviewAvatar(256, 256); - mAvatarPreview->setPreviewTarget("mPelvis", "mUpperBodyMesh0", mRawImagep, 2.f, FALSE); - - mSculptedPreview = new LLImagePreviewSculpted(256, 256); - mSculptedPreview->setPreviewTarget(mRawImagep, 2.0f); + if (!LLFloaterNameDesc::postBuild()) + { + return FALSE; + } + + LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); + if (iface) + { + iface->selectFirstItem(); + } + childSetCommitCallback("clothing_type_combo", onPreviewTypeCommit, this); + + mPreviewRect.set(PREVIEW_HPAD, + PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD, + getRect().getWidth() - PREVIEW_HPAD, + PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + mPreviewImageRect.set(0.f, 1.f, 1.f, 0.f); + + getChildView("bad_image_text")->setVisible(FALSE); + + if (mRawImagep.notNull() && gAgent.getRegion() != NULL) + { + mAvatarPreview = new LLImagePreviewAvatar(256, 256); + mAvatarPreview->setPreviewTarget("mPelvis", "mUpperBodyMesh0", mRawImagep, 2.f, FALSE); + + mSculptedPreview = new LLImagePreviewSculpted(256, 256); + mSculptedPreview->setPreviewTarget(mRawImagep, 2.0f); if (mRawImagep->getWidth() * mRawImagep->getHeight() <= LL_IMAGE_REZ_LOSSLESS_CUTOFF * LL_IMAGE_REZ_LOSSLESS_CUTOFF) { @@ -124,24 +124,24 @@ BOOL LLFloaterImagePreview::postBuild() check_box->setEnabled(TRUE); check_box->setControlVariable(gSavedSettings.getControl("LosslessJ2CUpload")); } - } - else - { - mAvatarPreview = NULL; - mSculptedPreview = NULL; - getChildView("bad_image_text")->setVisible(TRUE); - getChildView("clothing_type_combo")->setEnabled(FALSE); - getChildView("ok_btn")->setEnabled(FALSE); - - if(!mImageLoadError.empty()) - { - getChild<LLUICtrl>("bad_image_text")->setValue(mImageLoadError.c_str()); - } - } - - getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); - - return TRUE; + } + else + { + mAvatarPreview = NULL; + mSculptedPreview = NULL; + getChildView("bad_image_text")->setVisible(TRUE); + getChildView("clothing_type_combo")->setEnabled(FALSE); + getChildView("ok_btn")->setEnabled(FALSE); + + if(!mImageLoadError.empty()) + { + getChild<LLUICtrl>("bad_image_text")->setValue(mImageLoadError.c_str()); + } + } + + getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this)); + + return TRUE; } //----------------------------------------------------------------------------- @@ -149,70 +149,70 @@ BOOL LLFloaterImagePreview::postBuild() //----------------------------------------------------------------------------- LLFloaterImagePreview::~LLFloaterImagePreview() { - clearAllPreviewTextures(); + clearAllPreviewTextures(); - mRawImagep = NULL; - mImagep = NULL ; + mRawImagep = NULL; + mImagep = NULL ; } -//static +//static //----------------------------------------------------------------------------- // onPreviewTypeCommit() //----------------------------------------------------------------------------- -void LLFloaterImagePreview::onPreviewTypeCommit(LLUICtrl* ctrl, void* userdata) +void LLFloaterImagePreview::onPreviewTypeCommit(LLUICtrl* ctrl, void* userdata) { - LLFloaterImagePreview *fp =(LLFloaterImagePreview *)userdata; - - if (!fp->mAvatarPreview || !fp->mSculptedPreview) - { - return; - } - - S32 which_mode = 0; - - LLCtrlSelectionInterface* iface = fp->childGetSelectionInterface("clothing_type_combo"); - if (iface) - { - which_mode = iface->getFirstSelectedIndex(); - } - - switch(which_mode) - { - case 0: - break; - case 1: - fp->mAvatarPreview->setPreviewTarget("mSkull", "mHairMesh0", fp->mRawImagep, 0.4f, FALSE); - break; - case 2: - fp->mAvatarPreview->setPreviewTarget("mSkull", "mHeadMesh0", fp->mRawImagep, 0.4f, FALSE); - break; - case 3: - fp->mAvatarPreview->setPreviewTarget("mChest", "mUpperBodyMesh0", fp->mRawImagep, 1.0f, FALSE); - break; - case 4: - fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mLowerBodyMesh0", fp->mRawImagep, 1.2f, FALSE); - break; - case 5: - fp->mAvatarPreview->setPreviewTarget("mSkull", "mHeadMesh0", fp->mRawImagep, 0.4f, TRUE); - break; - case 6: - fp->mAvatarPreview->setPreviewTarget("mChest", "mUpperBodyMesh0", fp->mRawImagep, 1.2f, TRUE); - break; - case 7: - fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mLowerBodyMesh0", fp->mRawImagep, 1.2f, TRUE); - break; - case 8: - fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mSkirtMesh0", fp->mRawImagep, 1.3f, FALSE); - break; - case 9: - fp->mSculptedPreview->setPreviewTarget(fp->mRawImagep, 2.0f); - break; - default: - break; - } - - fp->mAvatarPreview->refresh(); - fp->mSculptedPreview->refresh(); + LLFloaterImagePreview *fp =(LLFloaterImagePreview *)userdata; + + if (!fp->mAvatarPreview || !fp->mSculptedPreview) + { + return; + } + + S32 which_mode = 0; + + LLCtrlSelectionInterface* iface = fp->childGetSelectionInterface("clothing_type_combo"); + if (iface) + { + which_mode = iface->getFirstSelectedIndex(); + } + + switch(which_mode) + { + case 0: + break; + case 1: + fp->mAvatarPreview->setPreviewTarget("mSkull", "mHairMesh0", fp->mRawImagep, 0.4f, FALSE); + break; + case 2: + fp->mAvatarPreview->setPreviewTarget("mSkull", "mHeadMesh0", fp->mRawImagep, 0.4f, FALSE); + break; + case 3: + fp->mAvatarPreview->setPreviewTarget("mChest", "mUpperBodyMesh0", fp->mRawImagep, 1.0f, FALSE); + break; + case 4: + fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mLowerBodyMesh0", fp->mRawImagep, 1.2f, FALSE); + break; + case 5: + fp->mAvatarPreview->setPreviewTarget("mSkull", "mHeadMesh0", fp->mRawImagep, 0.4f, TRUE); + break; + case 6: + fp->mAvatarPreview->setPreviewTarget("mChest", "mUpperBodyMesh0", fp->mRawImagep, 1.2f, TRUE); + break; + case 7: + fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mLowerBodyMesh0", fp->mRawImagep, 1.2f, TRUE); + break; + case 8: + fp->mAvatarPreview->setPreviewTarget("mKneeLeft", "mSkirtMesh0", fp->mRawImagep, 1.3f, FALSE); + break; + case 9: + fp->mSculptedPreview->setPreviewTarget(fp->mRawImagep, 2.0f); + break; + default: + break; + } + + fp->mAvatarPreview->refresh(); + fp->mSculptedPreview->refresh(); } @@ -221,16 +221,16 @@ void LLFloaterImagePreview::onPreviewTypeCommit(LLUICtrl* ctrl, void* userdata) //----------------------------------------------------------------------------- void LLFloaterImagePreview::clearAllPreviewTextures() { - if (mAvatarPreview) - { - mAvatarPreview->clearPreviewTexture("mHairMesh0"); - mAvatarPreview->clearPreviewTexture("mUpperBodyMesh0"); - mAvatarPreview->clearPreviewTexture("mLowerBodyMesh0"); - mAvatarPreview->clearPreviewTexture("mHeadMesh0"); - mAvatarPreview->clearPreviewTexture("mUpperBodyMesh0"); - mAvatarPreview->clearPreviewTexture("mLowerBodyMesh0"); - mAvatarPreview->clearPreviewTexture("mSkirtMesh0"); - } + if (mAvatarPreview) + { + mAvatarPreview->clearPreviewTexture("mHairMesh0"); + mAvatarPreview->clearPreviewTexture("mUpperBodyMesh0"); + mAvatarPreview->clearPreviewTexture("mLowerBodyMesh0"); + mAvatarPreview->clearPreviewTexture("mHeadMesh0"); + mAvatarPreview->clearPreviewTexture("mUpperBodyMesh0"); + mAvatarPreview->clearPreviewTexture("mLowerBodyMesh0"); + mAvatarPreview->clearPreviewTexture("mSkirtMesh0"); + } } //----------------------------------------------------------------------------- @@ -238,92 +238,92 @@ void LLFloaterImagePreview::clearAllPreviewTextures() //----------------------------------------------------------------------------- void LLFloaterImagePreview::draw() { - LLFloater::draw(); - LLRect r = getRect(); - - if (mRawImagep.notNull()) - { - LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); - U32 selected = 0; - if (iface) - selected = iface->getFirstSelectedIndex(); - - if (selected <= 0) - { - gl_rect_2d_checkerboard(mPreviewRect); - - if(mImagep.notNull()) - { - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mImagep->getTexName()); - } - else - { - mImagep = LLViewerTextureManager::getLocalTexture(mRawImagep.get(), FALSE) ; - - gGL.getTexUnit(0)->unbind(mImagep->getTarget()) ; - gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mImagep->getTexName()); - stop_glerror(); - - gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); - - gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - if (mAvatarPreview) - { - mAvatarPreview->setTexture(mImagep->getTexName()); - mSculptedPreview->setTexture(mImagep->getTexName()); - } - } - - gGL.color3f(1.f, 1.f, 1.f); - gGL.begin( LLRender::QUADS ); - { - gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); - gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); - gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mBottom); - gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); - gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); - gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); - gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mTop); - gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); - } - gGL.end(); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - - stop_glerror(); - } - else - { - if ((mAvatarPreview) && (mSculptedPreview)) - { - gGL.color3f(1.f, 1.f, 1.f); - - if (selected == 9) - { - gGL.getTexUnit(0)->bind(mSculptedPreview); - } - else - { - gGL.getTexUnit(0)->bind(mAvatarPreview); - } - - gGL.begin( LLRender::QUADS ); - { - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); - } - gGL.end(); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - } - } - } + LLFloater::draw(); + LLRect r = getRect(); + + if (mRawImagep.notNull()) + { + LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); + U32 selected = 0; + if (iface) + selected = iface->getFirstSelectedIndex(); + + if (selected <= 0) + { + gl_rect_2d_checkerboard(mPreviewRect); + + if(mImagep.notNull()) + { + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mImagep->getTexName()); + } + else + { + mImagep = LLViewerTextureManager::getLocalTexture(mRawImagep.get(), FALSE) ; + + gGL.getTexUnit(0)->unbind(mImagep->getTarget()) ; + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mImagep->getTexName()); + stop_glerror(); + + gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + + gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + if (mAvatarPreview) + { + mAvatarPreview->setTexture(mImagep->getTexName()); + mSculptedPreview->setTexture(mImagep->getTexName()); + } + } + + gGL.color3f(1.f, 1.f, 1.f); + gGL.begin( LLRender::QUADS ); + { + gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mTop); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); + gGL.texCoord2f(mPreviewImageRect.mLeft, mPreviewImageRect.mBottom); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mBottom); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(mPreviewImageRect.mRight, mPreviewImageRect.mTop); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); + } + gGL.end(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + stop_glerror(); + } + else + { + if ((mAvatarPreview) && (mSculptedPreview)) + { + gGL.color3f(1.f, 1.f, 1.f); + + if (selected == 9) + { + gGL.getTexUnit(0)->bind(mSculptedPreview); + } + else + { + gGL.getTexUnit(0)->bind(mAvatarPreview); + } + + gGL.begin( LLRender::QUADS ); + { + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2i(PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_HPAD + PREF_BUTTON_HEIGHT + PREVIEW_HPAD); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2i(r.getWidth() - PREVIEW_HPAD, PREVIEW_TEXTURE_HEIGHT + PREVIEW_VPAD); + } + gGL.end(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + } + } } @@ -388,8 +388,8 @@ bool LLFloaterImagePreview::loadImage(const std::string& src_filename) LOG_UNHANDLED_EXCEPTION(""); return false; } - - return true; + + return true; } //----------------------------------------------------------------------------- @@ -397,17 +397,17 @@ bool LLFloaterImagePreview::loadImage(const std::string& src_filename) //----------------------------------------------------------------------------- BOOL LLFloaterImagePreview::handleMouseDown(S32 x, S32 y, MASK mask) { - if (mPreviewRect.pointInRect(x, y)) - { - bringToFront( x, y ); - gFocusMgr.setMouseCapture(this); - gViewerWindow->hideCursor(); - mLastMouseX = x; - mLastMouseY = y; - return TRUE; - } - - return LLFloater::handleMouseDown(x, y, mask); + if (mPreviewRect.pointInRect(x, y)) + { + bringToFront( x, y ); + gFocusMgr.setMouseCapture(this); + gViewerWindow->hideCursor(); + mLastMouseX = x; + mLastMouseY = y; + return TRUE; + } + + return LLFloater::handleMouseDown(x, y, mask); } //----------------------------------------------------------------------------- @@ -415,9 +415,9 @@ BOOL LLFloaterImagePreview::handleMouseDown(S32 x, S32 y, MASK mask) //----------------------------------------------------------------------------- BOOL LLFloaterImagePreview::handleMouseUp(S32 x, S32 y, MASK mask) { - gFocusMgr.setMouseCapture(FALSE); - gViewerWindow->showCursor(); - return LLFloater::handleMouseUp(x, y, mask); + gFocusMgr.setMouseCapture(FALSE); + gViewerWindow->showCursor(); + return LLFloater::handleMouseUp(x, y, mask); } //----------------------------------------------------------------------------- @@ -425,119 +425,119 @@ BOOL LLFloaterImagePreview::handleMouseUp(S32 x, S32 y, MASK mask) //----------------------------------------------------------------------------- BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask) { - MASK local_mask = mask & ~MASK_ALT; - - if (mAvatarPreview && hasMouseCapture()) - { - if (local_mask == MASK_PAN) - { - // pan here - LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); - if (iface && iface->getFirstSelectedIndex() <= 0) - { - mPreviewImageRect.translate((F32)(x - mLastMouseX) * -0.005f * mPreviewImageRect.getWidth(), - (F32)(y - mLastMouseY) * -0.005f * mPreviewImageRect.getHeight()); - } - else - { - mAvatarPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); - mSculptedPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); - } - } - else if (local_mask == MASK_ORBIT) - { - F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f; - F32 pitch_radians = (F32)(y - mLastMouseY) * 0.02f; - - mAvatarPreview->rotate(yaw_radians, pitch_radians); - mSculptedPreview->rotate(yaw_radians, pitch_radians); - } - else - { - LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); - if (iface && iface->getFirstSelectedIndex() <= 0) - { - F32 zoom_amt = (F32)(y - mLastMouseY) * -0.002f; - mPreviewImageRect.stretch(zoom_amt); - } - else - { - F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f; - F32 zoom_amt = (F32)(y - mLastMouseY) * 0.02f; - - mAvatarPreview->rotate(yaw_radians, 0.f); - mAvatarPreview->zoom(zoom_amt); - mSculptedPreview->rotate(yaw_radians, 0.f); - mSculptedPreview->zoom(zoom_amt); - } - } - - LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); - if (iface && iface->getFirstSelectedIndex() <= 0) - { - if (mPreviewImageRect.getWidth() > 1.f) - { - mPreviewImageRect.stretch((1.f - mPreviewImageRect.getWidth()) * 0.5f); - } - else if (mPreviewImageRect.getWidth() < 0.1f) - { - mPreviewImageRect.stretch((0.1f - mPreviewImageRect.getWidth()) * 0.5f); - } - - if (mPreviewImageRect.getHeight() > 1.f) - { - mPreviewImageRect.stretch((1.f - mPreviewImageRect.getHeight()) * 0.5f); - } - else if (mPreviewImageRect.getHeight() < 0.1f) - { - mPreviewImageRect.stretch((0.1f - mPreviewImageRect.getHeight()) * 0.5f); - } - - if (mPreviewImageRect.mLeft < 0.f) - { - mPreviewImageRect.translate(-mPreviewImageRect.mLeft, 0.f); - } - else if (mPreviewImageRect.mRight > 1.f) - { - mPreviewImageRect.translate(1.f - mPreviewImageRect.mRight, 0.f); - } - - if (mPreviewImageRect.mBottom < 0.f) - { - mPreviewImageRect.translate(0.f, -mPreviewImageRect.mBottom); - } - else if (mPreviewImageRect.mTop > 1.f) - { - mPreviewImageRect.translate(0.f, 1.f - mPreviewImageRect.mTop); - } - } - else - { - mAvatarPreview->refresh(); - mSculptedPreview->refresh(); - } - - LLUI::getInstance()->setMousePositionLocal(this, mLastMouseX, mLastMouseY); - } - - if (!mPreviewRect.pointInRect(x, y) || !mAvatarPreview || !mSculptedPreview) - { - return LLFloater::handleHover(x, y, mask); - } - else if (local_mask == MASK_ORBIT) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLCAMERA); - } - else if (local_mask == MASK_PAN) - { - gViewerWindow->setCursor(UI_CURSOR_TOOLPAN); - } - else - { - gViewerWindow->setCursor(UI_CURSOR_TOOLZOOMIN); - } - - return TRUE; + MASK local_mask = mask & ~MASK_ALT; + + if (mAvatarPreview && hasMouseCapture()) + { + if (local_mask == MASK_PAN) + { + // pan here + LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); + if (iface && iface->getFirstSelectedIndex() <= 0) + { + mPreviewImageRect.translate((F32)(x - mLastMouseX) * -0.005f * mPreviewImageRect.getWidth(), + (F32)(y - mLastMouseY) * -0.005f * mPreviewImageRect.getHeight()); + } + else + { + mAvatarPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); + mSculptedPreview->pan((F32)(x - mLastMouseX) * -0.005f, (F32)(y - mLastMouseY) * -0.005f); + } + } + else if (local_mask == MASK_ORBIT) + { + F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f; + F32 pitch_radians = (F32)(y - mLastMouseY) * 0.02f; + + mAvatarPreview->rotate(yaw_radians, pitch_radians); + mSculptedPreview->rotate(yaw_radians, pitch_radians); + } + else + { + LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); + if (iface && iface->getFirstSelectedIndex() <= 0) + { + F32 zoom_amt = (F32)(y - mLastMouseY) * -0.002f; + mPreviewImageRect.stretch(zoom_amt); + } + else + { + F32 yaw_radians = (F32)(x - mLastMouseX) * -0.01f; + F32 zoom_amt = (F32)(y - mLastMouseY) * 0.02f; + + mAvatarPreview->rotate(yaw_radians, 0.f); + mAvatarPreview->zoom(zoom_amt); + mSculptedPreview->rotate(yaw_radians, 0.f); + mSculptedPreview->zoom(zoom_amt); + } + } + + LLCtrlSelectionInterface* iface = childGetSelectionInterface("clothing_type_combo"); + if (iface && iface->getFirstSelectedIndex() <= 0) + { + if (mPreviewImageRect.getWidth() > 1.f) + { + mPreviewImageRect.stretch((1.f - mPreviewImageRect.getWidth()) * 0.5f); + } + else if (mPreviewImageRect.getWidth() < 0.1f) + { + mPreviewImageRect.stretch((0.1f - mPreviewImageRect.getWidth()) * 0.5f); + } + + if (mPreviewImageRect.getHeight() > 1.f) + { + mPreviewImageRect.stretch((1.f - mPreviewImageRect.getHeight()) * 0.5f); + } + else if (mPreviewImageRect.getHeight() < 0.1f) + { + mPreviewImageRect.stretch((0.1f - mPreviewImageRect.getHeight()) * 0.5f); + } + + if (mPreviewImageRect.mLeft < 0.f) + { + mPreviewImageRect.translate(-mPreviewImageRect.mLeft, 0.f); + } + else if (mPreviewImageRect.mRight > 1.f) + { + mPreviewImageRect.translate(1.f - mPreviewImageRect.mRight, 0.f); + } + + if (mPreviewImageRect.mBottom < 0.f) + { + mPreviewImageRect.translate(0.f, -mPreviewImageRect.mBottom); + } + else if (mPreviewImageRect.mTop > 1.f) + { + mPreviewImageRect.translate(0.f, 1.f - mPreviewImageRect.mTop); + } + } + else + { + mAvatarPreview->refresh(); + mSculptedPreview->refresh(); + } + + LLUI::getInstance()->setMousePositionLocal(this, mLastMouseX, mLastMouseY); + } + + if (!mPreviewRect.pointInRect(x, y) || !mAvatarPreview || !mSculptedPreview) + { + return LLFloater::handleHover(x, y, mask); + } + else if (local_mask == MASK_ORBIT) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLCAMERA); + } + else if (local_mask == MASK_PAN) + { + gViewerWindow->setCursor(UI_CURSOR_TOOLPAN); + } + else + { + gViewerWindow->setCursor(UI_CURSOR_TOOLZOOMIN); + } + + return TRUE; } //----------------------------------------------------------------------------- @@ -545,16 +545,16 @@ BOOL LLFloaterImagePreview::handleHover(S32 x, S32 y, MASK mask) //----------------------------------------------------------------------------- BOOL LLFloaterImagePreview::handleScrollWheel(S32 x, S32 y, S32 clicks) { - if (mPreviewRect.pointInRect(x, y) && mAvatarPreview) - { - mAvatarPreview->zoom((F32)clicks * -0.2f); - mAvatarPreview->refresh(); + if (mPreviewRect.pointInRect(x, y) && mAvatarPreview) + { + mAvatarPreview->zoom((F32)clicks * -0.2f); + mAvatarPreview->refresh(); - mSculptedPreview->zoom((F32)clicks * -0.2f); - mSculptedPreview->refresh(); - } + mSculptedPreview->zoom((F32)clicks * -0.2f); + mSculptedPreview->refresh(); + } - return TRUE; + return TRUE; } //----------------------------------------------------------------------------- @@ -563,7 +563,7 @@ BOOL LLFloaterImagePreview::handleScrollWheel(S32 x, S32 y, S32 clicks) // static void LLFloaterImagePreview::onMouseCaptureLostImagePreview(LLMouseHandler* handler) { - gViewerWindow->showCursor(); + gViewerWindow->showCursor(); } @@ -572,63 +572,63 @@ void LLFloaterImagePreview::onMouseCaptureLostImagePreview(LLMouseHandler* handl //----------------------------------------------------------------------------- LLImagePreviewAvatar::LLImagePreviewAvatar(S32 width, S32 height) : LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) { - mNeedsUpdate = TRUE; - mTargetJoint = NULL; - mTargetMesh = NULL; - mCameraDistance = 0.f; - mCameraYaw = 0.f; - mCameraPitch = 0.f; - mCameraZoom = 1.f; - - mDummyAvatar = (LLVOAvatar*)gObjectList.createObjectViewer(LL_PCODE_LEGACY_AVATAR, gAgent.getRegion(), LLViewerObject::CO_FLAG_UI_AVATAR); - mDummyAvatar->mSpecialRenderMode = 2; - - mTextureName = 0; + mNeedsUpdate = TRUE; + mTargetJoint = NULL; + mTargetMesh = NULL; + mCameraDistance = 0.f; + mCameraYaw = 0.f; + mCameraPitch = 0.f; + mCameraZoom = 1.f; + + mDummyAvatar = (LLVOAvatar*)gObjectList.createObjectViewer(LL_PCODE_LEGACY_AVATAR, gAgent.getRegion(), LLViewerObject::CO_FLAG_UI_AVATAR); + mDummyAvatar->mSpecialRenderMode = 2; + + mTextureName = 0; } LLImagePreviewAvatar::~LLImagePreviewAvatar() { - mDummyAvatar->markDead(); + mDummyAvatar->markDead(); } //virtual S8 LLImagePreviewAvatar::getType() const { - return LLViewerDynamicTexture::LL_IMAGE_PREVIEW_AVATAR ; + return LLViewerDynamicTexture::LL_IMAGE_PREVIEW_AVATAR ; } -void LLImagePreviewAvatar::setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male) -{ - mTargetJoint = mDummyAvatar->mRoot->findJoint(joint_name); - // clear out existing test mesh - if (mTargetMesh) - { - mTargetMesh->setTestTexture(0); - } - - if (male) - { - mDummyAvatar->setVisualParamWeight( "male", 1.f ); - mDummyAvatar->updateVisualParams(); - mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); - } - else - { - mDummyAvatar->setVisualParamWeight( "male", 0.f ); - mDummyAvatar->updateVisualParams(); - mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); - } - mDummyAvatar->mRoot->setVisible(FALSE, TRUE); - - mTargetMesh = dynamic_cast<LLViewerJointMesh*>(mDummyAvatar->mRoot->findJoint(mesh_name)); - mTargetMesh->setTestTexture(mTextureName); - mTargetMesh->setVisible(TRUE, FALSE); - mCameraDistance = distance; - mCameraZoom = 1.f; - mCameraPitch = 0.f; - mCameraYaw = 0.f; - mCameraOffset.clearVec(); +void LLImagePreviewAvatar::setPreviewTarget(const std::string& joint_name, const std::string& mesh_name, LLImageRaw* imagep, F32 distance, BOOL male) +{ + mTargetJoint = mDummyAvatar->mRoot->findJoint(joint_name); + // clear out existing test mesh + if (mTargetMesh) + { + mTargetMesh->setTestTexture(0); + } + + if (male) + { + mDummyAvatar->setVisualParamWeight( "male", 1.f ); + mDummyAvatar->updateVisualParams(); + mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); + } + else + { + mDummyAvatar->setVisualParamWeight( "male", 0.f ); + mDummyAvatar->updateVisualParams(); + mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable); + } + mDummyAvatar->mRoot->setVisible(FALSE, TRUE); + + mTargetMesh = dynamic_cast<LLViewerJointMesh*>(mDummyAvatar->mRoot->findJoint(mesh_name)); + mTargetMesh->setTestTexture(mTextureName); + mTargetMesh->setVisible(TRUE, FALSE); + mCameraDistance = distance; + mCameraZoom = 1.f; + mCameraPitch = 0.f; + mCameraYaw = 0.f; + mCameraOffset.clearVec(); } //----------------------------------------------------------------------------- @@ -636,15 +636,15 @@ void LLImagePreviewAvatar::setPreviewTarget(const std::string& joint_name, const //----------------------------------------------------------------------------- void LLImagePreviewAvatar::clearPreviewTexture(const std::string& mesh_name) { - if (mDummyAvatar) - { - LLViewerJointMesh *mesh = dynamic_cast<LLViewerJointMesh*>(mDummyAvatar->mRoot->findJoint(mesh_name)); - // clear out existing test mesh - if (mesh) - { - mesh->setTestTexture(0); - } - } + if (mDummyAvatar) + { + LLViewerJointMesh *mesh = dynamic_cast<LLViewerJointMesh*>(mDummyAvatar->mRoot->findJoint(mesh_name)); + // clear out existing test mesh + if (mesh) + { + mesh->setTestTexture(0); + } + } } //----------------------------------------------------------------------------- @@ -652,82 +652,82 @@ void LLImagePreviewAvatar::clearPreviewTexture(const std::string& mesh_name) //----------------------------------------------------------------------------- BOOL LLImagePreviewAvatar::render() { - mNeedsUpdate = FALSE; - LLVOAvatar* avatarp = mDummyAvatar; - - gGL.pushUIMatrix(); - gGL.loadUIIdentity(); - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); - - - LLGLSUIDefault def; - gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); - - gUIProgram.bind(); - - gl_rect_2d_simple( mFullWidth, mFullHeight ); - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); - - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); - - gGL.flush(); - LLVector3 target_pos = mTargetJoint->getWorldPosition(); - - LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * - LLQuaternion(mCameraYaw, LLVector3::z_axis); - - LLQuaternion av_rot = avatarp->mPelvisp->getWorldRotation() * camera_rot; - LLViewerCamera::getInstance()->setOriginAndLookAt( - target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + mCameraOffset) * av_rot), // camera - LLVector3::z_axis, // up - target_pos + (mCameraOffset * av_rot) ); // point of interest - - stop_glerror(); - - LLViewerCamera::getInstance()->setAspect((F32)mFullWidth / mFullHeight); - LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); - LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); - - LLVertexBuffer::unbind(); - avatarp->updateLOD(); - - if (avatarp->mDrawable.notNull()) - { - LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); - // make sure alpha=0 shows avatar material color - LLGLDisable no_blend(GL_BLEND); - - LLFace* face = avatarp->mDrawable->getFace(0); - if (face) - { - LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)face->getPool(); - gPipeline.enableLightsPreview(); - avatarPoolp->renderAvatars(avatarp); // renders only one avatar - } - } - - gGL.popUIMatrix(); - gGL.color4f(1,1,1,1); - return TRUE; + mNeedsUpdate = FALSE; + LLVOAvatar* avatarp = mDummyAvatar; + + gGL.pushUIMatrix(); + gGL.loadUIIdentity(); + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + + LLGLSUIDefault def; + gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); + + gUIProgram.bind(); + + gl_rect_2d_simple( mFullWidth, mFullHeight ); + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); + + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); + + gGL.flush(); + LLVector3 target_pos = mTargetJoint->getWorldPosition(); + + LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * + LLQuaternion(mCameraYaw, LLVector3::z_axis); + + LLQuaternion av_rot = avatarp->mPelvisp->getWorldRotation() * camera_rot; + LLViewerCamera::getInstance()->setOriginAndLookAt( + target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + mCameraOffset) * av_rot), // camera + LLVector3::z_axis, // up + target_pos + (mCameraOffset * av_rot) ); // point of interest + + stop_glerror(); + + LLViewerCamera::getInstance()->setAspect((F32)mFullWidth / mFullHeight); + LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); + LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); + + LLVertexBuffer::unbind(); + avatarp->updateLOD(); + + if (avatarp->mDrawable.notNull()) + { + LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE); + // make sure alpha=0 shows avatar material color + LLGLDisable no_blend(GL_BLEND); + + LLFace* face = avatarp->mDrawable->getFace(0); + if (face) + { + LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)face->getPool(); + gPipeline.enableLightsPreview(); + avatarPoolp->renderAvatars(avatarp); // renders only one avatar + } + } + + gGL.popUIMatrix(); + gGL.color4f(1,1,1,1); + return TRUE; } //----------------------------------------------------------------------------- // refresh() //----------------------------------------------------------------------------- void LLImagePreviewAvatar::refresh() -{ - mNeedsUpdate = TRUE; +{ + mNeedsUpdate = TRUE; } //----------------------------------------------------------------------------- @@ -735,9 +735,9 @@ void LLImagePreviewAvatar::refresh() //----------------------------------------------------------------------------- void LLImagePreviewAvatar::rotate(F32 yaw_radians, F32 pitch_radians) { - mCameraYaw = mCameraYaw + yaw_radians; + mCameraYaw = mCameraYaw + yaw_radians; - mCameraPitch = llclamp(mCameraPitch + pitch_radians, F_PI_BY_TWO * -0.8f, F_PI_BY_TWO * 0.8f); + mCameraPitch = llclamp(mCameraPitch + pitch_radians, F_PI_BY_TWO * -0.8f, F_PI_BY_TWO * 0.8f); } //----------------------------------------------------------------------------- @@ -745,13 +745,13 @@ void LLImagePreviewAvatar::rotate(F32 yaw_radians, F32 pitch_radians) //----------------------------------------------------------------------------- void LLImagePreviewAvatar::zoom(F32 zoom_amt) { - mCameraZoom = llclamp(mCameraZoom + zoom_amt, 1.f, 10.f); + mCameraZoom = llclamp(mCameraZoom + zoom_amt, 1.f, 10.f); } void LLImagePreviewAvatar::pan(F32 right, F32 up) { - mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f); - mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f); + mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f); + mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f); } @@ -761,19 +761,19 @@ void LLImagePreviewAvatar::pan(F32 right, F32 up) LLImagePreviewSculpted::LLImagePreviewSculpted(S32 width, S32 height) : LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE) { - mNeedsUpdate = TRUE; - mCameraDistance = 0.f; - mCameraYaw = 0.f; - mCameraPitch = 0.f; - mCameraZoom = 1.f; - mTextureName = 0; - - LLVolumeParams volume_params; - volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_CIRCLE); - volume_params.setSculptID(LLUUID::null, LL_SCULPT_TYPE_SPHERE); - - F32 const HIGHEST_LOD = 4.0f; - mVolume = new LLVolume(volume_params, HIGHEST_LOD); + mNeedsUpdate = TRUE; + mCameraDistance = 0.f; + mCameraYaw = 0.f; + mCameraPitch = 0.f; + mCameraZoom = 1.f; + mTextureName = 0; + + LLVolumeParams volume_params; + volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_CIRCLE); + volume_params.setSculptID(LLUUID::null, LL_SCULPT_TYPE_SPHERE); + + F32 const HIGHEST_LOD = 4.0f; + mVolume = new LLVolume(volume_params, HIGHEST_LOD); } @@ -784,67 +784,67 @@ LLImagePreviewSculpted::~LLImagePreviewSculpted() //virtual S8 LLImagePreviewSculpted::getType() const { - return LLViewerDynamicTexture::LL_IMAGE_PREVIEW_SCULPTED ; + return LLViewerDynamicTexture::LL_IMAGE_PREVIEW_SCULPTED ; } void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) -{ - mCameraDistance = distance; - mCameraZoom = 1.f; - mCameraPitch = 0.f; - mCameraYaw = 0.f; - mCameraOffset.clearVec(); - - if (imagep) - { - mVolume->sculpt(imagep->getWidth(), imagep->getHeight(), imagep->getComponents(), imagep->getData(), 0, false); - } - - const LLVolumeFace &vf = mVolume->getVolumeFace(0); - U32 num_indices = vf.mNumIndices; - U32 num_vertices = vf.mNumVertices; - - mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0); - if (!mVertexBuffer->allocateBuffer(num_vertices, num_indices)) - { - LL_WARNS() << "Failed to allocate Vertex Buffer for image preview to" - << num_vertices << " vertices and " - << num_indices << " indices" << LL_ENDL; - // We are likely to crash on getTexCoord0Strider() - } - - LLStrider<LLVector3> vertex_strider; - LLStrider<LLVector3> normal_strider; - LLStrider<LLVector2> tc_strider; - LLStrider<U16> index_strider; - - mVertexBuffer->getVertexStrider(vertex_strider); - mVertexBuffer->getNormalStrider(normal_strider); - mVertexBuffer->getTexCoord0Strider(tc_strider); - mVertexBuffer->getIndexStrider(index_strider); - - // build vertices and normals - LLStrider<LLVector3> pos; - pos = (LLVector3*) vf.mPositions; pos.setStride(16); - LLStrider<LLVector3> norm; - norm = (LLVector3*) vf.mNormals; norm.setStride(16); - LLStrider<LLVector2> tc; - tc = (LLVector2*) vf.mTexCoords; tc.setStride(8); - - for (U32 i = 0; i < num_vertices; i++) - { - *(vertex_strider++) = *pos++; - LLVector3 normal = *norm++; - normal.normalize(); - *(normal_strider++) = normal; - *(tc_strider++) = *tc++; - } - - // build indices - for (U16 i = 0; i < num_indices; i++) - { - *(index_strider++) = vf.mIndices[i]; - } +{ + mCameraDistance = distance; + mCameraZoom = 1.f; + mCameraPitch = 0.f; + mCameraYaw = 0.f; + mCameraOffset.clearVec(); + + if (imagep) + { + mVolume->sculpt(imagep->getWidth(), imagep->getHeight(), imagep->getComponents(), imagep->getData(), 0, false); + } + + const LLVolumeFace &vf = mVolume->getVolumeFace(0); + U32 num_indices = vf.mNumIndices; + U32 num_vertices = vf.mNumVertices; + + mVertexBuffer = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0); + if (!mVertexBuffer->allocateBuffer(num_vertices, num_indices)) + { + LL_WARNS() << "Failed to allocate Vertex Buffer for image preview to" + << num_vertices << " vertices and " + << num_indices << " indices" << LL_ENDL; + // We are likely to crash on getTexCoord0Strider() + } + + LLStrider<LLVector3> vertex_strider; + LLStrider<LLVector3> normal_strider; + LLStrider<LLVector2> tc_strider; + LLStrider<U16> index_strider; + + mVertexBuffer->getVertexStrider(vertex_strider); + mVertexBuffer->getNormalStrider(normal_strider); + mVertexBuffer->getTexCoord0Strider(tc_strider); + mVertexBuffer->getIndexStrider(index_strider); + + // build vertices and normals + LLStrider<LLVector3> pos; + pos = (LLVector3*) vf.mPositions; pos.setStride(16); + LLStrider<LLVector3> norm; + norm = (LLVector3*) vf.mNormals; norm.setStride(16); + LLStrider<LLVector2> tc; + tc = (LLVector2*) vf.mTexCoords; tc.setStride(8); + + for (U32 i = 0; i < num_vertices; i++) + { + *(vertex_strider++) = *pos++; + LLVector3 normal = *norm++; + normal.normalize(); + *(normal_strider++) = normal; + *(tc_strider++) = *tc++; + } + + // build indices + for (U16 i = 0; i < num_indices; i++) + { + *(index_strider++) = vf.mIndices[i]; + } mVertexBuffer->unmapBuffer(); } @@ -855,82 +855,82 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance) //----------------------------------------------------------------------------- BOOL LLImagePreviewSculpted::render() { - mNeedsUpdate = FALSE; - LLGLSUIDefault def; - LLGLDisable no_blend(GL_BLEND); - LLGLEnable cull(GL_CULL_FACE); - LLGLDepthTest depth(GL_TRUE); + mNeedsUpdate = FALSE; + LLGLSUIDefault def; + LLGLDisable no_blend(GL_BLEND); + LLGLEnable cull(GL_CULL_FACE); + LLGLDepthTest depth(GL_TRUE); + + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.pushMatrix(); - gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.pushMatrix(); - gGL.loadIdentity(); - - gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); + gGL.color4f(0.15f, 0.2f, 0.3f, 1.f); - gUIProgram.bind(); + gUIProgram.bind(); - gl_rect_2d_simple( mFullWidth, mFullHeight ); - - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.popMatrix(); + gl_rect_2d_simple( mFullWidth, mFullHeight ); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.popMatrix(); + gGL.matrixMode(LLRender::MM_PROJECTION); + gGL.popMatrix(); - glClear(GL_DEPTH_BUFFER_BIT); - - LLVector3 target_pos(0, 0, 0); + gGL.matrixMode(LLRender::MM_MODELVIEW); + gGL.popMatrix(); - LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * - LLQuaternion(mCameraYaw, LLVector3::z_axis); + glClear(GL_DEPTH_BUFFER_BIT); - LLQuaternion av_rot = camera_rot; - LLViewerCamera::getInstance()->setOriginAndLookAt( - target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + mCameraOffset) * av_rot), // camera - LLVector3::z_axis, // up - target_pos + (mCameraOffset * av_rot) ); // point of interest + LLVector3 target_pos(0, 0, 0); - stop_glerror(); + LLQuaternion camera_rot = LLQuaternion(mCameraPitch, LLVector3::y_axis) * + LLQuaternion(mCameraYaw, LLVector3::z_axis); - LLViewerCamera::getInstance()->setAspect((F32) mFullWidth / mFullHeight); - LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); - LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); + LLQuaternion av_rot = camera_rot; + LLViewerCamera::getInstance()->setOriginAndLookAt( + target_pos + ((LLVector3(mCameraDistance, 0.f, 0.f) + mCameraOffset) * av_rot), // camera + LLVector3::z_axis, // up + target_pos + (mCameraOffset * av_rot) ); // point of interest - const LLVolumeFace &vf = mVolume->getVolumeFace(0); - U32 num_indices = vf.mNumIndices; - - gPipeline.enableLightsAvatar(); + stop_glerror(); - gObjectPreviewProgram.bind(); - gPipeline.enableLightsPreview(); + LLViewerCamera::getInstance()->setAspect((F32) mFullWidth / mFullHeight); + LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / mCameraZoom); + LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, mFullWidth, mFullHeight, FALSE); - gGL.pushMatrix(); - const F32 SCALE = 1.25f; - gGL.scalef(SCALE, SCALE, SCALE); - const F32 BRIGHTNESS = 0.9f; - gGL.diffuseColor3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); + const LLVolumeFace &vf = mVolume->getVolumeFace(0); + U32 num_indices = vf.mNumIndices; - mVertexBuffer->setBuffer(); - mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0); + gPipeline.enableLightsAvatar(); - gGL.popMatrix(); + gObjectPreviewProgram.bind(); + gPipeline.enableLightsPreview(); - gObjectPreviewProgram.unbind(); + gGL.pushMatrix(); + const F32 SCALE = 1.25f; + gGL.scalef(SCALE, SCALE, SCALE); + const F32 BRIGHTNESS = 0.9f; + gGL.diffuseColor3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); - return TRUE; + mVertexBuffer->setBuffer(); + mVertexBuffer->draw(LLRender::TRIANGLES, num_indices, 0); + + gGL.popMatrix(); + + gObjectPreviewProgram.unbind(); + + return TRUE; } //----------------------------------------------------------------------------- // refresh() //----------------------------------------------------------------------------- void LLImagePreviewSculpted::refresh() -{ - mNeedsUpdate = TRUE; +{ + mNeedsUpdate = TRUE; } //----------------------------------------------------------------------------- @@ -938,9 +938,9 @@ void LLImagePreviewSculpted::refresh() //----------------------------------------------------------------------------- void LLImagePreviewSculpted::rotate(F32 yaw_radians, F32 pitch_radians) { - mCameraYaw = mCameraYaw + yaw_radians; + mCameraYaw = mCameraYaw + yaw_radians; - mCameraPitch = llclamp(mCameraPitch + pitch_radians, F_PI_BY_TWO * -0.8f, F_PI_BY_TWO * 0.8f); + mCameraPitch = llclamp(mCameraPitch + pitch_radians, F_PI_BY_TWO * -0.8f, F_PI_BY_TWO * 0.8f); } //----------------------------------------------------------------------------- @@ -948,11 +948,11 @@ void LLImagePreviewSculpted::rotate(F32 yaw_radians, F32 pitch_radians) //----------------------------------------------------------------------------- void LLImagePreviewSculpted::zoom(F32 zoom_amt) { - mCameraZoom = llclamp(mCameraZoom + zoom_amt, 1.f, 10.f); + mCameraZoom = llclamp(mCameraZoom + zoom_amt, 1.f, 10.f); } void LLImagePreviewSculpted::pan(F32 right, F32 up) { - mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f); - mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f); + mCameraOffset.mV[VY] = llclamp(mCameraOffset.mV[VY] + right * mCameraDistance / mCameraZoom, -1.f, 1.f); + mCameraOffset.mV[VZ] = llclamp(mCameraOffset.mV[VZ] + up * mCameraDistance / mCameraZoom, -1.f, 1.f); } |