Merge branch 'ubitwork' into avination

avinationmerge
Melanie 2012-06-28 22:06:02 +02:00
commit 498820a74f
7 changed files with 139 additions and 85 deletions

View File

@ -6402,6 +6402,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{ {
handlerCompleteMovementToRegion(sender, true); handlerCompleteMovementToRegion(sender, true);
} }
else
m_log.Debug("HandleCompleteAgentMovement NULL handler");
handlerCompleteMovementToRegion = null; handlerCompleteMovementToRegion = null;
return true; return true;

View File

@ -710,14 +710,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
IClientAPI client; IClientAPI client;
if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView))
{ {
//m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); // m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
return; return;
} }
udpClient = ((LLClientView)client).UDPClient; udpClient = ((LLClientView)client).UDPClient;
if (!udpClient.IsConnected) if (!udpClient.IsConnected)
{
// m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet for a unConnected client in " + m_scene.RegionInfo.RegionName);
return; return;
}
#endregion Packet to Client Mapping #endregion Packet to Client Mapping

View File

@ -585,12 +585,12 @@ namespace OpenSim.Region.Framework.Scenes
protected internal void AddPhysicalPrim(int number) protected internal void AddPhysicalPrim(int number)
{ {
m_physicalPrim++; m_physicalPrim += number;
} }
protected internal void RemovePhysicalPrim(int number) protected internal void RemovePhysicalPrim(int number)
{ {
m_physicalPrim--; m_physicalPrim -= number;
} }
protected internal void AddToScriptLPS(int number) protected internal void AddToScriptLPS(int number)

View File

@ -631,6 +631,14 @@ namespace OpenSim.Region.Framework.Scenes
if (triggerScriptEvent) if (triggerScriptEvent)
part.TriggerScriptChangedEvent(Changed.POSITION); part.TriggerScriptChangedEvent(Changed.POSITION);
} }
/*
This seems not needed and should not be needed:
sp absolute position depends on sit part absolute position fixed above.
sp ParentPosition is not used anywhere.
Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it
Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature.
if (!m_dupeInProgress) if (!m_dupeInProgress)
{ {
foreach (ScenePresence av in m_linkedAvatars) foreach (ScenePresence av in m_linkedAvatars)
@ -640,12 +648,12 @@ namespace OpenSim.Region.Framework.Scenes
{ {
Vector3 offset = p.GetWorldPosition() - av.ParentPosition; Vector3 offset = p.GetWorldPosition() - av.ParentPosition;
av.AbsolutePosition += offset; av.AbsolutePosition += offset;
av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition // av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition
av.SendAvatarDataToAllAgents(); av.SendAvatarDataToAllAgents();
} }
} }
} }
*/
//if (m_rootPart.PhysActor != null) //if (m_rootPart.PhysActor != null)
//{ //{
//m_rootPart.PhysActor.Position = //m_rootPart.PhysActor.Position =
@ -676,8 +684,8 @@ namespace OpenSim.Region.Framework.Scenes
if (agent.ParentUUID != UUID.Zero) if (agent.ParentUUID != UUID.Zero)
{ {
agent.ParentPart = null; agent.ParentPart = null;
agent.ParentPosition = Vector3.Zero; // agent.ParentPosition = Vector3.Zero;
// agent.ParentUUID = UUID.Zero; // agent.ParentUUID = UUID.Zero;
} }
} }
@ -3752,7 +3760,7 @@ namespace OpenSim.Region.Framework.Scenes
else else
// ugly rotation update of all parts // ugly rotation update of all parts
{ {
group.AbsolutePosition = AbsolutePosition; group.ResetChildPrimPhysicsPositions();
} }
} }

View File

