mantis 8634: add osSetSitActiveRange(float range) , osSetStandTarget(vector feetAproxPosition) and respective get functions. range <0 disables sits on the prim, = 0 uses region default,feetAproxPosition is in prim local frame. <0,0,0> disables it. Still no persistance. feedback required!
parent
8db60ba3aa
commit
7adaede14a
|
@ -1257,6 +1257,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
set { m_sitTargetOrientation = value; }
|
set { m_sitTargetOrientation = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float SitActiveRange { get; set;}
|
||||||
|
public Vector3 StandOffset { get; set;}
|
||||||
|
|
||||||
public bool Stopped
|
public bool Stopped
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
|
|
|
@ -3262,7 +3262,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
standRotation = standRotation * m_bodyRot;
|
standRotation = standRotation * m_bodyRot;
|
||||||
m_bodyRot = standRotation;
|
m_bodyRot = standRotation;
|
||||||
|
|
||||||
Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W);
|
Quaternion standRotationZ;
|
||||||
|
Vector3 adjustmentForSitPose = part.StandOffset;
|
||||||
|
if (adjustmentForSitPose.X == 0 &&
|
||||||
|
adjustmentForSitPose.Y == 0 &&
|
||||||
|
adjustmentForSitPose.Z == 0)
|
||||||
|
{
|
||||||
|
standRotationZ = new Quaternion(0, 0, standRotation.Z, standRotation.W);
|
||||||
float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z;
|
float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z;
|
||||||
if (t > 0)
|
if (t > 0)
|
||||||
{
|
{
|
||||||
|
@ -3275,8 +3281,33 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
standRotationZ.W = 1.0f;
|
standRotationZ.W = 1.0f;
|
||||||
standRotationZ.Z = 0f;
|
standRotationZ.Z = 0f;
|
||||||
}
|
}
|
||||||
|
adjustmentForSitPose = new Vector3(0.65f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sitWorldPosition = part.GetWorldPosition();
|
||||||
|
|
||||||
Vector3 adjustmentForSitPose = new Vector3(0.65f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ;
|
standRotation = part.GetWorldRotation();
|
||||||
|
standRotationZ = new Quaternion(0, 0, standRotation.Z, standRotation.W);
|
||||||
|
float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z;
|
||||||
|
if (t > 0)
|
||||||
|
{
|
||||||
|
t = 1.0f / (float)Math.Sqrt(t);
|
||||||
|
standRotationZ.W *= t;
|
||||||
|
standRotationZ.Z *= t;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
standRotationZ.W = 1.0f;
|
||||||
|
standRotationZ.Z = 0f;
|
||||||
|
}
|
||||||
|
adjustmentForSitPose *= standRotationZ;
|
||||||
|
|
||||||
|
if (Appearance != null && Appearance.AvatarHeight > 0)
|
||||||
|
adjustmentForSitPose.Z += 0.5f * Appearance.AvatarHeight + .1f;
|
||||||
|
else
|
||||||
|
adjustmentForSitPose.Z += .9f;
|
||||||
|
}
|
||||||
|
|
||||||
m_pos = sitWorldPosition + adjustmentForSitPose;
|
m_pos = sitWorldPosition + adjustmentForSitPose;
|
||||||
}
|
}
|
||||||
|
@ -3325,7 +3356,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
//look for prims with explicit sit targets that are available
|
//look for prims with explicit sit targets that are available
|
||||||
foreach (SceneObjectPart part in partArray)
|
foreach (SceneObjectPart part in partArray)
|
||||||
{
|
{
|
||||||
if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero)
|
if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero && part.SitActiveRange > 0)
|
||||||
{
|
{
|
||||||
//switch the target to this prim
|
//switch the target to this prim
|
||||||
return part;
|
return part;
|
||||||
|
@ -3346,6 +3377,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (part == null)
|
if (part == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
float range = part.SitActiveRange;
|
||||||
|
if (range < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector3 pos = part.AbsolutePosition + offset;
|
||||||
|
if (range > 1e-5f)
|
||||||
|
{
|
||||||
|
if (Vector3.DistanceSquared(AbsolutePosition, pos) > range * range)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (PhysicsActor != null)
|
if (PhysicsActor != null)
|
||||||
m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
|
m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f;
|
||||||
|
|
||||||
|
@ -3359,9 +3401,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (PhysicsSit(part,offset)) // physics engine
|
if (PhysicsSit(part,offset)) // physics engine
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector3 pos = part.AbsolutePosition + offset;
|
|
||||||
if (Vector3.DistanceSquared(AbsolutePosition, pos) > 100)
|
|
||||||
return;
|
|
||||||
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
|
AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5674,5 +5674,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
return 3;
|
return 3;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void osSetSitActiveRange(LSL_Float v)
|
||||||
|
{
|
||||||
|
if (v > 128f)
|
||||||
|
v = 128f;
|
||||||
|
m_host.SitActiveRange = (float)v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LSL_Float osGetSitActiveRange()
|
||||||
|
{
|
||||||
|
return m_host.SitActiveRange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void osSetStandTarget(LSL_Vector v)
|
||||||
|
{
|
||||||
|
// todo add limits ?
|
||||||
|
m_host.StandOffset = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LSL_Vector osGetStandTarget()
|
||||||
|
{
|
||||||
|
return m_host.StandOffset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -559,5 +559,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||||
|
|
||||||
void osResetAllScripts(LSL_Integer AllLinkset);
|
void osResetAllScripts(LSL_Integer AllLinkset);
|
||||||
LSL_Integer osIsNotValidNumber(LSL_Float v);
|
LSL_Integer osIsNotValidNumber(LSL_Float v);
|
||||||
|
|
||||||
|
void osSetSitActiveRange(LSL_Float v);
|
||||||
|
LSL_Float osGetSitActiveRange();
|
||||||
|
void osSetStandTarget(vector v);
|
||||||
|
vector osGetStandTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
public partial class ScriptBaseClass
|
public partial class ScriptBaseClass
|
||||||
{
|
{
|
||||||
// SCRIPTS CONSTANTS
|
// SCRIPTS CONSTANTS
|
||||||
public static readonly LSLInteger OS_APIVERSION = 10;
|
public static readonly LSLInteger OS_APIVERSION = 11;
|
||||||
|
|
||||||
public static readonly LSLInteger TRUE = 1;
|
public static readonly LSLInteger TRUE = 1;
|
||||||
public static readonly LSLInteger FALSE = 0;
|
public static readonly LSLInteger FALSE = 0;
|
||||||
|
|
|
@ -1421,5 +1421,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
{
|
{
|
||||||
return m_OSSL_Functions.osIsNotValidNumber(v);
|
return m_OSSL_Functions.osIsNotValidNumber(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void osSetSitActiveRange(LSL_Float v)
|
||||||
|
{
|
||||||
|
m_OSSL_Functions.osSetSitActiveRange(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LSL_Float osGetSitActiveRange()
|
||||||
|
{
|
||||||
|
return m_OSSL_Functions.osGetSitActiveRange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void osSetStandTarget(vector v)
|
||||||
|
{
|
||||||
|
m_OSSL_Functions.osSetStandTarget(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
public vector osGetStandTarget()
|
||||||
|
|
||||||
|
{
|
||||||
|
return m_OSSL_Functions.osGetStandTarget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue