meow-7.2.2
leyla_linden 2010-12-22 16:50:38 -08:00
commit ae50a7cca2
9 changed files with 4746 additions and 4713 deletions

View File

@ -27,6 +27,7 @@
#include "linden_common.h"
#include "llmodel.h"
#include "llconvexdecomposition.h"
#include "llsdserialize.h"
#include "llvector4a.h"
@ -57,7 +58,15 @@ const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string);
LLModel::LLModel(LLVolumeParams& params, F32 detail)
: LLVolume(params, detail), mNormalizedScale(1,1,1), mNormalizedTranslation(0,0,0)
{
mDecompID = -1;
}
LLModel::~LLModel()
{
if (mDecompID >= 0)
{
LLConvexDecomposition::getInstance()->deleteDecomposition(mDecompID);
}
}
void load_face_from_dom_inputs(LLVolumeFace& face, const domInputLocalOffset_Array& inputs, U32 min_idx, U32 max_idx)
@ -941,11 +950,10 @@ void LLModel::normalizeVolumeFaces()
LLVector4a size;
size.setSub(max, min);
// To make the model fit within
// the unit cube with only the largest
// dimensions fitting on the surface of the cube,
// calculate the largest extent on any axis
F32 scale = 1.f/llmax(llmax(size[0], size[1]), size[2]);
// Compute scale as reciprocal of size
LLVector4a scale;
scale.splat(1.f);
scale.div(size);
for (U32 i = 0; i < mVolumeFaces.size(); ++i)
{
@ -974,7 +982,10 @@ void LLModel::normalizeVolumeFaces()
// we would need to multiply the model
// by to get the original size of the
// model instead of the normalized size.
mNormalizedScale = LLVector3(1,1,1) / scale;
LLVector4a normalized_scale;
normalized_scale.splat(1.f);
normalized_scale.div(scale);
mNormalizedScale.set(normalized_scale.getF32ptr());
mNormalizedTranslation.set(trans.getF32ptr());
mNormalizedTranslation *= -1.f;
}

View File

@ -56,6 +56,8 @@ public:
typedef std::vector<LLVector3> hull;
LLModel(LLVolumeParams& params, F32 detail);
~LLModel();
static LLSD writeModel(
std::string filename,
LLModel* physics,
@ -193,6 +195,7 @@ public:
LLVector3 mNormalizedTranslation;
// convex hull decomposition
S32 mDecompID;
convex_hull_decomposition mConvexHullDecomp;
void setConvexHullDecomposition(
const convex_hull_decomposition& decomp);

View File

@ -1262,6 +1262,7 @@ bool LLAppViewer::mainLoop()
break;
}
}
gMeshRepo.update() ;
if(!total_work_pending) //pause texture fetching threads if nothing to process.
{

File diff suppressed because it is too large Load Diff

View File

@ -1,330 +1,337 @@
/**
* @file llfloatermodelpreview.h
* @brief LLFloaterModelPreview class definition
*
* $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$
*/
#ifndef LL_LLFLOATERMODELPREVIEW_H
#define LL_LLFLOATERMODELPREVIEW_H
#include "llfloaternamedesc.h"
#include "lldynamictexture.h"
#include "llquaternion.h"
#include "llmeshrepository.h"
#include "llmodel.h"
#include "llthread.h"
#include "llviewermenufile.h"
class LLComboBox;
class LLJoint;
class LLViewerJointMesh;
class LLVOAvatar;
class LLTextBox;
class LLVertexBuffer;
class LLModelPreview;
class LLFloaterModelPreview;
class daeElement;
class domProfile_COMMON;
class domInstance_geometry;
class domNode;
class domTranslate;
class LLMenuButton;
class LLToggleableMenu;
/**
* @file llfloatermodelpreview.h
* @brief LLFloaterModelPreview class definition
*
* $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$
*/
#ifndef LL_LLFLOATERMODELPREVIEW_H
#define LL_LLFLOATERMODELPREVIEW_H
#include "llfloaternamedesc.h"
#include "lldynamictexture.h"
#include "llquaternion.h"
#include "llmeshrepository.h"
#include "llmodel.h"
#include "llthread.h"
#include "llviewermenufile.h"
class LLComboBox;
class LLJoint;
class LLViewerJointMesh;
class LLVOAvatar;
class LLTextBox;
class LLVertexBuffer;
class LLModelPreview;
class LLFloaterModelPreview;
class daeElement;
class domProfile_COMMON;
class domInstance_geometry;
class domNode;
class domTranslate;
class LLMenuButton;
class LLToggleableMenu;
const S32 NUM_LOD = 4;
class LLModelLoader : public LLThread
{
public:
typedef enum
{
STARTING = 0,
READING_FILE,
CREATING_FACES,
GENERATING_VERTEX_BUFFERS,
GENERATING_LOD,
DONE,
ERROR_PARSING, //basically loading failed
} eLoadState;
U32 mState;
std::string mFilename;
S32 mLod;
LLModelPreview* mPreview;
LLMatrix4 mTransform;
BOOL mFirstTransform;
LLVector3 mExtents[2];
std::map<daeElement*, LLPointer<LLModel> > mModel;
typedef std::vector<LLPointer<LLModel> > model_list;
model_list mModelList;
typedef std::vector<LLModelInstance> model_instance_list;
typedef std::map<LLMatrix4, model_instance_list > scene;
scene mScene;
typedef std::queue<LLPointer<LLModel> > model_queue;
//queue of models that need a physics rep
model_queue mPhysicsQ;
LLModelLoader(std::string filename, S32 lod, LLModelPreview* preview);
virtual void run();
void processElement(daeElement* element);
std::vector<LLImportMaterial> getMaterials(LLModel* model, domInstance_geometry* instance_geo);
LLImportMaterial profileToMaterial(domProfile_COMMON* material);
std::string getElementLabel(daeElement *element);
LLColor4 getDaeColor(daeElement* element);
daeElement* getChildFromElement( daeElement* pElement, std::string const & name );
bool isNodeAJoint( domNode* pNode );
void processJointNode( domNode* pNode, std::map<std::string,LLMatrix4>& jointTransforms );
void extractTranslation( domTranslate* pTranslate, LLMatrix4& transform );
void extractTranslationViaElement( daeElement* pTranslateElement, LLMatrix4& transform );
void setLoadState( U32 state ) { mState = state; }
U32 getLoadState( void ) { return mState; }
//map of avatar joints as named in COLLADA assets to internal joint names
std::map<std::string, std::string> mJointMap;
};
class LLFloaterModelPreview : public LLFloater
{
public:
class DecompRequest : public LLPhysicsDecomp::Request
{
public:
S32 mContinue;
LLPointer<LLModel> mModel;
DecompRequest(const std::string& stage, LLModel* mdl);
virtual S32 statusCallback(const char* status, S32 p1, S32 p2);
virtual void completed();
};
static LLFloaterModelPreview* sInstance;
LLFloaterModelPreview(const LLSD& key);
virtual ~LLFloaterModelPreview();
virtual BOOL postBuild();
BOOL handleMouseDown(S32 x, S32 y, MASK mask);
BOOL handleMouseUp(S32 x, S32 y, MASK mask);
BOOL handleHover(S32 x, S32 y, MASK mask);
BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
static void onMouseCaptureLostModelPreview(LLMouseHandler*);
static void setUploadAmount(S32 amount) { sUploadAmount = amount; }
static void onBrowseLOD(void* data);
static void onUpload(void* data);
static void onClearMaterials(void* data);
static void onModelDecompositionComplete(LLModel* model, std::vector<LLPointer<LLVertexBuffer> >& physics_mesh);
static void refresh(LLUICtrl* ctrl, void* data);
void updateResourceCost();
void loadModel(S32 lod);
void onViewOptionChecked(const LLSD& userdata);
bool isViewOptionChecked(const LLSD& userdata);
bool isViewOptionEnabled(const LLSD& userdata);
void setViewOptionEnabled(const std::string& option, bool enabled);
void enableViewOption(const std::string& option);
void disableViewOption(const std::string& option);
void setViewOption(const std::string& option, bool value);
protected:
friend class LLModelPreview;
friend class LLMeshFilePicker;
friend class LLPhysicsDecomp;
static void onImportScaleCommit(LLUICtrl*, void*);
static void onUploadJointsCommit(LLUICtrl*,void*);
static void onUploadSkinCommit(LLUICtrl*,void*);
static void onPreviewLODCommit(LLUICtrl*,void*);
static void onGenerateNormalsCommit(LLUICtrl*,void*);
static void onAutoFillCommit(LLUICtrl*,void*);
static void onLODParamCommit(LLUICtrl*,void*);
static void onExplodeCommit(LLUICtrl*, void*);
static void onPhysicsParamCommit(LLUICtrl* ctrl, void* userdata);
static void onPhysicsStageExecute(LLUICtrl* ctrl, void* userdata);
static void onPhysicsStageCancel(LLUICtrl* ctrl, void* userdata);
static void onPhysicsBrowse(LLUICtrl* ctrl, void* userdata);
static void onPhysicsUseLOD(LLUICtrl* ctrl, void* userdata);
static void onPhysicsOptimize(LLUICtrl* ctrl, void* userdata);
static void onPhysicsDecomposeBack(LLUICtrl* ctrl, void* userdata);
static void onPhysicsSimplifyBack(LLUICtrl* ctrl, void* userdata);
void draw();
void initDecompControls();
LLModelPreview* mModelPreview;
LLPhysicsDecomp::decomp_params mDecompParams;
S32 mLastMouseX;
S32 mLastMouseY;
LLRect mPreviewRect;
U32 mGLName;
static S32 sUploadAmount;
LLPointer<DecompRequest> mCurRequest;
std::map<std::string, bool> mViewOption;
//use "disabled" as false by default
std::map<std::string, bool> mViewOptionDisabled;
LLMenuButton* mViewOptionMenuButton;
LLToggleableMenu* mViewOptionMenu;
};
class LLMeshFilePicker : public LLFilePickerThread
{
public:
LLMeshFilePicker(LLModelPreview* mp, S32 lod);
virtual void notify(const std::string& filename);
private:
LLModelPreview* mMP;
S32 mLOD;
};
class LLModelPreview : public LLViewerDynamicTexture, public LLMutex
{
public:
LLModelPreview(S32 width, S32 height, LLFloater* fmp);
virtual ~LLModelPreview();
void resetPreviewTarget();
void setPreviewTarget(F32 distance);
void setTexture(U32 name) { mTextureName = name; }
void setPhysicsFromLOD(S32 lod);
BOOL render();
void update();
void genBuffers(S32 lod, bool skinned);
void clearBuffers();
void refresh();
void rotate(F32 yaw_radians, F32 pitch_radians);
void zoom(F32 zoom_amt);
void pan(F32 right, F32 up);
virtual BOOL needsRender() { return mNeedsUpdate; }
void setPreviewLOD(S32 lod);
void clearModel(S32 lod);
void loadModel(std::string filename, S32 lod);
void loadModelCallback(S32 lod);
void genLODs(S32 which_lod = -1, U32 decimation = 3);
void generateNormals();
void consolidate();
void clearMaterials();
U32 calcResourceCost();
void rebuildUploadData();
void clearIncompatible(S32 lod);
void updateStatusMessages();
bool containsRiggedAsset( void );
void clearGLODGroup();
static void textureLoadedCallback( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata );
protected:
friend class LLFloaterModelPreview;
friend class LLFloaterModelWizard;
friend class LLFloaterModelPreview::DecompRequest;
friend class LLPhysicsDecomp;
LLFloater* mFMP;
BOOL mNeedsUpdate;
bool mDirty;
bool mGenLOD;
U32 mTextureName;
F32 mCameraDistance;
F32 mCameraYaw;
F32 mCameraPitch;
F32 mCameraZoom;
LLVector3 mCameraOffset;
LLVector3 mPreviewTarget;
LLVector3 mPreviewScale;
S32 mPreviewLOD;
U32 mResourceCost;
std::string mLODFile[LLModel::NUM_LODS];
bool mLoading;
//GLOD object parameters (must rebuild object if these change)
F32 mBuildShareTolerance;
U32 mBuildQueueMode;
U32 mBuildOperator;
U32 mBuildBorderMode;
LLModelLoader* mModelLoader;
LLModelLoader::scene mScene[LLModel::NUM_LODS];
LLModelLoader::scene mBaseScene;
LLModelLoader::model_list mModel[LLModel::NUM_LODS];
LLModelLoader::model_list mBaseModel;
U32 mGroup;
std::map<LLPointer<LLModel>, U32> mObject;
U32 mMaxTriangleLimit;
std::map<LLPointer<LLModel>, std::vector<LLPointer<LLVertexBuffer> > > mPhysicsMesh;
LLMeshUploadThread::instance_list mUploadData;
std::set<LLPointer<LLViewerFetchedTexture> > mTextureSet;
//map of vertex buffers to models (one vertex buffer in vector per face in model
std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mVertexBuffer[LLModel::NUM_LODS+1];
};
#endif // LL_LLFLOATERMODELPREVIEW_H
class LLModelLoader : public LLThread
{
public:
typedef enum
{
STARTING = 0,
READING_FILE,
CREATING_FACES,
GENERATING_VERTEX_BUFFERS,
GENERATING_LOD,
DONE,
ERROR_PARSING, //basically loading failed
} eLoadState;
U32 mState;
std::string mFilename;
S32 mLod;
LLModelPreview* mPreview;
LLMatrix4 mTransform;
BOOL mFirstTransform;
LLVector3 mExtents[2];
std::map<daeElement*, LLPointer<LLModel> > mModel;
typedef std::vector<LLPointer<LLModel> > model_list;
model_list mModelList;
typedef std::vector<LLModelInstance> model_instance_list;
typedef std::map<LLMatrix4, model_instance_list > scene;
scene mScene;
typedef std::queue<LLPointer<LLModel> > model_queue;
//queue of models that need a physics rep
model_queue mPhysicsQ;
LLModelLoader(std::string filename, S32 lod, LLModelPreview* preview);
virtual void run();
void processElement(daeElement* element);
std::vector<LLImportMaterial> getMaterials(LLModel* model, domInstance_geometry* instance_geo);
LLImportMaterial profileToMaterial(domProfile_COMMON* material);
std::string getElementLabel(daeElement *element);
LLColor4 getDaeColor(daeElement* element);
daeElement* getChildFromElement( daeElement* pElement, std::string const & name );
bool isNodeAJoint( domNode* pNode );
void processJointNode( domNode* pNode, std::map<std::string,LLMatrix4>& jointTransforms );
void extractTranslation( domTranslate* pTranslate, LLMatrix4& transform );
void extractTranslationViaElement( daeElement* pTranslateElement, LLMatrix4& transform );
void setLoadState( U32 state ) { mState = state; }
U32 getLoadState( void ) { return mState; }
//map of avatar joints as named in COLLADA assets to internal joint names
std::map<std::string, std::string> mJointMap;
};
class LLFloaterModelPreview : public LLFloater
{
public:
class DecompRequest : public LLPhysicsDecomp::Request
{
public:
S32 mContinue;
LLPointer<LLModel> mModel;
DecompRequest(const std::string& stage, LLModel* mdl);
virtual S32 statusCallback(const char* status, S32 p1, S32 p2);
virtual void completed();
};
static LLFloaterModelPreview* sInstance;
LLFloaterModelPreview(const LLSD& key);
virtual ~LLFloaterModelPreview();
virtual BOOL postBuild();
BOOL handleMouseDown(S32 x, S32 y, MASK mask);
BOOL handleMouseUp(S32 x, S32 y, MASK mask);
BOOL handleHover(S32 x, S32 y, MASK mask);
BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
static void onMouseCaptureLostModelPreview(LLMouseHandler*);
static void setUploadAmount(S32 amount) { sUploadAmount = amount; }
static void onBrowseLOD(void* data);
static void onUpload(void* data);
static void onClearMaterials(void* data);
static void onModelDecompositionComplete(LLModel* model, std::vector<LLPointer<LLVertexBuffer> >& physics_mesh);
static void refresh(LLUICtrl* ctrl, void* data);
void updateResourceCost();
void loadModel(S32 lod);
void onViewOptionChecked(const LLSD& userdata);
bool isViewOptionChecked(const LLSD& userdata);
bool isViewOptionEnabled(const LLSD& userdata);
void setViewOptionEnabled(const std::string& option, bool enabled);
void enableViewOption(const std::string& option);
void disableViewOption(const std::string& option);
void setViewOption(const std::string& option, bool value);
protected:
friend class LLModelPreview;
friend class LLMeshFilePicker;
friend class LLPhysicsDecomp;
static void onImportScaleCommit(LLUICtrl*, void*);
static void onUploadJointsCommit(LLUICtrl*,void*);
static void onUploadSkinCommit(LLUICtrl*,void*);
static void onPreviewLODCommit(LLUICtrl*,void*);
static void onGenerateNormalsCommit(LLUICtrl*,void*);
static void onAutoFillCommit(LLUICtrl*,void*);
static void onLODParamCommit(LLUICtrl*,void*);
static void onExplodeCommit(LLUICtrl*, void*);
static void onPhysicsParamCommit(LLUICtrl* ctrl, void* userdata);
static void onPhysicsStageExecute(LLUICtrl* ctrl, void* userdata);
static void onPhysicsStageCancel(LLUICtrl* ctrl, void* userdata);
static void onPhysicsBrowse(LLUICtrl* ctrl, void* userdata);
static void onPhysicsUseLOD(LLUICtrl* ctrl, void* userdata);
static void onPhysicsOptimize(LLUICtrl* ctrl, void* userdata);
static void onPhysicsDecomposeBack(LLUICtrl* ctrl, void* userdata);
static void onPhysicsSimplifyBack(LLUICtrl* ctrl, void* userdata);
void draw();
void initDecompControls();
void setStatusMessage(const std::string& msg);
LLModelPreview* mModelPreview;
LLPhysicsDecomp::decomp_params mDecompParams;
S32 mLastMouseX;
S32 mLastMouseY;
LLRect mPreviewRect;
U32 mGLName;
static S32 sUploadAmount;
std::set<LLPointer<DecompRequest> > mCurRequest;
std::string mStatusMessage;
std::map<std::string, bool> mViewOption;
//use "disabled" as false by default
std::map<std::string, bool> mViewOptionDisabled;
//store which lod mode each LOD is using
// 0 - load from file
// 1 - auto generate
// 2 - None
S32 mLODMode[4];
LLMenuButton* mViewOptionMenuButton;
LLToggleableMenu* mViewOptionMenu;
LLMutex* mStatusLock;
};
class LLMeshFilePicker : public LLFilePickerThread
{
public:
LLMeshFilePicker(LLModelPreview* mp, S32 lod);
virtual void notify(const std::string& filename);
private:
LLModelPreview* mMP;
S32 mLOD;
};
class LLModelPreview : public LLViewerDynamicTexture, public LLMutex
{
public:
LLModelPreview(S32 width, S32 height, LLFloater* fmp);
virtual ~LLModelPreview();
void resetPreviewTarget();
void setPreviewTarget(F32 distance);
void setTexture(U32 name) { mTextureName = name; }
void setPhysicsFromLOD(S32 lod);
BOOL render();
void update();
void genBuffers(S32 lod, bool skinned);
void clearBuffers();
void refresh();
void rotate(F32 yaw_radians, F32 pitch_radians);
void zoom(F32 zoom_amt);
void pan(F32 right, F32 up);
virtual BOOL needsRender() { return mNeedsUpdate; }
void setPreviewLOD(S32 lod);
void clearModel(S32 lod);
void loadModel(std::string filename, S32 lod);
void loadModelCallback(S32 lod);
void genLODs(S32 which_lod = -1, U32 decimation = 3);
void generateNormals();
void consolidate();
void clearMaterials();
U32 calcResourceCost();
void rebuildUploadData();
void clearIncompatible(S32 lod);
void updateStatusMessages();
bool containsRiggedAsset( void );
void clearGLODGroup();
static void textureLoadedCallback( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata );
protected:
friend class LLFloaterModelPreview;
friend class LLFloaterModelWizard;
friend class LLFloaterModelPreview::DecompRequest;
friend class LLPhysicsDecomp;
LLFloater* mFMP;
BOOL mNeedsUpdate;
bool mDirty;
bool mGenLOD;
U32 mTextureName;
F32 mCameraDistance;
F32 mCameraYaw;
F32 mCameraPitch;
F32 mCameraZoom;
LLVector3 mCameraOffset;
LLVector3 mPreviewTarget;
LLVector3 mPreviewScale;
S32 mPreviewLOD;
U32 mResourceCost;
std::string mLODFile[LLModel::NUM_LODS];
bool mLoading;
//GLOD object parameters (must rebuild object if these change)
F32 mBuildShareTolerance;
U32 mBuildQueueMode;
U32 mBuildOperator;
U32 mBuildBorderMode;
LLModelLoader* mModelLoader;
LLModelLoader::scene mScene[LLModel::NUM_LODS];
LLModelLoader::scene mBaseScene;
LLModelLoader::model_list mModel[LLModel::NUM_LODS];
LLModelLoader::model_list mBaseModel;
U32 mGroup;
std::map<LLPointer<LLModel>, U32> mObject;
U32 mMaxTriangleLimit;
std::map<LLPointer<LLModel>, std::vector<LLPointer<LLVertexBuffer> > > mPhysicsMesh;
LLMeshUploadThread::instance_list mUploadData;
std::set<LLPointer<LLViewerFetchedTexture> > mTextureSet;
//map of vertex buffers to models (one vertex buffer in vector per face in model
std::map<LLModel*, std::vector<LLPointer<LLVertexBuffer> > > mVertexBuffer[LLModel::NUM_LODS+1];
};
#endif // LL_LLFLOATERMODELPREVIEW_H

View File

@ -1396,6 +1396,7 @@ LLMeshUploadThread::DecompRequest::DecompRequest(LLModel* mdl, LLModel* base_mod
{
mStage = "single_hull";
mModel = mdl;
mDecompID = &mdl->mDecompID;
mBaseModel = base_model;
mThread = thread;
@ -1486,7 +1487,7 @@ void LLMeshUploadThread::run()
{
textures.insert(material_iter->mDiffuseMap);
LLTextureUploadData data(material_iter->mDiffuseMap, material_iter->mDiffuseMapLabel);
LLTextureUploadData data(material_iter->mDiffuseMap.get(), material_iter->mDiffuseMapLabel);
uploadTexture(data);
}
}
@ -2135,6 +2136,24 @@ void LLMeshRepository::shutdown()
LLConvexDecomposition::quitSystem();
}
//called in the main thread.
S32 LLMeshRepository::update()
{
if(mUploadWaitList.empty())
{
return 0 ;
}
S32 size = mUploadWaitList.size() ;
for (S32 i = 0; i < size; ++i)
{
mUploads.push_back(mUploadWaitList[i]);
mUploadWaitList[i]->start() ;
}
mUploadWaitList.clear() ;
return size ;
}
S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_params, S32 detail)
{
@ -2262,6 +2281,9 @@ void LLMeshRepository::notifyLoadedMeshes()
mInventoryQ.pop();
}
}
//call completed callbacks on finished decompositions
mDecompThread->notifyCompleted();
if (!mThread->mWaiting)
{ //curl thread is churning, wait for it to go idle
@ -2654,8 +2676,7 @@ void LLMeshRepository::uploadModel(std::vector<LLModelInstance>& data, LLVector3
bool upload_skin, bool upload_joints)
{
LLMeshUploadThread* thread = new LLMeshUploadThread(data, scale, upload_textures, upload_skin, upload_joints);
mUploads.push_back(thread);
thread->start();
mUploadWaitList.push_back(thread);
}
S32 LLMeshRepository::getMeshSize(const LLUUID& mesh_id, S32 lod)
@ -2742,7 +2763,7 @@ void LLMeshUploadThread::sendCostRequest(LLMeshUploadData& data)
void LLMeshUploadThread::sendCostRequest(LLTextureUploadData& data)
{
if (data.mTexture.notNull() && data.mTexture->getDiscardLevel() >= 0)
if (data.mTexture && data.mTexture->getDiscardLevel() >= 0)
{
LLSD asset_resources = LLSD::emptyMap();
@ -3229,9 +3250,8 @@ void LLPhysicsDecomp::doDecomposition()
mCurRequest->mHullMesh.clear();
mCurRequest->setStatusMessage("FAIL");
mCurRequest->completed();
mCurRequest = NULL;
completeCurrent();
}
else
{
@ -3282,13 +3302,33 @@ void LLPhysicsDecomp::doDecomposition()
LLMutexLock lock(mMutex);
mCurRequest->setStatusMessage("FAIL");
mCurRequest->completed();
mCurRequest = NULL;
completeCurrent();
}
}
}
void LLPhysicsDecomp::completeCurrent()
{
LLMutexLock lock(mMutex);
mCompletedQ.push(mCurRequest);
mCurRequest = NULL;
}
void LLPhysicsDecomp::notifyCompleted()
{
if (!mCompletedQ.empty())
{
LLMutexLock lock(mMutex);
while (!mCompletedQ.empty())
{
Request* req = mCompletedQ.front();
req->completed();
mCompletedQ.pop();
}
}
}
void make_box(LLPhysicsDecomp::Request * request)
{
LLVector3 min,max;
@ -3406,18 +3446,17 @@ void LLPhysicsDecomp::doDecompositionSingleHull()
{
LLMutexLock lock(mMutex);
mCurRequest->completed();
mCurRequest = NULL;
completeCurrent();
}
}
void LLPhysicsDecomp::run()
{
LLConvexDecomposition::getInstance()->initThread();
mInited = true;
LLConvexDecomposition* decomp = LLConvexDecomposition::getInstance();
decomp->initThread();
mInited = true;
static const LLCDStageData* stages = NULL;
static S32 num_stages = 0;
@ -3443,6 +3482,13 @@ void LLPhysicsDecomp::run()
mRequestQ.pop();
}
S32& id = *(mCurRequest->mDecompID);
if (id == -1)
{
decomp->genDecomposition(id);
}
decomp->bindDecomposition(id);
if (mCurRequest->mStage == "single_hull")
{
doDecompositionSingleHull();
@ -3454,7 +3500,7 @@ void LLPhysicsDecomp::run()
}
}
LLConvexDecomposition::getInstance()->quitThread();
decomp->quitThread();
//delete mSignal;
delete mMutex;

View File

@ -65,7 +65,7 @@ public:
class LLTextureUploadData
{
public:
LLPointer<LLViewerFetchedTexture> mTexture;
LLViewerFetchedTexture* mTexture;
LLUUID mUUID;
std::string mRSVP;
std::string mLabel;
@ -157,6 +157,7 @@ public:
{
public:
//input params
S32* mDecompID;
std::string mStage;
std::vector<LLVector3> mPositions;
std::vector<U16> mIndices;
@ -167,8 +168,12 @@ public:
std::vector<LLPointer<LLVertexBuffer> > mHullMesh;
LLModel::convex_hull_decomposition mHull;
//status message callback, called from decomposition thread
virtual S32 statusCallback(const char* status, S32 p1, S32 p2) = 0;
//completed callback, called from the main thread
virtual void completed() = 0;
virtual void setStatusMessage(const std::string& msg);
};
@ -193,6 +198,9 @@ public:
void doDecompositionSingleHull();
virtual void run();
void completeCurrent();
void notifyCompleted();
std::map<std::string, S32> mStageID;
@ -201,6 +209,8 @@ public:
LLPointer<Request> mCurRequest;
std::queue<LLPointer<Request> > mCompletedQ;
};
class LLMeshRepoThread : public LLThread
@ -399,7 +409,7 @@ public:
std::queue<LLTextureUploadData> mTextureQ;
std::queue<LLTextureUploadData> mConfirmedTextureQ;
std::map<LLPointer<LLViewerFetchedTexture>, LLTextureUploadData> mTextureMap;
std::map<LLViewerFetchedTexture*, LLTextureUploadData> mTextureMap;
LLMeshUploadThread(instance_list& data, LLVector3& scale, bool upload_textures,
bool upload_skin, bool upload_joints);
@ -442,6 +452,7 @@ public:
void init();
void shutdown();
S32 update() ;
//mesh management functions
S32 loadMesh(LLVOVolume* volume, const LLVolumeParams& mesh_params, S32 detail = 0);
@ -505,6 +516,7 @@ public:
LLMeshRepoThread* mThread;
std::vector<LLMeshUploadThread*> mUploads;
std::vector<LLMeshUploadThread*> mUploadWaitList;
LLPhysicsDecomp* mDecompThread;

View File

@ -64,7 +64,7 @@
<text bottom_delta="25" left="25" width="100" follows="bottom|left">Upload Details</text>
<panel top_pad="5" border="true" left="15" width="290" height="70" follows="bottom|left"
bevel_style="in" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text left="25" follows="bottom|left" width="140" height="15" name="streaming cost">
Resource Cost: [COST]
</text>
@ -222,30 +222,25 @@
label="Physics"
name="physics_panel">
<!-- PHYSICS STEP ONE-->
<!-- PHYSICS GEOMETRY-->
<panel
follows="top|left"
name="physics step 1"
name="physics geometry"
left="0"
top="0"
width="260"
height="450"
visible="true">
width="300"
height="80"
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="left|top" bottom="40" height="30" left="10" font="SansSerifBig">
Step 1: Geometry
</text>
<radio_group follows="top|left" top_pad="5" width="240" height="70" name="physics_load_radio" value="physics_load_from_file">
<radio_item bottom="50" name="physics_load_from_file" label="Load from file"/>
<radio_item bottom="0" name="physics_use_lod" label="Use Level of Detail"/>
<radio_group follows="top|left" top="10" width="240" height="40" name="physics_load_radio" value="physics_load_from_file">
<radio_item bottom="0" name="physics_load_from_file" label="File:"/>
<radio_item bottom="23" name="physics_use_lod" label="Use Level of Detail:"/>
</radio_group>
<line_editor follows="left|top" bottom_delta="-25" width="140" left="30" value="" name="physics_file" height="20"/>
<button bottom_delta="3" name="physics_browse" label="Browse..." left_pad="5" follows="left|top" width="70" height="25"/>
<combo_box left="30" bottom_delta="40" follows="left|top" height="18"
name="physics_lod_combo" width="90" tool_tip="LOD to use for physics shape">
<combo_box left="180" top="10" follows="left|top" height="18"
name="physics_lod_combo" width="110" tool_tip="LOD to use for physics shape">
<combo_item name="physics_lowest">
Lowest
</combo_item>
@ -260,120 +255,103 @@
</combo_item>
</combo_box>
<line_editor follows="left|top" top_pad="5" width="140" left="60" value="" name="physics_file" height="20"/>
<button left_pad="10" name="physics_browse" label="Browse..." follows="left|top" width="70" height="20"/>
<!--
<text follows="top|left" name="physics_triangles" top_pad="15" height="15" left="10">
Triangles: [TRIANGLES]
</text>
<text follows="top|left" name="physics_hulls" top_pad="5" height="15">
Hulls: [HULLS]
</text>
<text follows="top|left" name="physics_points" top_pad="5" height="15">
Points: [POINTS]
</text>
<text follows="top|left" left="140" width="100" bottom_delta="-40" height="15">
Layer:
</text>
<combo_box name="physics_layer" follows="top|left" width="100" height="20" top_pad="5"/>
-->
<button bottom="440" left="180" width="80" follows="bottom|right" label="Optimize" name="physics_optimize" height="20"/>
</panel>
<check_box name="physics_optimize" follows="left|top" width="130" left="10" top_pad="5" height="20" label="Optimize"/>
<check_box name="physics_use_hull" follows="left|top" width="130" left_pad="5" height="20" label="Use Convex Hull"/>
-->
</panel>
<!-- PHYSICS STEP 2-->
<!-- PHYSICS ANALYSIS-->
<panel
follows="top|left"
name="physics step 2"
name="physics analysis"
top_pad="0"
left="0"
top="0"
width="260"
height="450"
visible="false">
width="300"
height="130"
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="left|top" bottom="40" height="30" left="10" font="SansSerifBig">
Step 2: Decompose
Step 1: Analysis
</text>
<text top_pad="100" follows="top|left" height="15">
Decompose Method:
<text top_pad="5" width="50" follows="top|left" height="15">
Method:
</text>
<combo_box name="Method" follows="top|left" top_pad="5" height="20" width="100"/>
<text top_pad="10" follows="top|left" height="15">
<combo_box name="Method" follows="top|left" left_pad="5" bottom_delta="2" height="20" width="80"/>
<text left="160" bottom_delta="-2" width="50" follows="top|left" height="15">
Quality:
</text>
<combo_box name="Decompose Quality" follows="top|left" top_pad="5" height="20" width="100"/>
<combo_box name="Decompose Quality" bottom_delta="2" follows="top|left" left_pad="5" height="20" width="80"/>
<slider name="Smooth" left="10" width="280" follows="top|left" top_pad="10" height="20" label="Smooth:"/>
<check_box name="Simplify Coplanar" follows="top|left" top_pad="10" height="15" label="Simplify Coplaner"/>
<check_box name="Close Holes (Slow)" follows="top|left" top_pad="10" height="15" label="Close Holes (slow)"/>
<slider name="Cosine%" width="240" follows="top|left" top_pad="10" height="20" label="Cosine %"/>
<text follows="top|left" top_pad="20" height="30" width="260">
"Note: Only models that have been Decomposed"
"can be made Physical or used as Vehicles."
</text>
<button bottom="440" left="90" width="80" follows="bottom|right" label="&lt;&lt; Back" name="decompose_back" height="20"/>
<button left_pad="5" width="90" follows="bottom|right" label="Decompose" name="Decompose" height="20"/>
<button left="200" bottom_delta="0" width="90" follows="top|left" label="Analyze" name="Decompose" height="20"/>
</panel>
<!-- PHYSICS STEP 3 -->
<panel
<!-- PHYSICS SIMPLIFICATION -->
<panel
follows="top|left"
name="physics step 3"
name="physics simplification"
left="0"
top="0"
width="260"
height="450"
visible="false">
top_pad="0"
width="300"
height="150"
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="left|top" bottom="40" height="30" left="10" font="SansSerifBig">
Step 3: Simplify
Step 2: Simplification
</text>
<text left="10" top_pad="100" height="15" width="240" follows="top|left">
Simplify Method:
<text left="10" top_pad="5" height="15" width="140" follows="top|left">
Method:
</text>
<combo_box top_pad="5" height="20" width="100" follows="top|left" name="Simplify Method"/>
<combo_box left_pad="5" height="20" width="120" follows="top|left" name="Simplify Method"/>
<slider name="Combine Quality" label="Combine Quality:" label_width="100" width="260" follows="top|left" top_pad="10" height="20"/>
<slider name="Detail Scale" label="Detail Scale:" label_width="100" width="260" follows="top|left" top_pad="10" height="20"/>
<slider name="Retain%" label="Retain %:" label_width="100" width="260" follows="top|left" top_pad="10" height="20"/>
<button bottom="440" left="90" width="80" follows="bottom|right" label="&lt;&lt; Back" name="simplify_back" height="20"/>
<button left_pad="5" width="90" follows="bottom|right" label="Simplify" name="Simplify" height="20"/>
<slider left="10" name="Combine Quality" label="Passes:" label_width="120" width="270" follows="top|left" top_pad="10" height="20"/>
<slider name="Detail Scale" label="Detail Scale:" label_width="120" width="270" follows="top|left" top_pad="10" height="20"/>
<slider name="Retain%" label="Retain:" label_width="120" width="270" follows="top|left" bottom_delta="0" left_delta="0" visible="false" height="20"/>
<button left="190" width="90" follows="top|left" label="Simplify" name="Simplify" height="20"/>
</panel>
<!-- INFO PANEL -->
<panel
left="0"
top="35"
width="260"
top_pad="0"
width="300"
height="100"
follows="left|top"
name="physics info"
visible="false">
visible="true"
border="true"
bevel_style="none" bg_alpha_color="0 0 0 0" bg_opaque_color="0 0 0 0.3">
<text follows="top|left" name="physics_triangles" top_pad="15" height="15" left="10">
Triangles: [TRIANGLES]
</text>
<text follows="top|left" name="physics_hulls" top_pad="5" height="15">
Hulls: [HULLS]
<slider name="physics_explode" follows="top|left" top="10" left="10" label="Preview Spread:" min_val="0.0" max_val="3.0" height="20" width="280"/>
<text follows="top|left" name="physics_triangles" top_pad="10" height="15" left="10">
Triangles: [TRIANGLES]
</text>
<text follows="top|left" name="physics_points" top_pad="5" height="15">
Points: [POINTS]
Vertices: [POINTS]
</text>
<text follows="top|left" name="physics_hulls" top_pad="5" height="15">
Hulls: [HULLS]
</text>
<text follows="top|left" left="140" width="100" bottom_delta="-40" height="15">
Layer:
</text>
<combo_box name="physics_layer" follows="top|left" width="100" height="20" top_pad="5"/>
<slider name="physics_explode" follows="top|left" top_pad="25" left="10" label="Explode" min_val="0.0" max_val="3.0" height="20" width="240"/>
</panel>
</panel>

View File

@ -1058,23 +1058,23 @@ anguage Infrstructure (CLI) international standard</string>
<key>windows</key>
<map>
<key>md5sum</key>
<string>50fb24b9ad5baf16cbd7b7bf8a607010</string>
<string>5ae8bab01189c5dbbc6f383c751e031a</string>
<key>url</key>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-windows-20101015a.tar.bz2</uri>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-windows-20101222.tar.bz2</uri>
</map>
<key>linux</key>
<map>
<key>md5sum</key>
<string>6711cd0dbade656b468f895843fc3709</string>
<string>f63424076d4fadd133950af0cf9c3564</string>
<key>url</key>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.2-linux-20100928.tar.bz2</uri>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-linux-20101222.tar.bz2</uri>
</map>
<key>darwin</key>
<map>
<key>md5sum</key>
<string>a6969a966e83ac3f0dc652df3e499797</string>
<string>47ef880db4aea1a9561194c54fc28433</string>
<key>url</key>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.1-darwin-20100914.tar.bz2</uri>
<uri>scp:install-packages.lindenlab.com:/local/www/install-packages/doc/llconvexdecomposition-0.3-darwin-20101222.tar.bz2</uri>
</map>
</map>
</map>