From 19ad64cc9681b6ac32ed0be219f78fe51d9df5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Sat, 4 Jan 2020 23:31:15 -0500 Subject: [PATCH] AlchSync: Change dynamic_casts to LLVOVolume to asVolume() --- indra/newview/llcontrolavatar.cpp | 2 +- indra/newview/llfloatertools.cpp | 4 ++-- indra/newview/llpanelprimmediacontrols.cpp | 2 +- indra/newview/llselectmgr.cpp | 6 +++--- indra/newview/llspatialpartition.cpp | 2 +- indra/newview/llviewermessage.cpp | 2 +- indra/newview/llviewerobject.cpp | 8 +++++++- indra/newview/llviewerobject.h | 2 ++ indra/newview/llviewerwindow.cpp | 3 ++- indra/newview/llvoavatar.cpp | 23 +++++++++++----------- indra/newview/llvovolume.cpp | 10 +++++++--- indra/newview/llvovolume.h | 6 ++++-- 12 files changed, 42 insertions(+), 28 deletions(-) diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index a3e2973e5..17f34e41d 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -478,7 +478,7 @@ void LLControlAvatar::getAnimatedVolumes(std::vector& volumes) for (const auto& iter : child_list) { LLViewerObject* childp = iter; - LLVOVolume *child_volp = dynamic_cast(childp); + LLVOVolume *child_volp = childp ? childp->asVolume() : nullptr; if (child_volp && child_volp->isAnimatedObject()) { volumes.push_back(child_volp); diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index aec33c078..55847532a 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -1383,8 +1383,8 @@ void LLFloaterTools::getMediaState() for ( ; iter != end; ++iter) { LLSelectNode* node = *iter; - LLVOVolume* object = dynamic_cast(node->getObject()); - if (NULL != object) + LLVOVolume* object = node ? node->getObject()->asVolume() : nullptr; + if (nullptr != object) { if (!object->permModify()) { diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 84146235c..970064c8d 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -320,7 +320,7 @@ void LLPanelPrimMediaControls::updateShape() { bool mini_controls = false; LLMediaEntry *media_data = objectp->getTE(mTargetObjectFace)->getMediaData(); - LLVOVolume *vol = dynamic_cast(objectp); + LLVOVolume *vol = objectp ? objectp->asVolume() : nullptr; if (media_data && vol) { // Don't show the media controls if we do not have permissions diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 7cb3be329..df8e183b1 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1998,7 +1998,7 @@ void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) else { // Add/update media object->setTEMediaFlags(te, mMediaFlags); - LLVOVolume *vo = dynamic_cast(object); + LLVOVolume *vo = object->asVolume(); llassert(NULL != vo); if (NULL != vo) { @@ -2024,7 +2024,7 @@ void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) if (object->permModify()) { object->sendTEUpdate(); - LLVOVolume *vo = dynamic_cast(object); + LLVOVolume *vo = object->asVolume(); llassert(NULL != vo); // It's okay to skip this object if hasMedia() is false... // the sendTEUpdate() above would remove all media data if it were @@ -7434,7 +7434,7 @@ S32 LLObjectSelection::getSelectedObjectRenderCost() ++child_iter) { LLViewerObject* child_obj = *child_iter; - LLVOVolume *child = dynamic_cast( child_obj ); + LLVOVolume *child = child_obj ? child_obj->asVolume() : nullptr; if (child) { cost += child->getRenderCost(textures); diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 3f9a4ef0b..f07432fea 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1787,7 +1787,7 @@ void renderComplexityDisplay(LLDrawable* drawablep) return; } - LLVOVolume *voVol = dynamic_cast(vobj); + LLVOVolume *voVol = vobj->asVolume();; if (!voVol) { diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 7429f5ca3..bf1c95af7 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -5953,7 +5953,7 @@ void process_object_animation(LLMessageSystem *mesgsys, void **user_data) return; } - LLVOVolume *volp = dynamic_cast(objp); + LLVOVolume *volp = objp->asVolume(); if (!volp) { LL_DEBUGS("AnimatedObjectsNotify") << "Received animation state for non-volume object " << uuid << LL_ENDL; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 1b948da9a..f6d8a20a9 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -3091,7 +3091,7 @@ void LLViewerObject::linkControlAvatar() { if (!getControlAvatar() && isRootEdit()) { - LLVOVolume *volp = dynamic_cast(this); + LLVOVolume *volp = asVolume(); if (!volp) { LL_WARNS() << "called with null or non-volume object" << LL_ENDL; @@ -5583,6 +5583,12 @@ LLVOAvatar* LLViewerObject::asAvatar() return NULL; } +// virtual +LLVOVolume* LLViewerObject::asVolume() +{ + return nullptr; +} + // If this object is directly or indirectly parented by an avatar, // return it. Normally getAvatar() is the correct function to call; // it will give the avatar used for skinning. The exception is with diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index fb4b812c6..e95b25c42 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -69,6 +69,7 @@ class LLPrimitive; class LLTextureEntry; class LLVOAvatar; class LLVOInventoryListener; +class LLVOVolume; class LLViewerInventoryItem; class LLViewerObject; class LLViewerObjectMedia; @@ -157,6 +158,7 @@ public: BOOL isParticleSource() const; virtual LLVOAvatar* asAvatar(); + virtual LLVOVolume* asVolume(); LLVOAvatar* getAvatarAncestor(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 608a4529a..eb3fb00c7 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1116,7 +1116,8 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi LL_DEBUGS() << "Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << LL_ENDL; - LLVOVolume *obj = dynamic_cast(static_cast(pick_info.getObject())); + LLViewerObject* vobjp = static_cast(pick_info.getObject()); + LLVOVolume *obj = vobjp ? vobjp->asVolume() : nullptr; if (obj && !obj->getRegion()->getCapability("ObjectMedia").empty()) { diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 2541648ee..e6505cd45 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -6923,7 +6923,7 @@ void LLVOAvatar::addAttachmentOverridesForObject(LLViewerObject *vo, uuid_set_t* } } - LLVOVolume *vobj = dynamic_cast(vo); + LLVOVolume *vobj = vo->asVolume(); if (vobj && vobj->isRiggedMesh() && vobj->getVolume() && vobj->getVolume()->isMeshAssetLoaded() && gMeshRepo.meshRezEnabled()) { @@ -10567,7 +10567,7 @@ void LLVOAvatar::getAssociatedVolumes(std::vector& volumes) {{ LLViewerObject* attached_object = iter.first; #endif - LLVOVolume *volume = dynamic_cast(attached_object); + LLVOVolume *volume = attached_object->asVolume(); if (volume) { volumes.push_back(volume); @@ -10580,11 +10580,12 @@ void LLVOAvatar::getAssociatedVolumes(std::vector& volumes) } } LLViewerObject::const_child_list_t& children = attached_object->getChildren(); - for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); - it != children.end(); ++it) + for (LLViewerObject* childp : children) { - LLViewerObject *childp = *it; - LLVOVolume *volume = dynamic_cast(childp); + if (!childp) + continue; + + LLVOVolume *volume = childp->asVolume(); if (volume) { volumes.push_back(volume); @@ -10601,11 +10602,9 @@ void LLVOAvatar::getAssociatedVolumes(std::vector& volumes) { volumes.push_back(volp); LLViewerObject::const_child_list_t& children = volp->getChildren(); - for (LLViewerObject::const_child_list_t::const_iterator it = children.begin(); - it != children.end(); ++it) + for (LLViewerObject* childp : children) { - LLViewerObject *childp = *it; - LLVOVolume *volume = dynamic_cast(childp); + LLVOVolume *volume = childp ? childp->asVolume() : nullptr; if (volume) { volumes.push_back(volume); @@ -10950,7 +10949,7 @@ void LLVOAvatar::accountRenderComplexityForObject( ++child_iter) { LLViewerObject* child_obj = *child_iter; - LLVOVolume *child = dynamic_cast(child_obj); + LLVOVolume *child = child_obj ? child_obj->asVolume() : nullptr; if (child) { attachment_children_cost += child->getRenderCost(textures); @@ -11007,7 +11006,7 @@ void LLVOAvatar::accountRenderComplexityForObject( iter != child_list.end(); ++iter) { LLViewerObject* childp = *iter; - const LLVOVolume* chld_volume = dynamic_cast(childp); + const LLVOVolume* chld_volume = childp ? childp->asVolume() : nullptr; if (chld_volume) { // get cost and individual textures diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2d9f841b6..34de9a3b7 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -265,6 +265,11 @@ LLVOVolume::~LLVOVolume() } } +LLVOVolume* LLVOVolume::asVolume() +{ + return this; +} + void LLVOVolume::markDead() { if (!mDead) @@ -3496,8 +3501,6 @@ bool LLVOVolume::isAnimatedObject() const // virtual void LLVOVolume::onReparent(LLViewerObject *old_parent, LLViewerObject *new_parent) { - LLVOVolume *old_volp = dynamic_cast(old_parent); - if (new_parent && !new_parent->isAvatar()) { if (mControlAvatar.notNull()) @@ -3509,6 +3512,7 @@ void LLVOVolume::onReparent(LLViewerObject *old_parent, LLViewerObject *new_pare av->markForDeath(); } } + LLVOVolume *old_volp = old_parent ? old_parent->asVolume() : nullptr; if (old_volp && old_volp->isAnimatedObject()) { if (old_volp->getControlAvatar()) @@ -5247,7 +5251,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (bridge) { vobj = bridge->mDrawable->getVObj(); - vol_obj = dynamic_cast(vobj); + vol_obj = vobj ? vobj->asVolume() : nullptr; } if (vol_obj) { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index ab2065ca8..db91548e8 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -94,7 +94,7 @@ public: }; // Class which embodies all Volume objects (with pcode LL_PCODE_VOLUME) -class LLVOVolume : public LLViewerObject +class LLVOVolume final : public LLViewerObject { LOG_CLASS(LLVOVolume); protected: @@ -126,7 +126,9 @@ public: public: LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); - /*virtual*/ void markDead(); // Override (and call through to parent) to clean up media references + + LLVOVolume* asVolume() final; + /*virtual*/ void markDead() override; // Override (and call through to parent) to clean up media references /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);