diff options
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-x[-rw-r--r--] | indra/newview/llfloatermodelpreview.cpp | 340 |
1 files changed, 198 insertions, 142 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 62b8d03281..737fdd4919 100644..100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -184,6 +184,13 @@ std::string lod_label_name[NUM_LOD+1] = "I went off the end of the lod_label_name array. Me so smart." }; +std::string colladaVersion[VERSIONTYPE_COUNT+1] = +{ + "1.4.0", + "1.4.1", + "Unsupported" +}; + #define LL_DEGENERACY_TOLERANCE 1e-7f @@ -768,6 +775,7 @@ void LLFloaterModelPreview::draw() if ( mModelPreview->getLoadState() == LLModelLoader::ERROR_PARSING ) { childSetTextArg("status", "[STATUS]", getString("status_parse_error")); + toggleCalculateButton(false); } else { @@ -776,7 +784,7 @@ void LLFloaterModelPreview::draw() } childSetEnabled("ok_btn", mHasUploadPerm && !mUploadModelUrl.empty()); - + childSetTextArg("prim_cost", "[PRIM_COST]", llformat("%d", mModelPreview->mResourceCost)); childSetTextArg("description_label", "[TEXTURES]", llformat("%d", mModelPreview->mTextureSet.size())); @@ -1394,7 +1402,22 @@ bool LLModelLoader::doLoadModel() setLoadState( ERROR_PARSING ); return false; } - + //Dom version + daeString domVersion = dae.getDomVersion(); + std::string sldom(domVersion); + llinfos<<"Collada Importer Version: "<<sldom<<llendl; + //Dae version + domVersionType docVersion = dom->getVersion(); + //0=1.4 + //1=1.4.1 + //2=Currently unsupported, however may work + if (docVersion > 1 ) + { + docVersion = VERSIONTYPE_COUNT; + } + llinfos<<"Dae version "<<colladaVersion[docVersion]<<llendl; + + daeDatabase* db = dae.getDatabase(); daeInt count = db->getElementCount(NULL, COLLADA_TYPE_MESH); @@ -1616,7 +1639,7 @@ bool LLModelLoader::doLoadModel() { //Build a joint for the resolver to work with char str[64]={0}; - sprintf(str,"./%s",(*jointIt).second.c_str() ); + sprintf(str,"./%s",(*jointIt).first.c_str() ); //llwarns<<"Joint "<< str <<llendl; //Setup the resolver @@ -1627,15 +1650,22 @@ bool LLModelLoader::doLoadModel() if ( pJoint ) { //Pull out the translate id and store it in the jointTranslations map - daeSIDResolver jointResolver( pJoint, "./translate" ); - domTranslate* pTranslate = daeSafeCast<domTranslate>( jointResolver.getElement() ); + daeSIDResolver jointResolverA( pJoint, "./translate" ); + domTranslate* pTranslateA = daeSafeCast<domTranslate>( jointResolverA.getElement() ); + daeSIDResolver jointResolverB( pJoint, "./location" ); + domTranslate* pTranslateB = daeSafeCast<domTranslate>( jointResolverB.getElement() ); LLMatrix4 workingTransform; //Translation via SID - if ( pTranslate ) + if ( pTranslateA ) + { + extractTranslation( pTranslateA, workingTransform ); + } + else + if ( pTranslateB ) { - extractTranslation( pTranslate, workingTransform ); + extractTranslation( pTranslateB, workingTransform ); } else { @@ -1753,7 +1783,7 @@ bool LLModelLoader::doLoadModel() } } - //Now that we've parsed the jointa werray, let's determine if we have a full rig + //Now that we've parsed the joint array, let's determine if we have a full rig //(which means we have all the joint sthat are required for an avatar versus //a skinned asset attached to a node in a file that contains an entire skeleton, //but does not use the skeleton). @@ -2512,13 +2542,20 @@ void LLModelLoader::processJointNode( domNode* pNode, JointTransformMap& jointTr LLMatrix4 workingTransform; //Pull out the translate id and store it in the jointTranslations map - daeSIDResolver jointResolver( pNode, "./translate" ); - domTranslate* pTranslate = daeSafeCast<domTranslate>( jointResolver.getElement() ); + daeSIDResolver jointResolverA( pNode, "./translate" ); + domTranslate* pTranslateA = daeSafeCast<domTranslate>( jointResolverA.getElement() ); + daeSIDResolver jointResolverB( pNode, "./location" ); + domTranslate* pTranslateB = daeSafeCast<domTranslate>( jointResolverB.getElement() ); //Translation via SID was successful - if ( pTranslate ) + if ( pTranslateA ) + { + extractTranslation( pTranslateA, workingTransform ); + } + else + if ( pTranslateB ) { - extractTranslation( pTranslate, workingTransform ); + extractTranslation( pTranslateB, workingTransform ); } else { @@ -3106,6 +3143,7 @@ U32 LLModelPreview::calcResourceCost() void LLFloaterModelPreview::setDetails(F32 x, F32 y, F32 z, F32 streaming_cost, F32 physics_cost) { + assert_main_thread(); childSetTextArg("import_dimensions", "[X]", llformat("%.3f", x)); childSetTextArg("import_dimensions", "[Y]", llformat("%.3f", y)); childSetTextArg("import_dimensions", "[Z]", llformat("%.3f", z)); @@ -3123,6 +3161,7 @@ void LLModelPreview::rebuildUploadData() std::string requested_name = mFMP->getChild<LLUICtrl>("description_form")->getValue().asString(); + std::string metric = mFMP->getChild<LLUICtrl>("model_category_combo")->getValue().asString(); LLSpinCtrl* scale_spinner = mFMP->getChild<LLSpinCtrl>("import_scale"); @@ -3184,6 +3223,7 @@ void LLModelPreview::rebuildUploadData() if (base_model) { base_model->mRequestedLabel = requested_name; + base_model->mMetric = metric; } S32 idx = 0; @@ -4891,6 +4931,8 @@ BOOL LLModelPreview::render() target_pos); // point of interest + z_near = llclamp(z_far * 0.001f, 0.001f, 0.1f); + LLViewerCamera::getInstance()->setPerspective(FALSE, mOrigin.mX, mOrigin.mY, width, height, FALSE, z_near, z_far); stop_glerror(); @@ -5010,184 +5052,197 @@ BOOL LLModelPreview::render() if (physics) { glClear(GL_DEPTH_BUFFER_BIT); - LLGLEnable blend(GL_BLEND); - gGL.blendFunc(LLRender::BF_ONE, LLRender::BF_ZERO); - - for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) + + for (U32 i = 0; i < 2; i++) { - LLModelInstance& instance = *iter; + if (i == 0) + { //depth only pass + gGL.setColorMask(false, false); + } + else + { + gGL.setColorMask(true, true); + } - LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; + //enable alpha blending on second pass but not first pass + LLGLState blend(GL_BLEND, i); + + gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); - if (!model) + for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) { - continue; - } + LLModelInstance& instance = *iter; - gGL.pushMatrix(); - LLMatrix4 mat = instance.mTransform; + LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; - glMultMatrixf((GLfloat*) mat.mMatrix); + if (!model) + { + continue; + } + gGL.pushMatrix(); + LLMatrix4 mat = instance.mTransform; - bool render_mesh = true; + glMultMatrixf((GLfloat*) mat.mMatrix); - LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; - if (decomp) - { - LLMutexLock(decomp->mMutex); - LLModel::Decomposition& physics = model->mPhysics; + bool render_mesh = true; - if (!physics.mHull.empty()) + LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; + if (decomp) { - render_mesh = false; + LLMutexLock(decomp->mMutex); - if (physics.mMesh.empty()) - { //build vertex buffer for physics mesh - gMeshRepo.buildPhysicsMesh(physics); - } + LLModel::Decomposition& physics = model->mPhysics; + + if (!physics.mHull.empty()) + { + render_mesh = false; + + if (physics.mMesh.empty()) + { //build vertex buffer for physics mesh + gMeshRepo.buildPhysicsMesh(physics); + } - if (!physics.mMesh.empty()) - { //render hull instead of mesh - for (U32 i = 0; i < physics.mMesh.size(); ++i) - { - if (explode > 0.f) + if (!physics.mMesh.empty()) + { //render hull instead of mesh + for (U32 i = 0; i < physics.mMesh.size(); ++i) { - gGL.pushMatrix(); + if (explode > 0.f) + { + gGL.pushMatrix(); - LLVector3 offset = model->mHullCenter[i]-model->mCenterOfHullCenters; - offset *= explode; + LLVector3 offset = model->mHullCenter[i]-model->mCenterOfHullCenters; + offset *= explode; - gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); - } + gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); + } - static std::vector<LLColor4U> hull_colors; + static std::vector<LLColor4U> hull_colors; - if (i+1 >= hull_colors.size()) - { - hull_colors.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127, 255)); - } + if (i+1 >= hull_colors.size()) + { + hull_colors.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127, 128)); + } glColor4ubv(hull_colors[i].mV); - LLVertexBuffer::drawArrays(LLRender::TRIANGLES, physics.mMesh[i].mPositions, physics.mMesh[i].mNormals); + LLVertexBuffer::drawArrays(LLRender::TRIANGLES, physics.mMesh[i].mPositions, physics.mMesh[i].mNormals); - if (explode > 0.f) - { - gGL.popMatrix(); + if (explode > 0.f) + { + gGL.popMatrix(); + } } } } } - } - if (render_mesh) - { - if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) - { - genBuffers(LLModel::LOD_PHYSICS, false); - } - for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) + if (render_mesh) { - LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; - - buffer->setBuffer(type_mask & buffer->getTypeMask()); + if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) + { + genBuffers(LLModel::LOD_PHYSICS, false); + } + for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) + { + LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - glColor4f(0.4f, 0.4f, 0.0f, 0.4f); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + glColor4f(0.4f, 0.4f, 0.0f, 0.4f); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); + buffer->setBuffer(type_mask & buffer->getTypeMask()); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); - glColor3f(1.f, 1.f, 0.f); + glColor3f(1.f, 1.f, 0.f); - glLineWidth(2.f); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); + glLineWidth(2.f); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glLineWidth(1.f); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glLineWidth(1.f); + } } - } - - gGL.popMatrix(); - } - glLineWidth(3.f); - glPointSize(8.f); - gPipeline.enableLightsFullbright(LLColor4::white); - //show degenerate triangles - LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - LLGLDisable cull(GL_CULL_FACE); - glColor4f(1.f,0.f,0.f,1.f); - const LLVector4a scale(0.5f); - - for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) - { - LLModelInstance& instance = *iter; + gGL.popMatrix(); + } - LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; + glLineWidth(3.f); + glPointSize(8.f); + gPipeline.enableLightsFullbright(LLColor4::white); + //show degenerate triangles + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + LLGLDisable cull(GL_CULL_FACE); + glColor4f(1.f,0.f,0.f,1.f); + const LLVector4a scale(0.5f); - if (!model) + for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) { - continue; - } + LLModelInstance& instance = *iter; - gGL.pushMatrix(); - LLMatrix4 mat = instance.mTransform; + LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; - glMultMatrixf((GLfloat*) mat.mMatrix); + if (!model) + { + continue; + } + gGL.pushMatrix(); + LLMatrix4 mat = instance.mTransform; - LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; - if (decomp) - { - LLMutexLock(decomp->mMutex); + glMultMatrixf((GLfloat*) mat.mMatrix); - LLModel::Decomposition& physics = model->mPhysics; - if (physics.mHull.empty()) + LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; + if (decomp) { - if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) + LLMutexLock(decomp->mMutex); + + LLModel::Decomposition& physics = model->mPhysics; + + if (physics.mHull.empty()) { - genBuffers(LLModel::LOD_PHYSICS, false); - } + if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) + { + genBuffers(LLModel::LOD_PHYSICS, false); + } - for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) - { - LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; + for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) + { + LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; - buffer->setBuffer(type_mask & buffer->getTypeMask()); + buffer->setBuffer(type_mask & buffer->getTypeMask()); - LLStrider<LLVector3> pos_strider; - buffer->getVertexStrider(pos_strider, 0); - LLVector4a* pos = (LLVector4a*) pos_strider.get(); + LLStrider<LLVector3> pos_strider; + buffer->getVertexStrider(pos_strider, 0); + LLVector4a* pos = (LLVector4a*) pos_strider.get(); - LLStrider<U16> idx; - buffer->getIndexStrider(idx, 0); - - for (U32 i = 0; i < buffer->getNumIndices(); i += 3) - { - LLVector4a v1; v1.setMul(pos[*idx++], scale); - LLVector4a v2; v2.setMul(pos[*idx++], scale); - LLVector4a v3; v3.setMul(pos[*idx++], scale); + LLStrider<U16> idx; + buffer->getIndexStrider(idx, 0); - if (ll_is_degenerate(v1,v2,v3)) + for (U32 i = 0; i < buffer->getNumIndices(); i += 3) { - buffer->draw(LLRender::LINE_LOOP, 3, i); - buffer->draw(LLRender::POINTS, 3, i); + LLVector4a v1; v1.setMul(pos[*idx++], scale); + LLVector4a v2; v2.setMul(pos[*idx++], scale); + LLVector4a v3; v3.setMul(pos[*idx++], scale); + + if (ll_is_degenerate(v1,v2,v3)) + { + buffer->draw(LLRender::LINE_LOOP, 3, i); + buffer->draw(LLRender::POINTS, 3, i); + } } } } } - } - gGL.popMatrix(); + gGL.popMatrix(); + } + glLineWidth(1.f); + glPointSize(1.f); + gPipeline.enableLightsPreview(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); } - glLineWidth(1.f); - glPointSize(1.f); - gPipeline.enableLightsPreview(); - gGL.setSceneBlendType(LLRender::BT_ALPHA); } } else @@ -5509,10 +5564,10 @@ void LLFloaterModelPreview::toggleCalculateButton(bool visible) if (visible) { std::string tbd = getString("tbd"); - childSetTextArg("weights", "[EQ]", tbd); - childSetTextArg("weights", "[ST]", tbd); - childSetTextArg("weights", "[SIM]", tbd); - childSetTextArg("weights", "[PH]", tbd); + childSetTextArg("weights_right", "[EQ]", tbd); + childSetTextArg("weights_left", "[ST]", tbd); + childSetTextArg("weights_right", "[SIM]", tbd); + childSetTextArg("weights_left", "[PH]", tbd); childSetTextArg("upload_fee", "[FEE]", tbd); childSetTextArg("price_breakdown", "[STREAMING]", tbd); childSetTextArg("price_breakdown", "[PHYSICS]", tbd); @@ -5535,17 +5590,16 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() const LLSD& result = mModelPhysicsFee; mUploadModelUrl = result["url"].asString(); - childSetTextArg("weights", "[EQ]", llformat("%0.3f", result["resource_cost"].asReal())); - childSetTextArg("weights", "[ST]", llformat("%0.3f", result["model_streaming_cost"].asReal())); - childSetTextArg("weights", "[SIM]", llformat("%0.3f", result["simulation_cost"].asReal())); - childSetTextArg("weights", "[PH]", llformat("%0.3f", result["physics_cost"].asReal())); + childSetTextArg("weights_right", "[EQ]", llformat("%0.3f", result["resource_cost"].asReal())); + childSetTextArg("weights_left", "[ST]", llformat("%0.3f", result["model_streaming_cost"].asReal())); + childSetTextArg("weights_right", "[SIM]", llformat("%0.3f", result["simulation_cost"].asReal())); + childSetTextArg("weights_left", "[PH]", llformat("%0.3f", result["physics_cost"].asReal())); childSetTextArg("upload_fee", "[FEE]", llformat("%d", result["upload_price"].asInteger())); childSetTextArg("price_breakdown", "[STREAMING]", llformat("%d", result["upload_price_breakdown"]["mesh_streaming"].asInteger())); childSetTextArg("price_breakdown", "[PHYSICS]", llformat("%d", result["upload_price_breakdown"]["mesh_physics"].asInteger())); childSetTextArg("price_breakdown", "[INSTANCES]", llformat("%d", result["upload_price_breakdown"]["mesh_instance"].asInteger())); childSetTextArg("price_breakdown", "[TEXTURES]", llformat("%d", result["upload_price_breakdown"]["texture"].asInteger())); childSetTextArg("price_breakdown", "[MODEL]", llformat("%d", result["upload_price_breakdown"]["model"].asInteger())); - childSetVisible("weights", true); childSetVisible("upload_fee", true); childSetVisible("price_breakdown", true); mUploadBtn->setEnabled(mHasUploadPerm && !mUploadModelUrl.empty()); @@ -5553,19 +5607,21 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() void LLFloaterModelPreview::setModelPhysicsFeeErrorStatus(U32 status, const std::string& reason) { - toggleCalculateButton(true); llwarns << "LLFloaterModelPreview::setModelPhysicsFeeErrorStatus(" << status << " : " << reason << ")" << llendl; + doOnIdleOneTime(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, true)); } /*virtual*/ void LLFloaterModelPreview::onModelUploadSuccess() { + assert_main_thread(); closeFloater(false); } /*virtual*/ void LLFloaterModelPreview::onModelUploadFailure() { + assert_main_thread(); toggleCalculateButton(true); } |