create a single ModelCost provider for the caps instance. Let it know and

check scene prim size limits.
avinationmerge
UbitUmarov 2012-09-19 01:33:16 +01:00
parent 51ca84afdf
commit fb32604b41
2 changed files with 56 additions and 14 deletions

View File

@ -87,6 +87,7 @@ namespace OpenSim.Region.ClientStack.Linden
private Scene m_Scene; private Scene m_Scene;
private Caps m_HostCapsObj; private Caps m_HostCapsObj;
private ModelCost m_ModelCost;
private static readonly string m_requestPath = "0000/"; private static readonly string m_requestPath = "0000/";
// private static readonly string m_mapLayerPath = "0001/"; // private static readonly string m_mapLayerPath = "0001/";
@ -123,6 +124,15 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
m_Scene = scene; m_Scene = scene;
m_HostCapsObj = caps; m_HostCapsObj = caps;
// create a model upload cost provider
m_ModelCost = new ModelCost();
// tell it about scene object limits
m_ModelCost.NonPhysicalPrimScaleMax = m_Scene.m_maxNonphys;
m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys;
// m_ModelCost.PrimScaleMin = ??
// m_ModelCost.ObjectLinkedPartsMax = ??
IConfigSource config = m_Scene.Config; IConfigSource config = m_Scene.Config;
if (config != null) if (config != null)
{ {
@ -193,7 +203,6 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
try try
{ {
// I don't think this one works...
m_HostCapsObj.RegisterHandler( m_HostCapsObj.RegisterHandler(
"NewFileAgentInventory", "NewFileAgentInventory",
new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>( new LLSDStreamhandler<LLSDAssetUploadRequest, LLSDAssetUploadResponse>(
@ -472,9 +481,8 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
string error; string error;
int modelcost; int modelcost;
ModelCost mc = new ModelCost();
if (!mc.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost,
meshcostdata, out error)) meshcostdata, out error))
{ {
client.SendAgentAlertMessage(error, false); client.SendAgentAlertMessage(error, false);

View File

@ -23,8 +23,14 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap;
namespace OpenSim.Region.ClientStack.Linden namespace OpenSim.Region.ClientStack.Linden
{ {
public struct ModelPrimLimits
{
}
public class ModelCost public class ModelCost
{ {
// upload fee tunning paramenters // upload fee tunning paramenters
// fees are normalized to 1.0 // fees are normalized to 1.0
// this parameters scale them to basic cost ( so 1.0 translates to 10 ) // this parameters scale them to basic cost ( so 1.0 translates to 10 )
@ -66,6 +72,12 @@ namespace OpenSim.Region.ClientStack.Linden
// internal // internal
const int bytesPerCoord = 6; // 3 coords, 2 bytes per each const int bytesPerCoord = 6; // 3 coords, 2 bytes per each
// control prims dimensions
public float PrimScaleMin = 0.01f;
public float NonPhysicalPrimScaleMax = 256f;
public float PhysicalPrimScaleMax = 10f;
public int ObjectLinkedPartsMax = 512;
// storage for a single mesh asset cost parameters // storage for a single mesh asset cost parameters
private class ameshCostParam private class ameshCostParam
{ {
@ -98,7 +110,15 @@ namespace OpenSim.Region.ClientStack.Linden
error = "Unable to upload mesh model. missing information."; error = "Unable to upload mesh model. missing information.";
return false; return false;
} }
int numberInstances = resources.instance_list.Array.Count;
if( numberInstances > ObjectLinkedPartsMax )
{
error = "upload failed: Model whould have two many linked prims";
return false;
}
meshcostdata.model_streaming_cost = 0.0; meshcostdata.model_streaming_cost = 0.0;
meshcostdata.simulation_cost = 0.0; meshcostdata.simulation_cost = 0.0;
meshcostdata.physics_cost = 0.0; meshcostdata.physics_cost = 0.0;
@ -148,12 +168,35 @@ namespace OpenSim.Region.ClientStack.Linden
} }
// instances (prims) cost // instances (prims) cost
int numberInstances = resources.instance_list.Array.Count;
int mesh; int mesh;
for (int i = 0; i < numberInstances; i++) for (int i = 0; i < numberInstances; i++)
{ {
Hashtable inst = (Hashtable)resources.instance_list.Array[i]; Hashtable inst = (Hashtable)resources.instance_list.Array[i];
ArrayList ascale = (ArrayList)inst["scale"];
Vector3 scale;
double tmp;
tmp = (double)ascale[0];
scale.X = (float)tmp;
tmp = (double)ascale[1];
scale.Y = (float)tmp;
tmp = (double)ascale[2];
scale.Z = (float)tmp;
if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin)
{
error = " upload fail: Model contains parts with a dimension lower than 0.01. Please adjust scaling";
return false;
}
if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax)
{
error = "upload fail: Model contains parts larger than maximum allowed. Please adjust scaling";
return false;
}
if (haveMeshs && inst.ContainsKey("mesh")) if (haveMeshs && inst.ContainsKey("mesh"))
{ {
mesh = (int)inst["mesh"]; mesh = (int)inst["mesh"];
@ -165,15 +208,6 @@ namespace OpenSim.Region.ClientStack.Linden
} }
// streamming cost // streamming cost
ArrayList ascale = (ArrayList)inst["scale"];
Vector3 scale;
double tmp;
tmp = (double)ascale[0];
scale.X = (float)tmp;
tmp = (double)ascale[1];
scale.Y = (float)tmp;
tmp = (double)ascale[2];
scale.Z = (float)tmp;
float sqdiam = scale.LengthSquared(); float sqdiam = scale.LengthSquared();