more changes on lookAt and RotLookAt; do something in attachments
parent
a9e58d6175
commit
e37c4e878c
|
@ -329,6 +329,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
get { return (RootPart.Flags & PrimFlags.Physics) != 0; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Is this scene object temporary?
|
||||
/// </summary>
|
||||
|
@ -2536,6 +2537,58 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void RotLookAt(Quaternion target, float strength, float damping)
|
||||
{
|
||||
if(IsDeleted)
|
||||
return;
|
||||
|
||||
// non physical is handle in LSL api
|
||||
if(!UsesPhysics || IsAttachment)
|
||||
return;
|
||||
|
||||
SceneObjectPart rootpart = m_rootPart;
|
||||
if (rootpart != null)
|
||||
{
|
||||
/* physics still doesnt suport this
|
||||
if (rootpart.PhysActor != null)
|
||||
{
|
||||
rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W);
|
||||
rootpart.PhysActor.APIDStrength = strength;
|
||||
rootpart.PhysActor.APIDDamping = damping;
|
||||
rootpart.PhysActor.APIDActive = true;
|
||||
}
|
||||
*/
|
||||
// so do it in rootpart
|
||||
rootpart.RotLookAt(target, strength, damping);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartLookAt(Quaternion target, float strength, float damping)
|
||||
{
|
||||
if(IsDeleted)
|
||||
return;
|
||||
|
||||
// non physical is done by LSL APi
|
||||
if(!UsesPhysics || IsAttachment)
|
||||
return;
|
||||
|
||||
if (m_rootPart != null)
|
||||
m_rootPart.RotLookAt(target, strength, damping);
|
||||
}
|
||||
|
||||
public void StopLookAt()
|
||||
{
|
||||
SceneObjectPart rootpart = m_rootPart;
|
||||
if (rootpart != null)
|
||||
{
|
||||
if (rootpart.PhysActor != null)
|
||||
{
|
||||
rootpart.PhysActor.APIDActive = false;
|
||||
}
|
||||
|
||||
rootpart.StopLookAt();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
|
||||
/// </summary>
|
||||
|
|
|
@ -3091,25 +3091,20 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void RotLookAt(Quaternion target, float strength, float damping)
|
||||
{
|
||||
// non physical is done on LSL
|
||||
// physical is a rootpart thing
|
||||
if(ParentGroup.IsDeleted)
|
||||
return;
|
||||
|
||||
if(ParentGroup.RootPart != this)
|
||||
ParentGroup.RootPart.RotLookAt(target, strength, damping);
|
||||
// for now we only handle physics case
|
||||
if(!ParentGroup.UsesPhysics || ParentGroup.IsAttachment)
|
||||
return;
|
||||
|
||||
if (ParentGroup.IsAttachment)
|
||||
// physical is SOG
|
||||
if(ParentGroup.RootPart != this)
|
||||
{
|
||||
/*
|
||||
ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
|
||||
if (avatar != null)
|
||||
{
|
||||
Rotate the Av?
|
||||
} */
|
||||
ParentGroup.RotLookAt(target, strength, damping);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
APIDDamp = damping;
|
||||
APIDStrength = strength;
|
||||
APIDTarget = target;
|
||||
|
@ -3121,7 +3116,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
|
||||
APIDActive = true;
|
||||
}
|
||||
|
||||
// Necessary to get the lookat deltas applied
|
||||
ParentGroup.QueueForUpdateCheck();
|
||||
|
@ -3129,14 +3123,17 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void StartLookAt(Quaternion target, float strength, float damping)
|
||||
{
|
||||
// non physical is done on LSL
|
||||
// physical is a rootpart thing
|
||||
if(ParentGroup.IsDeleted)
|
||||
return;
|
||||
|
||||
if(ParentGroup.RootPart != this)
|
||||
ParentGroup.RootPart.RotLookAt(target, strength, damping);
|
||||
// non physical is done on LSL
|
||||
if(ParentGroup.IsAttachment || !ParentGroup.UsesPhysics)
|
||||
return;
|
||||
|
||||
// physical is SOG
|
||||
if(ParentGroup.RootPart != this)
|
||||
ParentGroup.RotLookAt(target, strength, damping);
|
||||
else
|
||||
RotLookAt(target,strength,damping);
|
||||
}
|
||||
|
||||
|
@ -3145,9 +3142,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if(ParentGroup.IsDeleted)
|
||||
return;
|
||||
|
||||
if(ParentGroup.RootPart != this)
|
||||
ParentGroup.RootPart.StopLookAt();
|
||||
if(ParentGroup.RootPart != this && ParentGroup.UsesPhysics)
|
||||
ParentGroup.StopLookAt();
|
||||
|
||||
// just in case do this always
|
||||
if(APIDActive)
|
||||
AngularVelocity = Vector3.Zero;
|
||||
|
||||
|
|
|
@ -3569,7 +3569,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
// and rotate so Z points to target with X below horizont
|
||||
LSL_Rotation rot = new LSL_Rotation(0.0, 0.707107, 0.0, 0.707107) * llAxes2Rot(dir, left, up);
|
||||
|
||||
if (m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
|
||||
SceneObjectGroup sog = m_host.ParentGroup;
|
||||
if(sog == null || sog.IsDeleted)
|
||||
return;
|
||||
|
||||
if (!sog.UsesPhysics || sog.IsAttachment)
|
||||
{
|
||||
// Do nothing if either value is 0 (this has been checked in SL)
|
||||
if (strength <= 0.0 || damping <= 0.0)
|
||||
|
@ -3585,7 +3589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return;
|
||||
}
|
||||
|
||||
m_host.StartLookAt(rot, (float)strength, (float)damping);
|
||||
sog.StartLookAt(rot, (float)strength, (float)damping);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3991,15 +3995,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
// Per discussion with Melanie, for non-physical objects llLookAt appears to simply
|
||||
// set the rotation of the object, copy that behavior
|
||||
PhysicsActor pa = m_host.PhysActor;
|
||||
SceneObjectGroup sog = m_host.ParentGroup;
|
||||
if(sog == null || sog.IsDeleted)
|
||||
return;
|
||||
|
||||
if (strength == 0 || pa == null || !pa.IsPhysical)
|
||||
if (strength == 0 || !sog.UsesPhysics || sog.IsAttachment)
|
||||
{
|
||||
llSetLocalRot(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_host.RotLookAt(target, (float)strength, (float)damping);
|
||||
sog.RotLookAt(target, (float)strength, (float)damping);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue