summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rwxr-xr-xindra/newview/llfloatermodelpreview.cpp166
-rwxr-xr-xindra/newview/llfloatermodelpreview.h5
2 files changed, 54 insertions, 117 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 861dc88983..29bbf7d01e 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -610,7 +610,7 @@ void LLFloaterModelPreview::onAutoFillCommit(LLUICtrl* ctrl, void* userdata)
{
LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata;
- fp->mModelPreview->genLODs();
+ fp->mModelPreview->queryLODs();
}
void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit)
@@ -638,7 +638,12 @@ void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit)
//-----------------------------------------------------------------------------
void LLFloaterModelPreview::draw()
{
- LLFloater::draw();
+ LLFloater::draw();
+
+ if (!mModelPreview)
+ {
+ return;
+ }
mModelPreview->update();
@@ -668,7 +673,7 @@ void LLFloaterModelPreview::draw()
childSetTextArg("prim_cost", "[PRIM_COST]", llformat("%d", mModelPreview->mResourceCost));
childSetTextArg("description_label", "[TEXTURES]", llformat("%d", mModelPreview->mTextureSet.size()));
- if (mModelPreview)
+ if (mModelPreview->lodsReady())
{
gGL.color3f(1.f, 1.f, 1.f);
@@ -1178,6 +1183,7 @@ void LLFloaterModelPreview::onMouseCaptureLostModelPreview(LLMouseHandler* handl
LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp)
: LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE), LLMutex(NULL)
+, mLodsQuery()
, mPelvisZOffset( 0.0f )
, mLegacyRigValid( false )
, mRigValidJointUpload( false )
@@ -2573,112 +2579,6 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim
shader->bind();
}
}
-void LLModelPreview::genModelBBox()
-{
- LLVector3 min, max;
- min = this->mModelLoader->mExtents[0];
- max = this->mModelLoader->mExtents[1];
- std::vector<LLVector3> v_list;
- v_list.resize(4);
- std::map<U8, std::vector<LLVector3> > face_list;
-
- // Face 0
- v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]);
- v_list[1] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]);
- v_list[2] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]);
- v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]);
- face_list.insert(std::pair<U8, std::vector<LLVector3> >(0, v_list));
-
- // Face 1
- v_list[0] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]);
- v_list[1] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]);
- v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]);
- v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]);
- face_list.insert(std::pair<U8, std::vector<LLVector3> >(1, v_list));
-
- // Face 2
- v_list[0] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]);
- v_list[1] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]);
- v_list[2] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]);
- v_list[3] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]);
- face_list.insert(std::pair<U8, std::vector<LLVector3> >(2, v_list));
-
- // Face 3
- v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]);
- v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]);
- v_list[2] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]);
- v_list[3] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]);
- face_list.insert(std::pair<U8, std::vector<LLVector3> >(3, v_list));
-
- // Face 4
- v_list[0] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]);
- v_list[1] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]);
- v_list[2] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]);
- v_list[3] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]);
- face_list.insert(std::pair<U8, std::vector<LLVector3> >(4, v_list));
-
- // Face 5
- v_list[0] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]);
- v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]);
- v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]);
- v_list[3] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]);
- face_list.insert(std::pair<U8, std::vector<LLVector3> >(5, v_list));
-
- U16 Idx[] = { 0, 1, 2, 3, 0, 2, };
-
- U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0;
- LLPointer<LLVertexBuffer> buff = new LLVertexBuffer(type_mask, 0);
- buff->allocateBuffer(4, 6, true);
-
- LLStrider<LLVector3> pos;
- LLStrider<U16> idx;
- LLStrider<LLVector3> norm;
- LLStrider<LLVector2> tc;
-
- buff->getVertexStrider(pos);
- buff->getIndexStrider(idx);
-
- buff->getNormalStrider(norm);
- buff->getTexCoord0Strider(tc);
-
- for (U32 i = 0; i < 6; ++i)
- {
- idx[i] = Idx[i];
- }
-
- LLVolumeParams volume_params;
- volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE);
- LLModel* mdl = new LLModel(volume_params, 0.f);
- mdl->mLabel = "BBOX"; // please adopt name from high LOD (mBaseModel) or from original model otherwise it breaks search mechanics which is name based
-
- mdl->setNumVolumeFaces(6);
- for (U8 i = 0; i < 6; ++i)
- {
- for (U8 j = 0; j < 4; ++j)
- {
- pos[j] = face_list[i][j];
- }
-
- mdl->setVolumeFaceData(i, pos, norm, tc, idx, buff->getNumVerts(), buff->getNumIndices());
- }
-
- if (validate_model(mdl))
- {
- LLMatrix4 mat;
- std::map<std::string, LLImportMaterial> materials;
- std::vector<LLModelInstance> instance_list;
- instance_list.push_back(LLModelInstance(mdl, mdl->mLabel, mat, materials));
-
- for (S32 i = LLModel::LOD_HIGH - 1; i >= 0; i--)
- {
- mModel[i].clear();
- mModel[i].push_back(mdl);
-
- mScene[i].clear();
- mScene[i].insert(std::pair<LLMatrix4, std::vector<LLModelInstance> >(mat, instance_list));
- }
- }
-}
void LLModelPreview::updateStatusMessages()
{
@@ -3422,14 +3322,25 @@ void LLModelPreview::genBuffers(S32 lod, bool include_skin_weights)
void LLModelPreview::update()
{
if (mGenLOD)
- {
- mGenLOD = false;
- genLODs();
- refresh();
- updateStatusMessages();
- }
+ {
+ bool subscribe_for_generation = mLodsQuery.empty();
+ mGenLOD = false;
+ mDirty = true;
+ mLodsQuery.clear();
+
+ for (S32 lod = LLModel::LOD_HIGH; lod >= 0; --lod)
+ {
+ // adding all lods into query for generation
+ mLodsQuery.push_back(lod);
+ }
- if (mDirty)
+ if (subscribe_for_generation)
+ {
+ doOnIdleRepeating(lodQueryCallback);
+ }
+ }
+
+ if (mDirty && mLodsQuery.empty())
{
mDirty = false;
mResourceCost = calcResourceCost();
@@ -4350,6 +4261,29 @@ void LLModelPreview::textureLoadedCallback( BOOL success, LLViewerFetchedTexture
}
}
+// static
+bool LLModelPreview::lodQueryCallback()
+{
+ // not the best solution, but model preview belongs to floater
+ // so it is an easy way to check that preview still exists.
+ LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance;
+ if (fmp && fmp->mModelPreview)
+ {
+ LLModelPreview* preview = fmp->mModelPreview;
+ if (preview->mLodsQuery.size() > 0)
+ {
+ S32 lod = preview->mLodsQuery.back();
+ preview->mLodsQuery.pop_back();
+ preview->genLODs(lod);
+
+ // return false to continue cycle
+ return false;
+ }
+ }
+ // nothing to process
+ return true;
+}
+
void LLModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit)
{
if (!mLODFrozen)
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h
index 07e29d09c7..b2bb15ef05 100755
--- a/indra/newview/llfloatermodelpreview.h
+++ b/indra/newview/llfloatermodelpreview.h
@@ -261,8 +261,9 @@ public:
void clearModel(S32 lod);
void loadModel(std::string filename, S32 lod, bool force_disable_slm = false);
void loadModelCallback(S32 lod);
+ bool lodsReady() { return !mGenLOD && mLodsQuery.empty(); }
+ void queryLODs() { mGenLOD = true; };
void genLODs(S32 which_lod = -1, U32 decimation = 3, bool enforce_tri_limit = false);
- void genModelBBox(); // Generate just a model BBox if we can't generate proper LOD
void generateNormals();
void restoreNormals();
U32 calcResourceCost();
@@ -290,6 +291,7 @@ public:
void setLegacyRigValid( bool rigValid ) { mLegacyRigValid = rigValid; }
static void textureLoadedCallback( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata );
+ static bool lodQueryCallback();
boost::signals2::connection setDetailsCallback( const details_signal_t::slot_type& cb ){ return mDetailsSignal.connect(cb); }
boost::signals2::connection setModelLoadedCallback( const model_loaded_signal_t::slot_type& cb ){ return mModelLoadedSignal.connect(cb); }
@@ -303,6 +305,7 @@ public:
LLVector3 getTranslationForJointOffset( std::string joint );
static bool sIgnoreLoadedCallback;
+ std::vector<S32> mLodsQuery;
protected: