diff options
Diffstat (limited to 'indra/newview/lldrawable.cpp')
-rw-r--r-- | indra/newview/lldrawable.cpp | 203 |
1 files changed, 97 insertions, 106 deletions
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 12a7a22e24..70ae4ee13f 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -98,7 +98,7 @@ LLDrawable::LLDrawable(LLViewerObject *vobj, bool new_entry) void LLDrawable::init(bool new_entry) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; // mXform mParent = NULL; @@ -232,7 +232,7 @@ const LLMatrix4& LLDrawable::getRenderMatrix() const return isRoot() ? getWorldMatrix() : getParent()->getWorldMatrix(); } -BOOL LLDrawable::isLight() const +bool LLDrawable::isLight() const { LLViewerObject* objectp = mVObjp; if ( objectp && (objectp->getPCode() == LL_PCODE_VOLUME) && !isDead()) @@ -241,7 +241,7 @@ BOOL LLDrawable::isLight() const } else { - return FALSE; + return false; } } @@ -305,7 +305,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep) LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; { @@ -333,13 +333,13 @@ LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; face = new LLFace(this, mVObjp); - face->setTEOffset(mFaces.size()); + face->setTEOffset(static_cast<S32>(mFaces.size())); face->setTexture(texturep); face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); @@ -356,12 +356,12 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; face = new LLFace(this, mVObjp); - face->setTEOffset(mFaces.size()); + face->setTEOffset(static_cast<S32>(mFaces.size())); face->setTexture(texturep); face->setNormalMap(normalp); face->setPoolType(gPipeline.getPoolTypeFromTE(te, texturep)); @@ -379,12 +379,12 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; face = new LLFace(this, mVObjp); - face->setTEOffset(mFaces.size()); + face->setTEOffset(static_cast<S32>(mFaces.size())); face->setTexture(texturep); face->setNormalMap(normalp); face->setSpecularMap(specularp); @@ -403,7 +403,7 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (newFaces == (S32)mFaces.size()) { @@ -417,7 +417,7 @@ void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerText else // (newFaces > mFaces.size()) { mFaces.reserve(newFaces); - for (int i = mFaces.size(); i<newFaces; i++) + for (auto i = mFaces.size(); i<newFaces; i++) { addFace(poolp, texturep); } @@ -428,7 +428,7 @@ void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerText void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (newFaces <= (S32)mFaces.size() && newFaces >= (S32)mFaces.size()/2) { @@ -442,7 +442,7 @@ void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewer else // (newFaces > mFaces.size()) { mFaces.reserve(newFaces); - for (int i = mFaces.size(); i<newFaces; i++) + for (auto i = mFaces.size(); i<newFaces; i++) { addFace(poolp, texturep); } @@ -453,12 +453,12 @@ void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewer void LLDrawable::mergeFaces(LLDrawable* src) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; - U32 face_count = mFaces.size() + src->mFaces.size(); + auto face_count = mFaces.size() + src->mFaces.size(); mFaces.reserve(face_count); - for (U32 i = 0; i < src->mFaces.size(); i++) + for (size_t i = 0; i < src->mFaces.size(); i++) { LLFace* facep = src->mFaces[i]; facep->setDrawable(this); @@ -488,7 +488,7 @@ void LLDrawable::updateMaterial() void LLDrawable::makeActive() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; #if !LL_RELEASE_FOR_DOWNLOAD if (mVObjp.notNull()) @@ -550,9 +550,9 @@ void LLDrawable::makeActive() } -void LLDrawable::makeStatic(BOOL warning_enabled) +void LLDrawable::makeStatic(bool warning_enabled) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (isState(ACTIVE) && !isState(ACTIVE_CHILD) && @@ -598,11 +598,11 @@ void LLDrawable::makeStatic(BOOL warning_enabled) } // Returns "distance" between target destination and resulting xfrom -F32 LLDrawable::updateXform(BOOL undamped) +F32 LLDrawable::updateXform(bool undamped) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; - BOOL damped = !undamped; + bool damped = !undamped; // Position const LLVector3 old_pos(mXform.getPosition()); @@ -721,7 +721,7 @@ F32 LLDrawable::updateXform(BOOL undamped) if (mSpatialBridge) { - gPipeline.markMoved(mSpatialBridge, FALSE); + gPipeline.markMoved(mSpatialBridge, false); } return dist_squared; } @@ -734,7 +734,7 @@ void LLDrawable::setRadius(F32 radius) } } -void LLDrawable::moveUpdatePipeline(BOOL moved) +void LLDrawable::moveUpdatePipeline(bool moved) { if (moved) { @@ -754,7 +754,7 @@ void LLDrawable::moveUpdatePipeline(BOOL moved) void LLDrawable::movePartition() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLSpatialPartition* part = getSpatialPartition(); if (part) @@ -763,17 +763,17 @@ void LLDrawable::movePartition() } } -BOOL LLDrawable::updateMove() +bool LLDrawable::updateMove() { if (isDead()) { LL_WARNS() << "Update move on dead drawable!" << LL_ENDL; - return TRUE; + return true; } if (mVObjp.isNull()) { - return FALSE; + return false; } makeActive(); @@ -781,26 +781,26 @@ BOOL LLDrawable::updateMove() return isState(MOVE_UNDAMPED) ? updateMoveUndamped() : updateMoveDamped(); } -BOOL LLDrawable::updateMoveUndamped() +bool LLDrawable::updateMoveUndamped() { - F32 dist_squared = updateXform(TRUE); + F32 dist_squared = updateXform(true); mGeneration++; if (!isState(LLDrawable::INVISIBLE)) { - BOOL moved = (dist_squared > 0.001f && dist_squared < 255.99f); + bool moved = (dist_squared > 0.001f && dist_squared < 255.99f); moveUpdatePipeline(moved); mVObjp->updateText(); } mVObjp->clearChanged(LLXform::MOVED); - return TRUE; + return true; } void LLDrawable::updatePartition() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (!getVOVolume()) { @@ -808,7 +808,7 @@ void LLDrawable::updatePartition() } else if (mSpatialBridge) { - gPipeline.markMoved(mSpatialBridge, FALSE); + gPipeline.markMoved(mSpatialBridge, false); } else { @@ -817,22 +817,22 @@ void LLDrawable::updatePartition() } } -BOOL LLDrawable::updateMoveDamped() +bool LLDrawable::updateMoveDamped() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; - F32 dist_squared = updateXform(FALSE); + F32 dist_squared = updateXform(false); mGeneration++; if (!isState(LLDrawable::INVISIBLE)) { - BOOL moved = (dist_squared > 0.001f && dist_squared < 128.0f); + bool moved = (dist_squared > 0.001f && dist_squared < 128.0f); moveUpdatePipeline(moved); mVObjp->updateText(); } - BOOL done_moving = (dist_squared == 0.0f) ? TRUE : FALSE; + bool done_moving = dist_squared == 0.0f; if (done_moving) { @@ -844,7 +844,7 @@ BOOL LLDrawable::updateMoveDamped() void LLDrawable::updateDistance(LLCamera& camera, bool force_update) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { @@ -942,12 +942,12 @@ void LLDrawable::updateTexture() } } -BOOL LLDrawable::updateGeometry() +bool LLDrawable::updateGeometry() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; llassert(mVObjp.notNull()); - BOOL res = mVObjp && mVObjp->updateGeometry(this); + bool res = mVObjp && mVObjp->updateGeometry(this); return res; } @@ -1022,7 +1022,7 @@ const LLVector3& LLDrawable::getBounds(LLVector3& min, LLVector3& max) const void LLDrawable::updateSpatialExtents() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (mVObjp) { @@ -1054,7 +1054,7 @@ void LLDrawable::updateBinRadius() } } -void LLDrawable::updateSpecialHoverCursor(BOOL enabled) +void LLDrawable::updateSpecialHoverCursor(bool enabled) { // TODO: maintain a list of objects that have special // hover cursors, then use that list for per-frame @@ -1067,16 +1067,16 @@ F32 LLDrawable::getVisibilityRadius() const { return 0.f; } - else if (isLight()) + + if (isLight()) { - const LLVOVolume *vov = getVOVolume(); - if (vov) + if (const LLVOVolume* vov = getVOVolume()) { return llmax(getRadius(), vov->getLightRadius()); - } else { - // LL_WARNS() ? } + // LL_WARNS() ? } + return getRadius(); } @@ -1089,16 +1089,14 @@ bool LLDrawable::isVisible() const { if (LLViewerOctreeEntryData::isVisible()) { - return true; + return true; } + LLViewerOctreeGroup* group = mEntry->getGroup(); + if (group && group->isVisible()) { - LLViewerOctreeGroup* group = mEntry->getGroup(); - if (group && group->isVisible()) - { - LLViewerOctreeEntryData::setVisible(); - return true; - } + LLViewerOctreeEntryData::setVisible(); + return true; } return false; @@ -1107,27 +1105,30 @@ bool LLDrawable::isVisible() const //virtual bool LLDrawable::isRecentlyVisible() const { - //currently visible or visible in the previous frame. - bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); + // Currently visible or visible in the previous frame. + if (LLViewerOctreeEntryData::isRecentlyVisible()) + { + return true; + } - if(!vis) + const U32 MIN_VIS_FRAME_RANGE = 2 ; // Two frames: the current one and the last one. + if (sCurVisible - getVisible() < MIN_VIS_FRAME_RANGE) { - const U32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one. - vis = (sCurVisible - getVisible() < MIN_VIS_FRAME_RANGE); + return true; } - return vis ; + return false; } void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) - { +{ LLSpatialGroup* cur_groupp = (LLSpatialGroup*)getGroup(); //precondition: mGroupp MUST be null or DEAD or mGroupp MUST NOT contain this //llassert(!cur_groupp || cur_groupp->isDead() || !cur_groupp->hasElement(this)); //precondition: groupp MUST be null or groupp MUST contain this - llassert(!groupp || (LLSpatialGroup*)groupp->hasElement(this)); + llassert(!groupp || groupp->hasElement(this)); if (cur_groupp != groupp && getVOVolume()) { @@ -1136,8 +1137,7 @@ void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) //contained by its drawable's spatial group for (S32 i = 0; i < getNumFaces(); ++i) { - LLFace* facep = getFace(i); - if (facep) + if (LLFace* facep = getFace(i)) { facep->clearVertexBuffer(); } @@ -1158,7 +1158,7 @@ void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) */ LLSpatialPartition* LLDrawable::getSpatialPartition() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLSpatialPartition* retval = NULL; @@ -1166,7 +1166,7 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() !getVOVolume() || isStatic()) { - retval = gPipeline.getSpatialPartition((LLViewerObject*)mVObjp); + retval = gPipeline.getSpatialPartition(mVObjp); } else if (isRoot()) { @@ -1244,7 +1244,7 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() // Spatial Partition Bridging Drawable //======================================= -LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask, LLViewerRegion* regionp) : +LLSpatialBridge::LLSpatialBridge(LLDrawable* root, bool render_by_group, U32 data_mask, LLViewerRegion* regionp) : LLDrawable(root->getVObj(), true), LLSpatialPartition(data_mask, render_by_group, regionp) { @@ -1274,13 +1274,12 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat LLSpatialBridge::~LLSpatialBridge() { - if(mEntry) - { - LLSpatialGroup* group = getSpatialGroup(); - if (group) + if (mEntry) { - group->getSpatialPartition()->remove(this, group); - } + if (LLSpatialGroup* group = getSpatialGroup()) + { + group->getSpatialPartition()->remove(this, group); + } } //delete octree here so listeners will still be able to access bridge specific state @@ -1295,7 +1294,7 @@ void LLSpatialBridge::destroyTree() void LLSpatialBridge::updateSpatialExtents() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLSpatialGroup* root = (LLSpatialGroup*) mOctree->getListener(0); @@ -1409,7 +1408,7 @@ void LLSpatialBridge::transformExtents(const LLVector4a* src, LLVector4a* dst) } -void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results, BOOL for_select) +void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results, bool for_select) { LLViewerOctreeEntryData::setVisible(); @@ -1466,9 +1465,9 @@ public: } }; -void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* results, BOOL for_select) +void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* results, bool for_select) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (!gPipeline.hasRenderType(mDrawableType)) { @@ -1489,8 +1488,8 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* av = objparent->mDrawable; LLSpatialGroup* group = av->getSpatialGroup(); - BOOL impostor = FALSE; - BOOL loaded = FALSE; + bool impostor = false; + bool loaded = false; if (objparent->isAvatar()) { LLVOAvatar* avatarp = (LLVOAvatar*) objparent; @@ -1567,7 +1566,7 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (mDrawable == NULL) { @@ -1600,18 +1599,10 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) mDrawable->updateDistance(camera, force_update); - LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); - iter != child_list.end(); iter++) + for (LLViewerObject* child : mDrawable->getVObj()->getChildren()) { - LLViewerObject* child = *iter; LLDrawable* drawable = child->mDrawable; - if (!drawable) - { - continue; - } - - if (!drawable->isAvatar()) + if (drawable && !drawable->isDead() && !drawable->isAvatar()) { drawable->updateDistance(camera, force_update); } @@ -1624,13 +1615,13 @@ void LLSpatialBridge::makeActive() LL_ERRS() << "makeActive called on spatial bridge" << LL_ENDL; } -void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate) +void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, bool immediate) { LLSpatialPartition::move(drawablep, curp, immediate); - gPipeline.markMoved(this, FALSE); + gPipeline.markMoved(this, false); } -BOOL LLSpatialBridge::updateMove() +bool LLSpatialBridge::updateMove() { llassert_always(mDrawable); llassert_always(mDrawable->mVObjp); @@ -1641,9 +1632,9 @@ BOOL LLSpatialBridge::updateMove() mOctree->balance(); if (part) { - part->move(this, getSpatialGroup(), TRUE); + part->move(this, getSpatialGroup(), true); } - return TRUE; + return true; } void LLSpatialBridge::shiftPos(const LLVector4a& vec) @@ -1703,33 +1694,33 @@ const LLVector3 LLDrawable::getPositionAgent() const } } -BOOL LLDrawable::isAnimating() const +bool LLDrawable::isAnimating() const { if (!getVObj()) { - return TRUE; + return true; } if (getScale() != mVObjp->getScale()) { - return TRUE; + return true; } if (mVObjp->getPCode() == LLViewerObject::LL_VO_PART_GROUP) { - return TRUE; + return true; } if (mVObjp->getPCode() == LLViewerObject::LL_VO_HUD_PART_GROUP) { - return TRUE; + return true; } /*if (!isRoot() && !mVObjp->getAngularVelocity().isExactlyZero()) { //target omega - return TRUE; + return true; }*/ - return FALSE; + return false; } void LLDrawable::updateFaceSize(S32 idx) |