add llGetMaxScaleFactor and llGetMinScaleFactor
parent
b82a41d260
commit
935510d879
|
@ -4258,6 +4258,83 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return true;
|
||||
}
|
||||
|
||||
public float GetMaxGroupResizeScale()
|
||||
{
|
||||
if (Scene == null || IsDeleted || inTransit)
|
||||
return 1.0f;
|
||||
|
||||
float maxsize = Scene.m_maxNonphys;
|
||||
PhysicsActor pa = m_rootPart.PhysActor;
|
||||
// assuming physics is more restrictive
|
||||
if (pa != null && pa.IsPhysical)
|
||||
maxsize = Scene.m_maxPhys;
|
||||
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
float larger = float.MinValue;
|
||||
|
||||
for(int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
SceneObjectPart obPart = parts[i];
|
||||
Vector3 oldSize = new Vector3(obPart.Scale);
|
||||
if(larger < oldSize.X)
|
||||
larger = oldSize.X;
|
||||
|
||||
if(larger < oldSize.Y)
|
||||
larger = oldSize.Y;
|
||||
|
||||
if(larger < oldSize.Z)
|
||||
larger = oldSize.Z;
|
||||
}
|
||||
|
||||
if(larger >= maxsize)
|
||||
return 1.0f;
|
||||
|
||||
larger += 1e-3f;
|
||||
float fscale = maxsize / larger;
|
||||
|
||||
return fscale;
|
||||
}
|
||||
|
||||
public float GetMinGroupResizeScale()
|
||||
{
|
||||
if (Scene == null || IsDeleted || inTransit)
|
||||
return 1.0f;
|
||||
|
||||
float minsize = Scene.m_minNonphys;
|
||||
PhysicsActor pa = m_rootPart.PhysActor;
|
||||
// assuming physics is more restrictive
|
||||
if (pa != null && pa.IsPhysical)
|
||||
minsize = Scene.m_minPhys;
|
||||
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
float smaller = float.MaxValue;
|
||||
|
||||
for(int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
SceneObjectPart obPart = parts[i];
|
||||
Vector3 oldSize = new Vector3(obPart.Scale);
|
||||
if(smaller > oldSize.X)
|
||||
smaller = oldSize.X;
|
||||
|
||||
if(smaller > oldSize.Y)
|
||||
smaller = oldSize.Y;
|
||||
|
||||
if(smaller > oldSize.Z)
|
||||
smaller = oldSize.Z;
|
||||
}
|
||||
|
||||
if(smaller <= minsize)
|
||||
return 1.0f;
|
||||
|
||||
if(smaller > 2e-3f)
|
||||
smaller -= 1e-3f;
|
||||
float fscale = minsize / smaller;
|
||||
if(fscale < 1e-8f)
|
||||
fscale = 1e-8f;
|
||||
|
||||
return fscale;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Position
|
||||
|
|
|
@ -1828,6 +1828,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return ScriptBaseClass.FALSE;
|
||||
}
|
||||
|
||||
public LSL_Float llGetMaxScaleFactor()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
SceneObjectGroup group = m_host.ParentGroup;
|
||||
|
||||
if (group == null || group.IsDeleted || group.inTransit)
|
||||
return 1.0f;
|
||||
|
||||
return (LSL_Float)group.GetMaxGroupResizeScale();
|
||||
}
|
||||
|
||||
public LSL_Float llGetMinScaleFactor()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
SceneObjectGroup group = m_host.ParentGroup;
|
||||
|
||||
if (group == null || group.IsDeleted || group.inTransit)
|
||||
return 1.0f;
|
||||
|
||||
return (LSL_Float)group.GetMinGroupResizeScale();
|
||||
}
|
||||
|
||||
public void llSetScale(LSL_Vector scale)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
|
|
@ -327,6 +327,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
|||
LSL_Integer llSameGroup(string agent);
|
||||
void llSay(int channelID, string text);
|
||||
LSL_Integer llScaleByFactor(double scaling_factor);
|
||||
LSL_Float llGetMaxScaleFactor();
|
||||
LSL_Float llGetMinScaleFactor();
|
||||
void llScaleTexture(double u, double v, int face);
|
||||
LSL_Integer llScriptDanger(LSL_Vector pos);
|
||||
void llScriptProfiler(LSL_Integer flag);
|
||||
|
|
|
@ -1470,6 +1470,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
return m_LSL_Functions.llScaleByFactor(scaling_factor);
|
||||
}
|
||||
|
||||
public LSL_Float llGetMaxScaleFactor()
|
||||
{
|
||||
return m_LSL_Functions.llGetMaxScaleFactor();
|
||||
}
|
||||
|
||||
public LSL_Float llGetMinScaleFactor()
|
||||
{
|
||||
return m_LSL_Functions.llGetMinScaleFactor();
|
||||
}
|
||||
|
||||
public void llScaleTexture(double u, double v, int face)
|
||||
{
|
||||
m_LSL_Functions.llScaleTexture(u, v, face);
|
||||
|
|
Loading…
Reference in New Issue