@ -4496,7 +4496,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (pa != null) if (pa != null)
{ {
ParentGroup.Scene.RemovePhysicalPrim(1); if(wasUsingPhysics)
ParentGroup.Scene.RemovePhysicalPrim(1);
RemoveFromPhysics(); RemoveFromPhysics();
} }
@ -4513,38 +4514,37 @@ namespace OpenSim.Region.Framework.Scenes
{ {
AddToPhysics(UsePhysics, SetPhantom, building, false); AddToPhysics(UsePhysics, SetPhantom, building, false);
pa = PhysActor; pa = PhysActor;
/* /*
if (pa != null) if (pa != null)
{ {
if ( if (
// ((AggregateScriptEvents & scriptEvents.collision) != 0) || // ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
(CollisionSound != UUID.Zero) (CollisionSound != UUID.Zero)
) )
{ {
pa.OnCollisionUpdate += PhysicsCollision; pa.OnCollisionUpdate += PhysicsCollision;
pa.SubscribeEvents(1000); pa.SubscribeEvents(1000);
} }
} }
*/ */
} }
else // it already has a physical representation else // it already has a physical representation
{ {
DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
/* moved into DoPhysicsPropertyUpdate /* moved into DoPhysicsPropertyUpdate
if(VolumeDetectActive) if(VolumeDetectActive)
pa.SetVolumeDetect(1); pa.SetVolumeDetect(1);
else else
pa.SetVolumeDetect(0); pa.SetVolumeDetect(0);
*/ */
if (pa.Building != building) if (pa.Building != building)
pa.Building = building; pa.Building = building;

View File

@ -433,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes
get { return (IClientCore)ControllingClient; } get { return (IClientCore)ControllingClient; }
} }
public Vector3 ParentPosition { get; set; } // public Vector3 ParentPosition { get; set; }
/// <summary> /// <summary>
/// Position of this avatar relative to the region the avatar is in /// Position of this avatar relative to the region the avatar is in
@ -491,7 +491,7 @@ namespace OpenSim.Region.Framework.Scenes
if (ParentID == 0) if (ParentID == 0)
{ {
m_pos = value; m_pos = value;
ParentPosition = Vector3.Zero; // ParentPosition = Vector3.Zero;
} }
//m_log.DebugFormat( //m_log.DebugFormat(
@ -857,11 +857,12 @@ namespace OpenSim.Region.Framework.Scenes
part.ParentGroup.AddAvatar(UUID); part.ParentGroup.AddAvatar(UUID);
if (part.SitTargetPosition != Vector3.Zero) if (part.SitTargetPosition != Vector3.Zero)
part.SitTargetAvatar = UUID; part.SitTargetAvatar = UUID;
ParentPosition = part.GetWorldPosition(); // ParentPosition = part.GetWorldPosition();
ParentID = part.LocalId; ParentID = part.LocalId;
ParentPart = part; ParentPart = part;
m_pos = m_prevSitOffset; m_pos = m_prevSitOffset;
pos = ParentPosition; // pos = ParentPosition;
pos = part.GetWorldPosition();
} }
ParentUUID = UUID.Zero; ParentUUID = UUID.Zero;
@ -1933,11 +1934,12 @@ namespace OpenSim.Region.Framework.Scenes
part.SitTargetAvatar = UUID.Zero; part.SitTargetAvatar = UUID.Zero;
part.ParentGroup.DeleteAvatar(UUID); part.ParentGroup.DeleteAvatar(UUID);
ParentPosition = part.GetWorldPosition(); // ParentPosition = part.GetWorldPosition();
ControllingClient.SendClearFollowCamProperties(part.ParentUUID); ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
ParentPosition = Vector3.Zero; // ParentPosition = Vector3.Zero;
m_pos += part.GetWorldPosition() + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
ParentID = 0; ParentID = 0;
ParentPart = null; ParentPart = null;
@ -2388,13 +2390,13 @@ namespace OpenSim.Region.Framework.Scenes
// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset;
Rotation = sitTargetOrient; Rotation = sitTargetOrient;
ParentPosition = part.AbsolutePosition; // ParentPosition = part.AbsolutePosition;
part.ParentGroup.AddAvatar(UUID); part.ParentGroup.AddAvatar(UUID);
} }
else else
{ {
m_pos -= part.AbsolutePosition; m_pos -= part.AbsolutePosition;
ParentPosition = part.AbsolutePosition; // ParentPosition = part.AbsolutePosition;
part.ParentGroup.AddAvatar(UUID); part.ParentGroup.AddAvatar(UUID);
// m_log.DebugFormat( // m_log.DebugFormat(
@ -3568,7 +3570,8 @@ namespace OpenSim.Region.Framework.Scenes
// m_reprioritizationTimer.Dispose(); // m_reprioritizationTimer.Dispose();
RemoveFromPhysicalScene(); RemoveFromPhysicalScene();
Animator.Close(); if(Animator != null)
Animator.Close();
Animator = null; Animator = null;
} }

View File

@ -660,18 +660,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
double x,y,z,s; double x,y,z,s;
v.x *= 0.5;
v.y *= 0.5;
v.z *= 0.5;
double c1 = Math.Cos(v.x);
double c2 = Math.Cos(v.y);
double c1c2 = c1 * c2;
double s1 = Math.Sin(v.x);
double s2 = Math.Sin(v.y);
double s1s2 = s1 * s2;
double c1s2 = c1 * s2;
double s1c2 = s1 * c2;
double c3 = Math.Cos(v.z);
double s3 = Math.Sin(v.z);
double c1 = Math.Cos(v.x * 0.5); x = s1c2 * c3 + c1s2 * s3;
double c2 = Math.Cos(v.y * 0.5); y = c1s2 * c3 - s1c2 * s3;
double c3 = Math.Cos(v.z * 0.5); z = s1s2 * c3 + c1c2 * s3;
double s1 = Math.Sin(v.x * 0.5); s = c1c2 * c3 - s1s2 * s3;
double s2 = Math.Sin(v.y * 0.5);
double s3 = Math.Sin(v.z * 0.5);
x = s1 * c2 * c3 + c1 * s2 * s3;
y = c1 * s2 * c3 - s1 * c2 * s3;
z = s1 * s2 * c3 + c1 * c2 * s3;
s = c1 * c2 * c3 - s1 * s2 * s3;
return new LSL_Rotation(x, y, z, s); return new LSL_Rotation(x, y, z, s);
} }
@ -1911,11 +1917,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Primitive.TextureEntry tex = part.Shape.Textures; Primitive.TextureEntry tex = part.Shape.Textures;
Color4 texcolor; Color4 texcolor;
LSL_Vector rgb = new LSL_Vector(); LSL_Vector rgb = new LSL_Vector();
int nsides = GetNumberOfSides(part);
if (face == ScriptBaseClass.ALL_SIDES) if (face == ScriptBaseClass.ALL_SIDES)
{ {
int i; int i;
for (i = 0; i < nsides; i++)
for (i = 0 ; i < GetNumberOfSides(part); i++)
{ {
texcolor = tex.GetFace((uint)i).RGBA; texcolor = tex.GetFace((uint)i).RGBA;
rgb.x += texcolor.R; rgb.x += texcolor.R;
@ -1923,13 +1930,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
rgb.z += texcolor.B; rgb.z += texcolor.B;
} }
rgb.x /= (float)GetNumberOfSides(part); float invnsides = 1.0f / (float)nsides;
rgb.y /= (float)GetNumberOfSides(part);
rgb.z /= (float)GetNumberOfSides(part); rgb.x *= invnsides;
rgb.y *= invnsides;
rgb.z *= invnsides;
return rgb; return rgb;
} }
if (face >= 0 && face < GetNumberOfSides(part)) if (face >= 0 && face < nsides)
{ {
texcolor = tex.GetFace((uint)face).RGBA; texcolor = tex.GetFace((uint)face).RGBA;
rgb.x = texcolor.R; rgb.x = texcolor.R;
@ -2328,15 +2337,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// (root prim). ParentID may be nonzero in attachments and // (root prim). ParentID may be nonzero in attachments and
// using it would cause attachments and HUDs to rotate // using it would cause attachments and HUDs to rotate
// to the wrong positions. // to the wrong positions.
SetRot(m_host, Rot2Quaternion(rot)); SetRot(m_host, Rot2Quaternion(rot));
} }
else else
{ {
// we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
SceneObjectPart rootPart = m_host.ParentGroup.RootPart; SceneObjectPart rootPart;
if (rootPart != null) // better safe than sorry if (m_host.ParentGroup != null) // better safe than sorry
{ {
SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); rootPart = m_host.ParentGroup.RootPart;
if (rootPart != null)
SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot));
} }
} }
@ -2346,6 +2358,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetLocalRot(LSL_Rotation rot) public void llSetLocalRot(LSL_Rotation rot)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
SetRot(m_host, Rot2Quaternion(rot)); SetRot(m_host, Rot2Quaternion(rot));
ScriptSleep(200); ScriptSleep(200);
} }
@ -2355,25 +2368,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
return; return;
part.UpdateRotation(rot); bool isroot = (part == part.ParentGroup.RootPart);
// Update rotation does not move the object in the physics scene if it's a linkset. bool isphys;
//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type
// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
// So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line
// is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt
// It's perfectly okay when the object is not an active physical body though.
// So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against
// but only if the object is not physial and active. This is important for rotating doors.
// without the absoluteposition = absoluteposition happening, the doors do not move in the physics
// scene
PhysicsActor pa = part.PhysActor; PhysicsActor pa = part.PhysActor;
if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) // keep using physactor ideia of isphysical
// it should be SOP ideia of that
// not much of a issue with ubitODE
if (pa != null && pa.IsPhysical)
isphys = true;
else
isphys = false;
// SL doesn't let scripts rotate root of physical linksets
if (isroot && isphys)
return;
part.UpdateRotation(rot);
// Update rotation does not move the object in the physics engine if it's a non physical linkset
// so do a nasty update of parts positions if is a root part rotation
if (isroot && pa != null) // with if above implies non physical root part
{ {
part.ParentGroup.ResetChildPrimPhysicsPositions(); part.ParentGroup.ResetChildPrimPhysicsPositions();
} }
else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part
{
List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars();
if (sittingavas.Count > 0)
{
foreach (ScenePresence av in sittingavas)
{
if (isroot || part.LocalId == av.ParentID)
av.SendTerseUpdateToAllClients();
}
}
}
} }
/// <summary> /// <summary>
@ -2422,7 +2453,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Rotation llGetLocalRot() public LSL_Rotation llGetLocalRot()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); Quaternion rot = m_host.RotationOffset;
return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
} }
public void llSetForce(LSL_Vector force, int local) public void llSetForce(LSL_Vector force, int local)
@ -7994,7 +8026,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Quaternion srot = sitpart.RotationOffset; Quaternion srot = sitpart.RotationOffset;
rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation
av.Rotation = rot; av.Rotation = rot;
av.SendAvatarDataToAllAgents(); // av.SendAvatarDataToAllAgents();
av.SendTerseUpdateToAllClients();
} }
break; break;
@ -8014,7 +8047,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation
} }
av.Rotation = rot; av.Rotation = rot;
av.SendAvatarDataToAllAgents(); // av.SendAvatarDataToAllAgents();
av.SendTerseUpdateToAllClients();
} }
break; break;
@ -8109,7 +8143,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
positionChanged = false; positionChanged = false;
av.OffsetPosition = finalPos; av.OffsetPosition = finalPos;
av.SendAvatarDataToAllAgents(); // av.SendAvatarDataToAllAgents();
av.SendTerseUpdateToAllClients();
} }
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
@ -8125,7 +8160,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (positionChanged) if (positionChanged)
{ {
av.OffsetPosition = finalPos; av.OffsetPosition = finalPos;
av.SendAvatarDataToAllAgents(); // av.SendAvatarDataToAllAgents();
av.SendTerseUpdateToAllClients();
positionChanged = false; positionChanged = false;
} }
} }
@ -8534,6 +8570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_ROT_LOCAL: case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
if (remain < 1) if (remain < 1)
return; return;
LSL_Rotation lr = rules.GetQuaternionItem(idx++); LSL_Rotation lr = rules.GetQuaternionItem(idx++);
SetRot(part, Rot2Quaternion(lr)); SetRot(part, Rot2Quaternion(lr));
break; break;
@ -12577,7 +12614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
if (false)// World.SuportsRayCastFiltered()) if (World.SuportsRayCastFiltered())
{ {
if (dist == 0) if (dist == 0)
return list; return list;