mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Implementation of LSL_Integer llScaleByFactor(double scaling_factor)
Signed-off-by: Mandarinka Tasty <mandarinka.tasty@gmail.com> Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
This commit is contained in:
committed by
UbitUmarov
parent
f9b62b5680
commit
e45245d267
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user