From 7f5b1182efab9e7a80293622fa658d8d1a7b1fc8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 19:09:51 +0100 Subject: same cleanup --- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 79 +++++++++++----------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 622a2d9..ba73a25 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.ClientStack.Linden const float physMeshSizeWth = 6f; // counts 7x const float physHullSizeWth = 8f; // counts 9x - // stream cost size factors + // stream cost area factors const float highLodFactor = 17.36f; const float midLodFactor = 277.78f; const float lowLodFactor = 1111.11f; @@ -94,13 +94,12 @@ namespace OpenSim.Region.ClientStack.Linden totalcost += textures_cost; } - float meshsfee = 0; - // meshs assets cost - + float meshsfee = 0; int numberMeshs = 0; + bool haveMeshs = false; List meshsCosts = new List(); - // a model could have no mesh actually + if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) { numberMeshs = resources.mesh_list.Array.Count; @@ -117,6 +116,7 @@ namespace OpenSim.Region.ClientStack.Linden meshsCosts.Add(curCost); meshsfee += curCost.costFee; } + haveMeshs = true; } // instances (prims) cost @@ -126,44 +126,43 @@ namespace OpenSim.Region.ClientStack.Linden { Hashtable inst = (Hashtable)resources.instance_list.Array[i]; - // streamming cost - // assume all instances have a mesh - // but in general they can have normal prims - // but for now that seems not suported - // when they do, we will need to inspect pbs information - // and have cost funtions for all prims types - // don't check for shape type none, since - // that could be used to upload meshs with low cost - // changing later inworld - - 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(); - - mesh = (int)inst["mesh"]; - - if(mesh >= numberMeshs) + if (haveMeshs && inst.ContainsKey("mesh")) { - error = "Unable to upload mesh model. incoerent information."; - return false; - } + mesh = (int)inst["mesh"]; - ameshCostParam curCost = meshsCosts[mesh]; - float mesh_streaming = streamingCost(curCost, sqdiam); + if (mesh >= numberMeshs) + { + error = "Unable to upload mesh model. incoerent information."; + return false; + } + + // 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; - meshcostdata.model_streaming_cost += mesh_streaming; + float sqdiam = scale.LengthSquared(); - meshcostdata.physics_cost += curCost.physicsCost; + ameshCostParam curCost = meshsCosts[mesh]; + float mesh_streaming = streamingCost(curCost, sqdiam); + + meshcostdata.model_streaming_cost += mesh_streaming; + meshcostdata.physics_cost += curCost.physicsCost; + } + else // instance as no mesh ?? + { + // to do later if needed + meshcostdata.model_streaming_cost += 0.5f; + meshcostdata.physics_cost += 1.0f; + } - // unscripted and static prim server cost + // assume unscripted and static prim server cost meshcostdata.simulation_cost += 0.5f; // charge for prims creation meshsfee += primCreationCost; @@ -174,6 +173,10 @@ namespace OpenSim.Region.ClientStack.Linden else meshcostdata.resource_cost = meshcostdata.physics_cost; + if (meshcostdata.resource_cost < meshcostdata.simulation_cost) + meshcostdata.resource_cost = meshcostdata.simulation_cost; + + if (meshsfee < ModelMinCost) meshsfee = ModelMinCost; -- cgit v1.1