add a few more parameters to llGetObjectDetails(); add intger log2(uint)

This commit is contained in:
UbitUmarov
2022-08-23 17:26:09 +01:00
parent 1456f43bc3
commit d545506efc
6 changed files with 110 additions and 11 deletions

View File

@@ -213,6 +213,40 @@ namespace OpenSim.Framework
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
}
// next should be replaced using .net5 system numerics bitoperations log2
// this is just log2 + 1
private static byte[] nBitsLookup =
{
01, 10, 02, 11, 14, 22, 03, 30, 12, 15, 17, 19, 23, 26, 04, 31,
09, 13, 21, 29, 16, 18, 25, 08, 20, 28, 24, 07, 27, 06, 05, 32
};
public static int NumberBits(uint n)
{
n |= (n >> 1);
n |= (n >> 2);
n |= (n >> 4);
n |= (n >> 8);
n |= (n >> 16);
return nBitsLookup[(n * 0x07C4ACDDu) >> 27];
}
private static byte[] intLog2Lookup =
{
00, 09, 01, 10, 13, 21, 02, 29, 11, 14, 16, 18, 22, 25, 03, 30,
08, 12, 20, 28, 15, 17, 24, 07, 19, 27, 23, 06, 26, 05, 04, 31
};
public static int intLog2(uint n)
{
n |= (n >> 1);
n |= (n >> 2);
n |= (n >> 4);
n |= (n >> 8);
n |= (n >> 16);
return intLog2Lookup[(n * 0x07C4ACDDu) >> 27];
}
/// <summary>
/// Linear interpolates B<->C using percent A
/// </summary>

View File

@@ -203,14 +203,15 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
m_primMesher = RenderingLoader.LoadRenderer(renderers[0]);
}
viewWitdh = (int)m_scene.RegionInfo.RegionSizeX;
viewHeight = (int)m_scene.RegionInfo.RegionSizeY;
cameraPos = new Vector3(
(m_scene.RegionInfo.RegionSizeX) * 0.5f,
(m_scene.RegionInfo.RegionSizeY) * 0.5f,
viewWitdh * 0.5f,
viewHeight * 0.5f,
m_cameraHeight);
cameraDir = -Vector3.UnitZ;
viewWitdh = (int)m_scene.RegionInfo.RegionSizeX;
viewHeight = (int)m_scene.RegionInfo.RegionSizeY;
orto = true;
Bitmap tile = GenImage();
@@ -341,9 +342,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
int bitWidth;
int bitHeight;
const double log2inv = 1.4426950408889634073599246810019;
bitWidth = (int)Math.Ceiling((Math.Log(terrain.Width) * log2inv));
bitHeight = (int)Math.Ceiling((Math.Log(terrain.Height) * log2inv));
bitWidth = Util.intLog2((uint)terrain.Width);
bitHeight = Util.intLog2((uint)terrain.Height);
if (bitWidth > 8) // more than 256 is very heavy :(
bitWidth = 8;

View File

@@ -365,8 +365,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
SafeNativeMethods.Vector3 px = new SafeNativeMethods.Vector3(sx * 0.5f, sy * 0.5f, 0);
if (sx < sy)
sx = sy;
sx = (float)Math.Log(sx) * 1.442695f + 0.5f;
int dp = (int)sx - 1;
int dp = Util.intLog2((uint)sx);
if(dp > 8)
dp = 8;
else if(dp < 4)

View File

@@ -14661,6 +14661,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret.Add(new LSL_Integer(count));
break;
case ScriptBaseClass.OBJECT_ACCOUNT_LEVEL:
ret.Add(new LSL_Integer(1));
break;
case ScriptBaseClass.OBJECT_MATERIAL:
ret.Add(new LSL_Integer((int)Material.Flesh));
break;
case ScriptBaseClass.OBJECT_MASS:
ret.Add(new LSL_Float(av.GetMass()));
break;
case ScriptBaseClass.OBJECT_TEXT:
ret.Add(new LSL_String(""));
break;
case ScriptBaseClass.OBJECT_REZ_TIME:
ret.Add(new LSL_String(""));
break;
case ScriptBaseClass.OBJECT_LINK_NUMBER:
ret.Add(new LSL_Integer(0));
break;
case ScriptBaseClass.OBJECT_SCALE:
ret.Add(new LSL_Vector(av.Appearance.AvatarBoxSize));
break;
case ScriptBaseClass.OBJECT_TEXT_COLOR:
ret.Add(new LSL_Vector(0f, 0f, 0f));
break;
case ScriptBaseClass.OBJECT_TEXT_ALPHA:
ret.Add(new LSL_Float(1.0f));
break;
default:
// Invalid or unhandled constant.
ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL));
@@ -14886,6 +14913,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case ScriptBaseClass.OBJECT_ANIMATED_SLOTS_AVAILABLE:
ret.Add(new LSL_Integer(0));
break;
case ScriptBaseClass.OBJECT_ACCOUNT_LEVEL:
ret.Add(new LSL_Integer(1));
break;
case ScriptBaseClass.OBJECT_MATERIAL:
ret.Add(new LSL_Integer(m_host.Material));
break;
case ScriptBaseClass.OBJECT_MASS:
ret.Add(new LSL_Float(llGetMassMKS()));
break;
case ScriptBaseClass.OBJECT_TEXT:
ret.Add(new LSL_String(m_host.Text));
break;
case ScriptBaseClass.OBJECT_REZ_TIME:
ret.Add(new LSL_String(m_host.Rezzed.ToString("yyyy-MM-ddTHH:mm:ss.ffffffZ", CultureInfo.InvariantCulture)));
break;
case ScriptBaseClass.OBJECT_LINK_NUMBER:
ret.Add(new LSL_Integer(m_host.LinkNum));
break;
case ScriptBaseClass.OBJECT_SCALE:
ret.Add(new LSL_Vector(m_host.Scale));
break;
case ScriptBaseClass.OBJECT_TEXT_COLOR:
Color4 textColor = m_host.GetTextColor();
ret.Add(new LSL_Vector(textColor.R,
textColor.G,
textColor.B));
break;
case ScriptBaseClass.OBJECT_TEXT_ALPHA:
ret.Add(new LSL_Float(m_host.GetTextColor().A));
break;
default:
// Invalid or unhandled constant.
ret.Add(new LSL_Integer(ScriptBaseClass.OBJECT_UNKNOWN_DETAIL));

View File

@@ -670,6 +670,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int OBJECT_SIT_COUNT = 38;
public const int OBJECT_ANIMATED_COUNT = 39;
public const int OBJECT_ANIMATED_SLOTS_AVAILABLE = 40;
public const int OBJECT_ACCOUNT_LEVEL = 41;
public const int OBJECT_MATERIAL = 42;
public const int OBJECT_MASS = 43;
public const int OBJECT_TEXT = 44;
public const int OBJECT_REZ_TIME = 45;
public const int OBJECT_LINK_NUMBER = 46;
public const int OBJECT_SCALE = 47;
public const int OBJECT_TEXT_COLOR = 48;
public const int OBJECT_TEXT_ALPHA = 49;
// Pathfinding types

View File

@@ -939,8 +939,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (Engine.World.PipeEventsForScript(LocalID) ||
data.EventName == "control") // Don't freeze avies!
{
// m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
// PrimName, ScriptName, data.EventName, State);
//m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
// PrimName, ScriptName, data.EventName, State);
try
{