SL-11535 Autopilot should store selection for later use

master
andreykproductengine 2019-07-03 13:01:56 +03:00
parent dbb613a2d8
commit 45ecb9d6af
3 changed files with 104 additions and 16 deletions

View File

@ -152,6 +152,53 @@ struct LLDeRezInfo
// Imports
//
//-----------------------------------------------------------------------------
// ~LLSelectionCallbackData()
//-----------------------------------------------------------------------------
LLSelectionCallbackData::LLSelectionCallbackData()
{
LLSelectMgr *instance = LLSelectMgr::getInstance();
LLObjectSelectionHandle selection = instance->getSelection();
if (!selection->getNumNodes())
{
return;
}
mSelectedObjects = new LLObjectSelection();
for (LLObjectSelection::iterator iter = selection->begin();
iter != selection->end();)
{
LLObjectSelection::iterator curiter = iter++;
LLSelectNode *nodep = *curiter;
LLViewerObject* objectp = nodep->getObject();
if (!objectp)
{
mSelectedObjects->mSelectType = SELECT_TYPE_WORLD;
}
else
{
LLSelectNode* new_nodep = new LLSelectNode(*nodep);
mSelectedObjects->addNode(new_nodep);
if (objectp->isHUDAttachment())
{
mSelectedObjects->mSelectType = SELECT_TYPE_HUD;
}
else if (objectp->isAttachment())
{
mSelectedObjects->mSelectType = SELECT_TYPE_ATTACHMENT;
}
else
{
mSelectedObjects->mSelectType = SELECT_TYPE_WORLD;
}
}
}
}
//
// Functions
@ -4472,9 +4519,19 @@ void LLSelectMgr::selectionSetObjectSaleInfo(const LLSaleInfo& sale_info)
void LLSelectMgr::sendAttach(U8 attachment_point, bool replace)
{
LLViewerObject* attach_object = mSelectedObjects->getFirstRootObject();
sendAttach(mSelectedObjects, attachment_point, replace);
}
if (!attach_object || !isAgentAvatarValid() || mSelectedObjects->mSelectType != SELECT_TYPE_WORLD)
void LLSelectMgr::sendAttach(LLObjectSelectionHandle selection_handle, U8 attachment_point, bool replace)
{
if (selection_handle.isNull())
{
return;
}
LLViewerObject* attach_object = selection_handle->getFirstRootObject();
if (!attach_object || !isAgentAvatarValid() || selection_handle->mSelectType != SELECT_TYPE_WORLD)
{
return;
}
@ -4492,6 +4549,7 @@ void LLSelectMgr::sendAttach(U8 attachment_point, bool replace)
}
sendListToRegions(
selection_handle,
"ObjectAttach",
packAgentIDAndSessionAndAttachment,
packObjectIDAndRotation,
@ -4503,6 +4561,7 @@ void LLSelectMgr::sendAttach(U8 attachment_point, bool replace)
// After "ObjectAttach" server will unsubscribe us from properties updates
// so either deselect objects or resend selection after attach packet reaches server
// In case of build_mode LLPanelObjectInventory::refresh() will deal with selection
// Still unsubscribe even in case selection_handle is not current selection
deselectAll();
}
}
@ -5044,7 +5103,17 @@ void LLSelectMgr::packPermissions(LLSelectNode* node, void *user_data)
void LLSelectMgr::sendListToRegions(const std::string& message_name,
void (*pack_header)(void *user_data),
void (*pack_body)(LLSelectNode* node, void *user_data),
void (*log_func)(LLSelectNode* node, void *user_data),
void (*log_func)(LLSelectNode* node, void *user_data),
void *user_data,
ESendType send_type)
{
sendListToRegions(mSelectedObjects, message_name, pack_header, pack_body, log_func, user_data, send_type);
}
void LLSelectMgr::sendListToRegions(LLObjectSelectionHandle selected_handle,
const std::string& message_name,
void (*pack_header)(void *user_data),
void (*pack_body)(LLSelectNode* node, void *user_data),
void (*log_func)(LLSelectNode* node, void *user_data),
void *user_data,
ESendType send_type)
{
@ -5070,7 +5139,7 @@ void LLSelectMgr::sendListToRegions(const std::string& message_name,
return true;
}
} func;
getSelection()->applyToNodes(&func);
selected_handle->applyToNodes(&func);
std::queue<LLSelectNode*> nodes_to_send;
@ -5113,25 +5182,25 @@ void LLSelectMgr::sendListToRegions(const std::string& message_name,
{
case SEND_ONLY_ROOTS:
if(message_name == "ObjectBuy")
getSelection()->applyToRootNodes(&pushroots);
selected_handle->applyToRootNodes(&pushroots);
else
getSelection()->applyToRootNodes(&pushall);
selected_handle->applyToRootNodes(&pushall);
break;
case SEND_INDIVIDUALS:
getSelection()->applyToNodes(&pushall);
selected_handle->applyToNodes(&pushall);
break;
case SEND_ROOTS_FIRST:
// first roots...
getSelection()->applyToNodes(&pushroots);
selected_handle->applyToNodes(&pushroots);
// then children...
getSelection()->applyToNodes(&pushnonroots);
selected_handle->applyToNodes(&pushnonroots);
break;
case SEND_CHILDREN_FIRST:
// first children...
getSelection()->applyToNodes(&pushnonroots);
selected_handle->applyToNodes(&pushnonroots);
// then roots...
getSelection()->applyToNodes(&pushroots);
selected_handle->applyToNodes(&pushroots);
break;
default:

View File

@ -239,6 +239,7 @@ class LLObjectSelection : public LLRefCount
{
friend class LLSelectMgr;
friend class LLSafeHandle<LLObjectSelection>;
friend class LLSelectionCallbackData;
protected:
~LLObjectSelection();
@ -396,6 +397,16 @@ extern template class LLSelectMgr* LLSingleton<class LLSelectMgr>::getInstance()
// For use with getFirstTest()
struct LLSelectGetFirstTest;
// temporary storage, Ex: to attach objects after autopilot
class LLSelectionCallbackData
{
public:
LLSelectionCallbackData();
LLObjectSelectionHandle getSelection() { return mSelectedObjects; }
private:
LLObjectSelectionHandle mSelectedObjects;
};
class LLSelectMgr : public LLEditMenuHandler, public LLSingleton<LLSelectMgr>
{
LLSINGLETON(LLSelectMgr);
@ -740,6 +751,7 @@ public:
// canceled
void sendBuy(const LLUUID& buyer_id, const LLUUID& category_id, const LLSaleInfo sale_info);
void sendAttach(U8 attachment_point, bool replace);
void sendAttach(LLObjectSelectionHandle selection_handle, U8 attachment_point, bool replace);
void sendDetach();
void sendDropAttachment();
void sendLink();
@ -787,6 +799,13 @@ private:
void (*log_func)(LLSelectNode* node, void *user_data),
void *user_data,
ESendType send_type);
void sendListToRegions( LLObjectSelectionHandle selected_handle,
const std::string& message_name,
void (*pack_header)(void *user_data),
void (*pack_body)(LLSelectNode* node, void *user_data),
void (*log_func)(LLSelectNode* node, void *user_data),
void *user_data,
ESendType send_type);
static void packAgentID( void *);

View File

@ -6672,10 +6672,10 @@ private:
static void onNearAttachObject(BOOL success, void *user_data);
void confirmReplaceAttachment(S32 option, LLViewerJointAttachment* attachment_point);
struct CallbackData
class CallbackData : public LLSelectionCallbackData
{
CallbackData(LLViewerJointAttachment* point, bool replace) : mAttachmentPoint(point), mReplace(replace) {}
public:
CallbackData(LLViewerJointAttachment* point, bool replace) : LLSelectionCallbackData(), mAttachmentPoint(point), mReplace(replace) {}
LLViewerJointAttachment* mAttachmentPoint;
bool mReplace;
@ -6716,8 +6716,8 @@ void LLObjectAttachToAvatar::onNearAttachObject(BOOL success, void *user_data)
// interpret 0 as "default location"
attachment_id = 0;
}
LLSelectMgr::getInstance()->sendAttach(attachment_id, cb_data->mReplace);
}
LLSelectMgr::getInstance()->sendAttach(cb_data->getSelection(), attachment_id, cb_data->mReplace);
}
LLObjectAttachToAvatar::setObjectSelection(NULL);
delete cb_data;