summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llagentlistener.cpp75
-rw-r--r--indra/newview/llagentlistener.h1
-rw-r--r--indra/newview/lltoolgrab.cpp99
-rw-r--r--indra/newview/lltoolgrab.h7
-rw-r--r--indra/newview/llviewermenu.cpp50
5 files changed, 160 insertions, 72 deletions
diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp
index 0d30b95074..0a13644911 100644
--- a/indra/newview/llagentlistener.cpp
+++ b/indra/newview/llagentlistener.cpp
@@ -40,6 +40,7 @@
#include "llviewerregion.h"
#include "llsdutil.h"
#include "llsdutil_math.h"
+#include "lltoolgrab.h"
LLAgentListener::LLAgentListener(LLAgent &agent)
: LLEventAPI("LLAgent",
@@ -56,6 +57,11 @@ LLAgentListener::LLAgentListener(LLAgent &agent)
add("requestStand",
"Ask to stand up",
&LLAgentListener::requestStand);
+ add("requestTouch",
+ "[\"obj_uuid\"]: id of object to touch, use this or [\"position\"] to indicate the object to touch"
+ "[\"position\"]: region position {x, y, z} where to find closest object to touch"
+ "[\"face\"]: optional object face number to touch[Default: 0]",
+ &LLAgentListener::requestTouch);
add("resetAxes",
"Set the agent to a fixed orientation (optionally specify [\"lookat\"] = array of [x, y, z])",
&LLAgentListener::resetAxes);
@@ -169,6 +175,75 @@ void LLAgentListener::requestStand(LLSD const & event_data) const
mAgent.setControlFlags(AGENT_CONTROL_STAND_UP);
}
+void LLAgentListener::requestTouch(LLSD const & event_data) const
+{
+ LLViewerObject *object = NULL;
+
+ if (event_data.has("obj_uuid"))
+ {
+ object = gObjectList.findObject(event_data["obj_uuid"]);
+ }
+ else if (event_data.has("position"))
+ {
+ LLVector3 target_position = ll_vector3_from_sd(event_data["position"]);
+
+ // Find the object closest to that position
+ F32 min_distance = 10000.0f; // Start big
+ S32 num_objects = gObjectList.getNumObjects();
+ S32 cur_index = 0;
+ while (cur_index < num_objects)
+ {
+ LLViewerObject * cur_object = gObjectList.getObject(cur_index++);
+ if (cur_object)
+ { // Calculate distance from the target position
+ LLVector3 target_diff = cur_object->getPositionRegion() - target_position;
+ F32 distance_to_target = target_diff.length();
+ if (distance_to_target < min_distance)
+ { // Found an object closer
+ min_distance = distance_to_target;
+ object = cur_object;
+ }
+ }
+ }
+ }
+
+ S32 face = 0;
+ if (event_data.has("face"))
+ {
+ face = event_data["face"].asInteger();
+ }
+
+ if (object && object->getPCode() == LL_PCODE_VOLUME)
+ {
+ // Fake enough pick info to get it to (hopefully) work
+ LLPickInfo pick;
+ pick.mObjectFace = face;
+
+ /*
+ These values are sent to the simulator, but face seems to be easiest to use
+
+ pick.mUVCoords "UVCoord"
+ pick.mSTCoords "STCoord"
+ pick.mObjectFace "FaceIndex"
+ pick.mIntersection "Position"
+ pick.mNormal "Normal"
+ pick.mBinormal "Binormal"
+ */
+
+ // A touch is a sketchy message sequence ... send a grab, immediately
+ // followed by un-grabbing, crossing fingers and hoping packets arrive in
+ // the correct order
+ send_ObjectGrab_message(object, pick, LLVector3::zero);
+ send_ObjectDeGrab_message(object, pick);
+ }
+ else
+ {
+ llwarns << "LLAgent requestTouch could not find the touch target "
+ << event_data["obj_uuid"].asUUID() << llendl;
+ }
+}
+
+
void LLAgentListener::resetAxes(const LLSD& event) const
{
if (event.has("lookat"))
diff --git a/indra/newview/llagentlistener.h b/indra/newview/llagentlistener.h
index aadb87db12..6aeda5f8db 100644
--- a/indra/newview/llagentlistener.h
+++ b/indra/newview/llagentlistener.h
@@ -44,6 +44,7 @@ private:
void requestTeleport(LLSD const & event_data) const;
void requestSit(LLSD const & event_data) const;
void requestStand(LLSD const & event_data) const;
+ void requestTouch(LLSD const & event_data) const;
void resetAxes(const LLSD& event) const;
void getAxes(const LLSD& event) const;
void getPosition(const LLSD& event) const;
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index b6c0f662e5..319e2508e0 100644
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -54,7 +54,6 @@
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
-#include "llviewerwindow.h"
#include "llvoavatarself.h"
#include "llworld.h"
@@ -387,22 +386,7 @@ void LLToolGrab::startGrab()
mDragStartPointGlobal = grab_start_global;
mDragStartFromCamera = grab_start_global - gAgentCamera.getCameraPositionGlobal();
- LLMessageSystem *msg = gMessageSystem;
- msg->newMessageFast(_PREHASH_ObjectGrab);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlockFast(_PREHASH_ObjectData);
- msg->addU32Fast(_PREHASH_LocalID, objectp->mLocalID);
- msg->addVector3Fast(_PREHASH_GrabOffset, grab_offset );
- msg->nextBlock("SurfaceInfo");
- msg->addVector3("UVCoord", LLVector3(mGrabPick.mUVCoords));
- msg->addVector3("STCoord", LLVector3(mGrabPick.mSTCoords));
- msg->addS32Fast(_PREHASH_FaceIndex, mGrabPick.mObjectFace);
- msg->addVector3("Position", mGrabPick.mIntersection);
- msg->addVector3("Normal", mGrabPick.mNormal);
- msg->addVector3("Binormal", mGrabPick.mBinormal);
- msg->sendMessage( objectp->getRegion()->getHost());
+ send_ObjectGrab_message(objectp, mGrabPick, grab_offset);
mGrabOffsetFromCenterInitial = grab_offset;
mGrabHiddenOffsetFromCamera = mDragStartFromCamera;
@@ -1036,28 +1020,12 @@ void LLToolGrab::stopGrab()
}
// Next, send messages to simulator
- LLMessageSystem *msg = gMessageSystem;
switch(mMode)
{
case GRAB_ACTIVE_CENTER:
case GRAB_NONPHYSICAL:
case GRAB_LOCKED:
- msg->newMessageFast(_PREHASH_ObjectDeGrab);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlockFast(_PREHASH_ObjectData);
- msg->addU32Fast(_PREHASH_LocalID, objectp->mLocalID);
- msg->nextBlock("SurfaceInfo");
- msg->addVector3("UVCoord", LLVector3(pick.mUVCoords));
- msg->addVector3("STCoord", LLVector3(pick.mSTCoords));
- msg->addS32Fast(_PREHASH_FaceIndex, pick.mObjectFace);
- msg->addVector3("Position", pick.mIntersection);
- msg->addVector3("Normal", pick.mNormal);
- msg->addVector3("Binormal", pick.mBinormal);
-
- msg->sendMessage(objectp->getRegion()->getHost());
-
+ send_ObjectDeGrab_message(objectp, pick);
mVerticalDragging = FALSE;
break;
@@ -1109,3 +1077,66 @@ LLVector3d LLToolGrab::getGrabPointGlobal()
return gAgent.getPositionGlobal();
}
}
+
+
+void send_ObjectGrab_message(LLViewerObject* object, const LLPickInfo & pick, const LLVector3 &grab_offset)
+{
+ if (!object) return;
+
+ LLMessageSystem *msg = gMessageSystem;
+
+ msg->newMessageFast(_PREHASH_ObjectGrab);
+ msg->nextBlockFast( _PREHASH_AgentData);
+ msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ msg->nextBlockFast( _PREHASH_ObjectData);
+ msg->addU32Fast( _PREHASH_LocalID, object->mLocalID);
+ msg->addVector3Fast(_PREHASH_GrabOffset, grab_offset);
+ msg->nextBlock("SurfaceInfo");
+ msg->addVector3("UVCoord", LLVector3(pick.mUVCoords));
+ msg->addVector3("STCoord", LLVector3(pick.mSTCoords));
+ msg->addS32Fast(_PREHASH_FaceIndex, pick.mObjectFace);
+ msg->addVector3("Position", pick.mIntersection);
+ msg->addVector3("Normal", pick.mNormal);
+ msg->addVector3("Binormal", pick.mBinormal);
+ msg->sendMessage( object->getRegion()->getHost());
+
+ /* Diagnostic code
+ llinfos << "mUVCoords: " << pick.mUVCoords
+ << ", mSTCoords: " << pick.mSTCoords
+ << ", mObjectFace: " << pick.mObjectFace
+ << ", mIntersection: " << pick.mIntersection
+ << ", mNormal: " << pick.mNormal
+ << ", mBinormal: " << pick.mBinormal
+ << llendl;
+
+ llinfos << "Avatar pos: " << gAgent.getPositionAgent() << llendl;
+ llinfos << "Object pos: " << object->getPosition() << llendl;
+ */
+}
+
+
+void send_ObjectDeGrab_message(LLViewerObject* object, const LLPickInfo & pick)
+{
+ if (!object) return;
+
+ LLMessageSystem *msg = gMessageSystem;
+
+ msg->newMessageFast(_PREHASH_ObjectDeGrab);
+ msg->nextBlockFast(_PREHASH_AgentData);
+ msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+ msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+ msg->nextBlockFast(_PREHASH_ObjectData);
+ msg->addU32Fast(_PREHASH_LocalID, object->mLocalID);
+ msg->nextBlock("SurfaceInfo");
+ msg->addVector3("UVCoord", LLVector3(pick.mUVCoords));
+ msg->addVector3("STCoord", LLVector3(pick.mSTCoords));
+ msg->addS32Fast(_PREHASH_FaceIndex, pick.mObjectFace);
+ msg->addVector3("Position", pick.mIntersection);
+ msg->addVector3("Normal", pick.mNormal);
+ msg->addVector3("Binormal", pick.mBinormal);
+ msg->sendMessage(object->getRegion()->getHost());
+}
+
+
+
diff --git a/indra/newview/lltoolgrab.h b/indra/newview/lltoolgrab.h
index 61e3fcb8b2..06a3b662c8 100644
--- a/indra/newview/lltoolgrab.h
+++ b/indra/newview/lltoolgrab.h
@@ -39,6 +39,13 @@ class LLTextBox;
class LLViewerObject;
class LLPickInfo;
+
+// Message utilities
+void send_ObjectGrab_message(LLViewerObject* object, const LLPickInfo & pick, const LLVector3 &grab_offset);
+void send_ObjectDeGrab_message(LLViewerObject* object, const LLPickInfo & pick);
+
+
+
class LLToolGrab : public LLTool, public LLSingleton<LLToolGrab>
{
public:
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index ec72df79d1..81a4188cd4 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -104,6 +104,7 @@
#include "llappearancemgr.h"
#include "lltrans.h"
#include "lleconomy.h"
+#include "lltoolgrab.h"
#include "boost/unordered_map.hpp"
using namespace LLVOAvatarDefines;
@@ -2392,50 +2393,23 @@ class LLObjectEnableReportAbuse : public view_listener_t
}
};
+
void handle_object_touch()
{
- LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
- if (!object) return;
-
- LLPickInfo pick = LLToolPie::getInstance()->getPick();
+ LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
+ if (!object) return;
- LLMessageSystem *msg = gMessageSystem;
+ LLPickInfo pick = LLToolPie::getInstance()->getPick();
- msg->newMessageFast(_PREHASH_ObjectGrab);
- msg->nextBlockFast( _PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlockFast( _PREHASH_ObjectData);
- msg->addU32Fast( _PREHASH_LocalID, object->mLocalID);
- msg->addVector3Fast(_PREHASH_GrabOffset, LLVector3::zero );
- msg->nextBlock("SurfaceInfo");
- msg->addVector3("UVCoord", LLVector3(pick.mUVCoords));
- msg->addVector3("STCoord", LLVector3(pick.mSTCoords));
- msg->addS32Fast(_PREHASH_FaceIndex, pick.mObjectFace);
- msg->addVector3("Position", pick.mIntersection);
- msg->addVector3("Normal", pick.mNormal);
- msg->addVector3("Binormal", pick.mBinormal);
- msg->sendMessage( object->getRegion()->getHost());
-
- // *NOTE: Hope the packets arrive safely and in order or else
- // there will be some problems.
- // *TODO: Just fix this bad assumption.
- msg->newMessageFast(_PREHASH_ObjectDeGrab);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
- msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
- msg->nextBlockFast(_PREHASH_ObjectData);
- msg->addU32Fast(_PREHASH_LocalID, object->mLocalID);
- msg->nextBlock("SurfaceInfo");
- msg->addVector3("UVCoord", LLVector3(pick.mUVCoords));
- msg->addVector3("STCoord", LLVector3(pick.mSTCoords));
- msg->addS32Fast(_PREHASH_FaceIndex, pick.mObjectFace);
- msg->addVector3("Position", pick.mIntersection);
- msg->addVector3("Normal", pick.mNormal);
- msg->addVector3("Binormal", pick.mBinormal);
- msg->sendMessage(object->getRegion()->getHost());
+ // *NOTE: Hope the packets arrive safely and in order or else
+ // there will be some problems.
+ // *TODO: Just fix this bad assumption.
+ send_ObjectGrab_message(object, pick, LLVector3::zero);
+ send_ObjectDeGrab_message(object, pick);
}
+
+
static void init_default_item_label(const std::string& item_name)
{
boost::unordered_map<std::string, LLStringExplicit>::iterator it = sDefaultItemLabels.find(item_name);