Exemple #1
0
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"]);
		object = findObjectClosestTo(target_position);
	}

	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 LLToolGrab::stopGrab()
{
	LLViewerObject* objectp = mGrabPick.getObject();
	if (!objectp)
	{
		return;
	}

	LLPickInfo pick = mGrabPick;

	if (mMode == GRAB_NONPHYSICAL)
	{
		// for non-physical (touch) grabs,
		// gather surface info for this degrab (mouse-up)
		S32 x = gViewerWindow->getCurrentMouseX();
		S32 y = gViewerWindow->getCurrentMouseY();
		pick.mMousePt = LLCoordGL(x, y);
		pick.getSurfaceInfo();
	}

	// Next, send messages to simulator
	switch(mMode)
	{
	case GRAB_ACTIVE_CENTER:
	case GRAB_NONPHYSICAL:
	case GRAB_LOCKED:
		send_ObjectDeGrab_message(objectp, pick);
		mVerticalDragging = FALSE;
		break;

	case GRAB_NOOBJECT:
	case GRAB_INACTIVE:
	default:
		// do nothing
		break;
	}

	mHideBuildHighlight = FALSE;
}