pass touch_end as other touchs, make blockgrab work on nonphysical also

LSLKeyTest
UbitUmarov 2016-09-16 19:23:56 +01:00
parent 7c4c3f0d10
commit fb46eb3344
3 changed files with 54 additions and 63 deletions

View File

@ -1881,7 +1881,7 @@ namespace OpenSim.Region.Framework.Scenes
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", "[EVENT MANAGER]: Delegate for TriggerGroupMove failed - continuing. {0} {1}",
e.Message, e.StackTrace); e.Message, e.StackTrace);
} }
} }

View File

@ -340,13 +340,11 @@ namespace OpenSim.Region.Framework.Scenes
obj.ObjectGrabHandler(localID, offsetPos, remoteClient); obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
// If the touched prim handles touches, deliver it // If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ScriptEvents & scriptEvents.touch_start) != 0) if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
// Deliver to the root prim if the touched prim doesn't handle touches // Deliver to the root prim if the touched prim doesn't handle touches
// or if we're meant to pass on touches anyway. Don't send to root prim // or if we're meant to pass on touches anyway.
// if prim touched is the root prim as we just did it
if (((part.ScriptEvents & scriptEvents.touch_start) == 0) || if (((part.ScriptEvents & scriptEvents.touch_start) == 0) ||
(part.PassTouches && (part.LocalId != obj.RootPart.LocalId))) (part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
{ {
@ -381,12 +379,10 @@ namespace OpenSim.Region.Framework.Scenes
surfaceArg = surfaceArgs[0]; surfaceArg = surfaceArgs[0];
// If the touched prim handles touches, deliver it // If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ScriptEvents & scriptEvents.touch) != 0) if ((part.ScriptEvents & scriptEvents.touch) != 0)
EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
// Deliver to the root prim if the touched prim doesn't handle touches // Deliver to the root prim if the touched prim doesn't handle touches
// or if we're meant to pass on touches anyway. Don't send to root prim // or if we're meant to pass on touches anyway.
// if prim touched is the root prim as we just did it
if (((part.ScriptEvents & scriptEvents.touch) == 0) || if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
(part.PassTouches && (part.LocalId != group.RootPart.LocalId))) (part.PassTouches && (part.LocalId != group.RootPart.LocalId)))
{ {
@ -400,18 +396,21 @@ namespace OpenSim.Region.Framework.Scenes
if (part == null) if (part == null)
return; return;
SceneObjectGroup obj = part.ParentGroup; SceneObjectGroup grp = part.ParentGroup;
SurfaceTouchEventArgs surfaceArg = null; SurfaceTouchEventArgs surfaceArg = null;
if (surfaceArgs != null && surfaceArgs.Count > 0) if (surfaceArgs != null && surfaceArgs.Count > 0)
surfaceArg = surfaceArgs[0]; surfaceArg = surfaceArgs[0];
// If the touched prim handles touches, deliver it // If the touched prim handles touches, deliver it
// If not, deliver to root prim
if ((part.ScriptEvents & scriptEvents.touch_end) != 0) if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg); EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
else // if not or PassTouchs, send it also to root.
EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); if (((part.ScriptEvents & scriptEvents.touch_end) == 0) ||
(part.PassTouches && (part.LocalId != grp.RootPart.LocalId)))
{
EventManager.TriggerObjectDeGrab(grp.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
}
} }
public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID,

View File

@ -79,7 +79,8 @@ namespace OpenSim.Region.Framework.Scenes
touch_end = 536870912, touch_end = 536870912,
touch_start = 2097152, touch_start = 2097152,
transaction_result = 33554432, transaction_result = 33554432,
object_rez = 4194304 object_rez = 4194304,
anytouch = touch | touch_end | touch_start
} }
public struct scriptPosTarget public struct scriptPosTarget
@ -3497,34 +3498,26 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
{ {
if (BlockGrabOverride)
return;
SceneObjectPart part = GetPart(partID); SceneObjectPart part = GetPart(partID);
if (part == null) if (part == null)
return; return;
if (part.BlockGrab)
return;
PhysicsActor pa = m_rootPart.PhysActor; PhysicsActor pa = m_rootPart.PhysActor;
if (pa != null) if (pa != null && pa.IsPhysical)
{ {
if (pa.IsPhysical) // empirically convert distance diference to a impulse
{ Vector3 grabforce = pos - AbsolutePosition;
if (!BlockGrabOverride && !part.BlockGrab) grabforce = grabforce * (pa.Mass * 0.1f);
{ pa.AddForce(grabforce, false);
/* Vector3 llmoveforce = pos - AbsolutePosition; m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
Vector3 grabforce = llmoveforce;
grabforce = (grabforce / 10) * pa.Mass;
*/
// empirically convert distance diference to a impulse
Vector3 grabforce = pos - AbsolutePosition;
grabforce = grabforce * (pa.Mass/ 10.0f);
pa.AddForce(grabforce, false);
m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
}
}
else
{
NonPhysicalGrabMovement(pos);
}
} }
else else
{ {
@ -3553,6 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
public void SpinStart(IClientAPI remoteClient) public void SpinStart(IClientAPI remoteClient)
{ {
if (BlockGrabOverride || m_rootPart.BlockGrab)
return;
if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) if (m_scene.EventManager.TriggerGroupSpinStart(UUID))
{ {
PhysicsActor pa = m_rootPart.PhysActor; PhysicsActor pa = m_rootPart.PhysActor;
@ -3600,46 +3595,43 @@ namespace OpenSim.Region.Framework.Scenes
// but it will result in over-shoot or under-shoot of the target orientation. // but it will result in over-shoot or under-shoot of the target orientation.
// For the end user, this means that ctrl+shift+drag can be used for relative, // For the end user, this means that ctrl+shift+drag can be used for relative,
// but not absolute, adjustments of orientation for physical prims. // but not absolute, adjustments of orientation for physical prims.
if (BlockGrabOverride || m_rootPart.BlockGrab)
return;
if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation))
{ {
PhysicsActor pa = m_rootPart.PhysActor; PhysicsActor pa = m_rootPart.PhysActor;
if (pa != null) if (pa != null && pa.IsPhysical)
{ {
if (pa.IsPhysical) if (m_rootPart.IsWaitingForFirstSpinUpdatePacket)
{ {
if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) // first time initialization of "old" orientation for calculation of delta rotations
{ m_rootPart.SpinOldOrientation = newOrientation;
// first time initialization of "old" orientation for calculation of delta rotations m_rootPart.IsWaitingForFirstSpinUpdatePacket = false;
m_rootPart.SpinOldOrientation = newOrientation;
m_rootPart.IsWaitingForFirstSpinUpdatePacket = false;
}
else
{
// save and update old orientation
Quaternion old = m_rootPart.SpinOldOrientation;
m_rootPart.SpinOldOrientation = newOrientation;
//m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old);
//m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation);
// compute difference between previous old rotation and new incoming rotation
Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation;
float rotationAngle;
Vector3 rotationAxis;
minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle);
rotationAxis.Normalize();
//m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor
pa.AddAngularForce(spinforce,true);
m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
}
} }
else else
{ {
NonPhysicalSpinMovement(newOrientation); // save and update old orientation
Quaternion old = m_rootPart.SpinOldOrientation;
m_rootPart.SpinOldOrientation = newOrientation;
//m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old);
//m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation);
// compute difference between previous old rotation and new incoming rotation
Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation;
float rotationAngle;
Vector3 rotationAxis;
minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle);
rotationAxis.Normalize();
//m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor
pa.AddAngularForce(spinforce,true);
m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
} }
} }
else else