add llGetCameraAspect and llGetCameraFOV

This commit is contained in:
UbitUmarov
2024-03-28 15:34:03 +00:00
parent 45e49c480f
commit e918888e30
7 changed files with 75 additions and 3 deletions

View File

@@ -648,6 +648,9 @@ namespace OpenSim.Framework
{
Vector3 StartPos { get; set; }
float StartFar { get; set; }
float FOV { get; set; }
int viewHeight { get; set; }
int viewWidth { get; set; }
UUID AgentId { get; }

View File

@@ -385,7 +385,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
protected Dictionary<UUID, ulong> m_groupPowers = new();
protected int m_terrainCheckerCount;
protected uint m_agentFOVCounter;
protected IAssetService m_assetService;
protected bool m_supportViewerCache = false;
@@ -405,6 +405,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
set { m_startpos = value; }
}
public float StartFar { get; set; }
public float FOV { get; set; } = 1.25f;
public int viewHeight { get; set; } = 480;
public int viewWidth { get; set; } = 640;
public UUID AgentId { get { return m_agentId; } }
public UUID ScopeId { get { return m_scopeId; } }
@@ -11595,7 +11599,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (genCounter == 0 || genCounter > m_agentFOVCounter)
{
m_agentFOVCounter = genCounter;
OnAgentFOV?.Invoke(this, fovPacket.FOVBlock.VerticalAngle);
FOV = fovPacket.FOVBlock.VerticalAngle;
OnAgentFOV?.Invoke(this, FOV);
}
}
@@ -11751,6 +11756,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private void HandleAgentHeightWidth(Packet Pack)
{
AgentHeightWidthPacket hwPacket = (AgentHeightWidthPacket)Pack;
if (hwPacket.AgentData.AgentID.NotEqual(m_agentId) || hwPacket.AgentData.SessionID.NotEqual(m_sessionId))
return;
viewHeight = hwPacket.HeightWidthBlock.Height;
viewWidth = hwPacket.HeightWidthBlock.Width;
}

View File

@@ -525,7 +525,9 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
}
public float StartFar { get; set; }
public float FOV { get; set; } = 1.25f;
public int viewHeight { get; set; } = 480;
public int viewWidth { get; set; } = 640;
public bool TryGet<T>(out T iface)
{
iface = default(T);

View File

@@ -567,6 +567,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
}
public float StartFar { get; set; }
public float FOV { get; set; } = 1.25f;
public int viewHeight { get; set; } = 480;
public int viewWidth { get; set; } = 640;
public virtual UUID AgentId
{

View File

@@ -13339,6 +13339,45 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return LSL_Rotation.Identity;
}
public LSL_Float llGetCameraFOV()
{
if (m_item.PermsGranter.IsZero())
return LSL_Float.Zero;
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{
Error("llGetCameraAspect", "No permissions to track the camera");
return LSL_Float.Zero;
}
ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
if (presence is not null && presence.ControllingClient is not null)
{
return new LSL_Float(presence.ControllingClient.FOV);
}
return 1.4f;
}
public LSL_Float llGetCameraAspect()
{
if (m_item.PermsGranter.IsZero())
return 1f;
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{
Error("llGetCameraAspect", "No permissions to track the camera");
return 1f;
}
ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
if (presence is not null && presence.ControllingClient is not null)
{
int h = presence.ControllingClient.viewHeight;
return new LSL_Float(h > 0 ? (float)presence.ControllingClient.viewWidth / h : 1.0f);
}
return 1f;
}
public void llSetPrimURL(string url)
{
Deprecated("llSetPrimURL", "Use llSetPrimMediaParams instead");

View File

@@ -129,6 +129,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Integer llGetAttached();
LSL_List llGetAttachedList(LSL_Key id);
LSL_List llGetBoundingBox(string obj);
LSL_Float llGetCameraAspect();
LSL_Float llGetCameraFOV();
LSL_Vector llGetCameraPos();
LSL_Rotation llGetCameraRot();
LSL_Vector llGetCenterOfMass();

View File

@@ -512,6 +512,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_LSL_Functions.llGetBoundingBox(obj);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Float llGetCameraAspect()
{
return m_LSL_Functions.llGetCameraAspect();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Float llGetCameraFOV()
{
return m_LSL_Functions.llGetCameraFOV();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LSL_Vector llGetCameraPos()
{