Implementation of LSL_Integer llScaleByFactor(double scaling_factor)

Signed-off-by: Mandarinka Tasty <mandarinka.tasty@gmail.com>
Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
melanie
Mandarinka Tasty 2016-11-24 23:40:20 +01:00 committed by UbitUmarov
parent f9b62b5680
commit e45245d267
3 changed files with 52 additions and 0 deletions

View File

@ -1803,6 +1803,52 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return 0;
}
public LSL_Integer llScaleByFactor(double scaling_factor)
{
m_host.AddScriptLPS(1);
SceneObjectGroup group = m_host.ParentGroup;
if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical)
return ScriptBaseClass.FALSE;
if (group.RootPart.KeyframeMotion != null)
return ScriptBaseClass.FALSE;
List<SceneObjectPart> prims = GetLinkParts(ScriptBaseClass.LINK_SET);
if (prims.Count > 0)
{
foreach (SceneObjectPart prim in prims)
{
LSL_Vector size = new LSL_Vector(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);
LSL_Vector new_size = new LSL_Vector(scaling_factor * size);
new_size.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, new_size.x));
new_size.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, new_size.y));
new_size.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, new_size.z));
if (new_size.x != scaling_factor * size.x || new_size.y != scaling_factor * size.y || new_size.z != scaling_factor * size.z)
return ScriptBaseClass.FALSE;
LSL_Vector position = new LSL_Vector(GetPartLocalPos(prim));
if (!prim.IsRoot)
{
position = GetSetPosTarget(prim, scaling_factor * position, position, true);
prim.OffsetPosition = position;
prim.ScheduleTerseUpdate();
}
SetScale(prim, new_size);
}
return ScriptBaseClass.TRUE;
}
else
{
return ScriptBaseClass.FALSE;
}
}
public void llSetScale(LSL_Vector scale)
{
m_host.AddScriptLPS(1);

View File

@ -326,6 +326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Integer llRound(double f);
LSL_Integer llSameGroup(string agent);
void llSay(int channelID, string text);
LSL_Integer llScaleByFactor(double scaling_factor);
void llScaleTexture(double u, double v, int face);
LSL_Integer llScriptDanger(LSL_Vector pos);
void llScriptProfiler(LSL_Integer flag);

View File

@ -1465,6 +1465,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_LSL_Functions.llSay(channelID, text);
}
public LSL_Integer llScaleByFactor(double scaling_factor)
{
return m_LSL_Functions.llScaleByFactor(scaling_factor);
}
public void llScaleTexture(double u, double v, int face)
{
m_LSL_Functions.llScaleTexture(u, v, face);