Than you, otakup0pe, for a patch to correct llSetPos & friends' behavior

for child prims.
Fixes Mantis #3931
trunk
Melanie Thielker 2009-07-27 23:13:31 +00:00
parent 3038efcc47
commit aec16c2a0a
1 changed files with 24 additions and 14 deletions

View File

@ -1849,15 +1849,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(200); ScriptSleep(200);
} }
// Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
// note linked setpos is capped "differently"
private LSL_Vector SetPosAdjust(LSL_Vector start, LSL_Vector end)
{
if ( llVecDist(start, end) > 10.0f * m_ScriptDistanceFactor ) {
return start + m_ScriptDistanceFactor * 10.0f * llVecNorm(end - start);
} else {
return end;
}
}
protected void SetPos(SceneObjectPart part, LSL_Vector targetPos) protected void SetPos(SceneObjectPart part, LSL_Vector targetPos)
{ {
// Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos) // Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
LSL_Vector currentPos = llGetLocalPos(); LSL_Vector currentPos = llGetLocalPos();
if (llVecDist(currentPos, targetPos) > 10.0f * m_ScriptDistanceFactor)
{
targetPos = currentPos + m_ScriptDistanceFactor * 10.0f * llVecNorm(targetPos - currentPos);
}
float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y); float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true); bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);
@ -1867,22 +1872,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if ((targetPos.z < ground) && disable_underground_movement) if ((targetPos.z < ground) && disable_underground_movement)
targetPos.z = ground; targetPos.z = ground;
part.UpdateOffSet(new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z)); LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos);
} part.UpdateOffSet(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z)); }
else if (part.ParentGroup.RootPart == part) else if (part.ParentGroup.RootPart == part)
{ {
if ((targetPos.z < ground) && disable_underground_movement) if ((targetPos.z < ground) && disable_underground_movement)
targetPos.z = ground; targetPos.z = ground;
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
parent.UpdateGroupPosition(new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z)); LSL_Vector real_vec = SetPosAdjust(currentPos, targetPos);
parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
} }
else else
{ {
part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z); //it's late... i think this is right ?
SceneObjectGroup parent = part.ParentGroup; if ( llVecDist(new LSL_Vector(0,0,0), targetPos) <= 10.0f )
parent.HasGroupChanged = true; {
parent.ScheduleGroupForTerseUpdate(); part.OffsetPosition = new Vector3((float)targetPos.x, (float)targetPos.y, (float)targetPos.z);
} SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate();
}
}
} }
public LSL_Vector llGetPos() public LSL_Vector llGetPos()