Flipped the MESH_ENABLED switch. Added missing components and updated stuff to be closer to mesh-development head.

This commit is contained in:
Shyotl
2011-07-30 20:30:07 -05:00
parent c081efa460
commit b258b71e07
51 changed files with 3264 additions and 1451 deletions

View File

@@ -33,9 +33,37 @@
#include "llviewertexture.h"
#include "llvolume.h"
#if MESH_IMPORT
#define LLCONVEXDECOMPINTER_STATIC 1
#include "llconvexdecomposition.h"
#endif //MESH_IMPORT
#if !MESH_IMPORT
//Placeholder structs from LLConvexDecomposition.h:
struct LLCDMeshData
{
enum IndexType
{
INT_16,
INT_32
};
const float* mVertexBase;
int mVertexStrideBytes;
int mNumVertices;
const void* mIndexBase;
IndexType mIndexType;
int mIndexStrideBytes;
int mNumTriangles;
};
struct LLCDHull
{
const float* mVertexBase;
int mVertexStrideBytes;
int mNumVertices;
};
#endif //!MESH_IMPORT
class LLVOVolume;
class LLMeshResponder;
@@ -91,6 +119,7 @@ public:
LLPointer<LLViewerFetchedTexture> mDiffuseMap;
std::string mDiffuseMapFilename;
std::string mDiffuseMapLabel;
std::string mBinding;
LLColor4 mDiffuseColor;
bool mFullbright;
@@ -119,9 +148,9 @@ public:
S32 mLocalMeshID;
LLMatrix4 mTransform;
std::vector<LLImportMaterial> mMaterial;
std::map<std::string, LLImportMaterial> mMaterial;
LLModelInstance(LLModel* model, const std::string& label, LLMatrix4& transform, std::vector<LLImportMaterial>& materials)
LLModelInstance(LLModel* model, const std::string& label, LLMatrix4& transform, std::map<std::string, LLImportMaterial>& materials)
: mModel(model), mLabel(label), mTransform(transform), mMaterial(materials)
{
mLocalMeshID = -1;
@@ -160,6 +189,17 @@ public:
virtual void completed() = 0;
virtual void setStatusMessage(const std::string& msg);
bool isValid() const {return mPositions.size() > 2 && mIndices.size() > 2 ;}
protected:
//internal use
LLVector3 mBBox[2] ;
F32 mTriangleAreaThreshold ;
void assignData(LLModel* mdl) ;
void updateTriangleAreaThreshold() ;
bool isValidTriangle(U16 idx1, U16 idx2, U16 idx3) ;
};
LLCondition* mSignal;
@@ -178,7 +218,7 @@ public:
static S32 llcdCallback(const char*, S32, S32);
void cancel();
void setMeshData(LLCDMeshData& mesh);
void setMeshData(LLCDMeshData& mesh, bool vertex_based);
void doDecomposition();
void doDecompositionSingleHull();
@@ -218,7 +258,6 @@ public:
mesh_header_map mMeshHeader;
std::map<LLUUID, U32> mMeshHeaderSize;
std::map<LLUUID, U32> mMeshResourceCost;
class HeaderRequest
{
@@ -310,7 +349,7 @@ public:
virtual void run();
void loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
void loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod, bool do_lock = true);
bool fetchMeshHeader(const LLVolumeParams& mesh_params);
bool fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
bool headerReceived(const LLVolumeParams& mesh_params, U8* data, S32 data_size);
@@ -322,8 +361,7 @@ public:
void notifyLoadedMeshes();
S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
U32 getResourceCost(const LLUUID& mesh_params);
void loadMeshSkinInfo(const LLUUID& mesh_id);
void loadMeshDecomposition(const LLUUID& mesh_id);
void loadMeshPhysicsShape(const LLUUID& mesh_id);
@@ -343,8 +381,12 @@ public:
};
#if MESH_IMPORT
class LLMeshUploadThread : public LLThread
{
private:
S32 mMeshUploadTimeOut ; //maximum time in seconds to execute an uploading request.
public:
class DecompRequest : public LLPhysicsDecomp::Request
{
@@ -374,9 +416,7 @@ public:
LLMutex* mMutex;
LLCurlRequest* mCurlRequest;
S32 mPendingConfirmations;
S32 mPendingUploads;
S32 mPendingCost;
LLVector3 mOrigin;
bool mFinished;
bool mUploadTextures;
@@ -385,46 +425,24 @@ public:
BOOL mDiscarded ;
LLHost mHost;
std::string mUploadObjectAssetCapability;
std::string mNewInventoryCapability;
std::string mWholeModelFeeCapability;
std::string mWholeModelUploadURL;
std::queue<LLMeshUploadData> mUploadQ;
std::queue<LLMeshUploadData> mConfirmedQ;
std::queue<LLModelInstance> mInstanceQ;
std::queue<LLTextureUploadData> mTextureQ;
std::queue<LLTextureUploadData> mConfirmedTextureQ;
std::map<LLViewerFetchedTexture*, LLTextureUploadData> mTextureMap;
LLMeshUploadThread(instance_list& data, LLVector3& scale, bool upload_textures,
bool upload_skin, bool upload_joints);
bool upload_skin, bool upload_joints, std::string upload_url, bool do_upload = true,
LLHandle<LLWholeModelFeeObserver> fee_observer= (LLHandle<LLWholeModelFeeObserver>()), LLHandle<LLWholeModelUploadObserver> upload_observer = (LLHandle<LLWholeModelUploadObserver>()));
~LLMeshUploadThread();
void uploadTexture(LLTextureUploadData& data);
void doUploadTexture(LLTextureUploadData& data);
void sendCostRequest(LLTextureUploadData& data);
void priceResult(LLTextureUploadData& data, const LLSD& content);
void onTextureUploaded(LLTextureUploadData& data);
void uploadModel(LLMeshUploadData& data);
void sendCostRequest(LLMeshUploadData& data);
void doUploadModel(LLMeshUploadData& data);
void onModelUploaded(LLMeshUploadData& data);
void createObjects(LLMeshUploadData& data);
LLSD createObject(LLModelInstance& instance);
void priceResult(LLMeshUploadData& data, const LLSD& content);
bool finished() { return mFinished; }
virtual void run();
void preStart();
void discard() ;
BOOL isDiscarded();
void generateHulls();
void doWholeModelUpload();
void doIterativeUpload();
void requestWholeModelFee();
void wholeModelToLLSD(LLSD& dest, bool include_textures);
@@ -432,7 +450,17 @@ public:
LLVector3& result_pos,
LLQuaternion& result_rot,
LLVector3& result_scale);
void setFeeObserverHandle(LLHandle<LLWholeModelFeeObserver> observer_handle) { mFeeObserverHandle = observer_handle; }
void setUploadObserverHandle(LLHandle<LLWholeModelUploadObserver> observer_handle) { mUploadObserverHandle = observer_handle; }
private:
LLHandle<LLWholeModelFeeObserver> mFeeObserverHandle;
LLHandle<LLWholeModelUploadObserver> mUploadObserverHandle;
bool mDoUpload; // if FALSE only model data will be requested, otherwise the model will be uploaded
};
#endif //MESH_IMPORT
class LLMeshRepository
{
@@ -465,20 +493,25 @@ public:
S32 getActualMeshLOD(const LLVolumeParams& mesh_params, S32 lod);
static S32 getActualMeshLOD(LLSD& header, S32 lod);
U32 calcResourceCost(LLSD& header);
U32 getResourceCost(const LLUUID& mesh_params);
const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id);
const LLMeshSkinInfo* getSkinInfo(const LLUUID& mesh_id, LLVOVolume* requesting_obj);
LLModel::Decomposition* getDecomposition(const LLUUID& mesh_id);
void fetchPhysicsShape(const LLUUID& mesh_id);
bool hasPhysicsShape(const LLUUID& mesh_id);
void buildHull(const LLVolumeParams& params, S32 detail);
void buildPhysicsMesh(LLModel::Decomposition& decomp);
bool meshUploadEnabled();
bool meshRezEnabled();
LLSD& getMeshHeader(const LLUUID& mesh_id);
#if MESH_IMPORT
void uploadModel(std::vector<LLModelInstance>& data, LLVector3& scale, bool upload_textures,
bool upload_skin, bool upload_joints);
bool upload_skin, bool upload_joints, std::string upload_url, bool do_upload = true,
LLHandle<LLWholeModelFeeObserver> fee_observer= (LLHandle<LLWholeModelFeeObserver>()), LLHandle<LLWholeModelUploadObserver> upload_observer = (LLHandle<LLWholeModelUploadObserver>()));
#endif //MESH_IMPORT
S32 getMeshSize(const LLUUID& mesh_id, S32 lod);
@@ -496,7 +529,8 @@ public:
std::vector<LLMeshRepoThread::LODRequest> mPendingRequests;
//list of mesh ids awaiting skin info
std::set<LLUUID> mLoadingSkins;
typedef std::map<LLUUID, std::set<LLUUID> > skin_load_map;
skin_load_map mLoadingSkins;
//list of mesh ids that need to send skin info fetch requests
std::queue<LLUUID> mPendingSkinRequests;
@@ -515,11 +549,15 @@ public:
U32 mMeshThreadCount;
#if MESH_IMPORT
void cacheOutgoingMesh(LLMeshUploadData& data, LLSD& header);
#endif //MESH_IMPORT
LLMeshRepoThread* mThread;
#if MESH_IMPORT
std::vector<LLMeshUploadThread*> mUploads;
std::vector<LLMeshUploadThread*> mUploadWaitList;
#endif //MESH_IMPORT
LLPhysicsDecomp* mDecompThread;