First attempt at mult-sit on large single prims.
parent
32c464ad1f
commit
5dedacca3c
|
@ -117,6 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public Vector4 CollisionPlane = Vector4.UnitW;
|
public Vector4 CollisionPlane = Vector4.UnitW;
|
||||||
|
|
||||||
private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation
|
private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation
|
||||||
|
private Vector3 m_avUnscriptedSitPos; // for non-scripted prims
|
||||||
private Vector3 m_lastPosition;
|
private Vector3 m_lastPosition;
|
||||||
private Quaternion m_lastRotation;
|
private Quaternion m_lastRotation;
|
||||||
private Vector3 m_lastVelocity;
|
private Vector3 m_lastVelocity;
|
||||||
|
@ -1644,9 +1645,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
AddToPhysicalScene(false);
|
AddToPhysicalScene(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight);
|
m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight);
|
||||||
m_parentPosition = Vector3.Zero;
|
m_parentPosition = Vector3.Zero;
|
||||||
|
//Console.WriteLine("Stand Pos {0}", m_pos);
|
||||||
|
|
||||||
m_parentID = 0;
|
m_parentID = 0;
|
||||||
SendFullUpdateToAllClients();
|
SendFullUpdateToAllClients();
|
||||||
|
@ -1740,21 +1741,37 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied +
|
//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied +
|
||||||
// " TargSet=" + SitTargetisSet);
|
// " TargSet=" + SitTargetisSet);
|
||||||
|
// Sit analysis rewritten by KF 091125
|
||||||
if (SitTargetisSet && SitTargetUnOccupied)
|
if (SitTargetisSet) // scipted sit
|
||||||
{
|
{
|
||||||
part.SetAvatarOnSitTarget(UUID);
|
if (SitTargetUnOccupied)
|
||||||
offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z);
|
{
|
||||||
sitOrientation = avSitOrientation;
|
part.SetAvatarOnSitTarget(UUID); // set that Av will be on it
|
||||||
autopilot = false; // Jump direct to scripted llSitPos()
|
offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one
|
||||||
}
|
sitOrientation = avSitOrientation; // Change rotatione to the scripted one
|
||||||
|
autopilot = false; // Jump direct to scripted llSitPos()
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
}
|
||||||
|
else // Not Scripted
|
||||||
|
{
|
||||||
|
if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim
|
||||||
|
{
|
||||||
|
Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation());
|
||||||
|
m_avUnscriptedSitPos = offset * partIRot; // sit where clicked
|
||||||
|
pos = part.AbsolutePosition + (offset * partIRot);
|
||||||
|
}
|
||||||
|
else // small prim
|
||||||
|
{
|
||||||
|
if (SitTargetUnOccupied)
|
||||||
|
{
|
||||||
|
m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center
|
||||||
|
pos = part.AbsolutePosition;
|
||||||
|
}
|
||||||
|
else return; // occupied small
|
||||||
|
} // end large/small
|
||||||
|
} // end Scripted/not
|
||||||
|
|
||||||
pos = part.AbsolutePosition + offset; // Region position where clicked
|
|
||||||
//if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1)
|
|
||||||
//{
|
|
||||||
// offset = pos;
|
|
||||||
//autopilot = false;
|
|
||||||
//}
|
|
||||||
if (m_physicsActor != null)
|
if (m_physicsActor != null)
|
||||||
{
|
{
|
||||||
// If we're not using the client autopilot, we're immediately warping the avatar to the location
|
// If we're not using the client autopilot, we're immediately warping the avatar to the location
|
||||||
|
@ -1887,8 +1904,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
// Non-scripted sit by Kitto Flora 21Nov09
|
// Non-scripted sit by Kitto Flora 21Nov09
|
||||||
// Calculate angle of line from prim to Av
|
// Calculate angle of line from prim to Av
|
||||||
float y_diff = (m_avInitialPos.Y - part.AbsolutePosition.Y);
|
Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos;
|
||||||
float x_diff = ( m_avInitialPos.X - part.AbsolutePosition.X);
|
float y_diff = (m_avInitialPos.Y - sitTargetPos.Y);
|
||||||
|
float x_diff = ( m_avInitialPos.X - sitTargetPos.X);
|
||||||
if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0
|
if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0
|
||||||
if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0
|
if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0
|
||||||
float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff);
|
float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff);
|
||||||
|
@ -1896,23 +1914,30 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'.
|
// NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'.
|
||||||
// Av sits at world euler <0,0, z>, translated by part rotation
|
// Av sits at world euler <0,0, z>, translated by part rotation
|
||||||
m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click
|
m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click
|
||||||
m_pos = new Vector3(0f, 0f, 0.05f) +
|
|
||||||
(new Vector3(0.0f, 0f, 0.625f) * partIRot) +
|
|
||||||
(new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); // sit at center of prim
|
|
||||||
m_parentPosition = part.AbsolutePosition;
|
m_parentPosition = part.AbsolutePosition;
|
||||||
//Set up raytrace to find top surface of prim
|
if(m_avUnscriptedSitPos != Vector3.Zero)
|
||||||
Vector3 size = part.Scale;
|
{ // sit where clicked on big prim
|
||||||
float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
|
m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot);
|
||||||
Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
|
}
|
||||||
Vector3 down = new Vector3(0f, 0f, -1f);
|
else
|
||||||
m_scene.PhysicsScene.RaycastWorld(
|
{ // sit at center of small prim
|
||||||
start, // Vector3 position,
|
m_pos = new Vector3(0f, 0f, 0.05f) +
|
||||||
down, // Vector3 direction,
|
(new Vector3(0.0f, 0f, 0.625f) * partIRot) +
|
||||||
mag, // float length,
|
(new Vector3(0.25f, 0f, 0.0f) * m_bodyRot);
|
||||||
SitAltitudeCallback); // retMethod
|
//Set up raytrace to find top surface of prim
|
||||||
}
|
Vector3 size = part.Scale;
|
||||||
|
float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z));
|
||||||
|
Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag);
|
||||||
|
Vector3 down = new Vector3(0f, 0f, -1f);
|
||||||
|
m_scene.PhysicsScene.RaycastWorld(
|
||||||
|
start, // Vector3 position,
|
||||||
|
down, // Vector3 direction,
|
||||||
|
mag, // float length,
|
||||||
|
SitAltitudeCallback); // retMethod
|
||||||
|
} // end small/big
|
||||||
|
} // end scripted/not
|
||||||
}
|
}
|
||||||
else
|
else // no Av
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue