check for avatar skeleton data on meshs headers on cost estimation. Dont
let a model have more than one mesh with skeleton, for testing create a mesh inventory item, for this meshs. Add also option to read a avatar collider replacement. This information still needs to be saved somewhere so it can be checked on attachment, etc, without parsing the mesh asset again.avinationmerge
parent
fe495874f2
commit
1a6ef2d60e
|
@ -58,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
|
string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
|
||||||
byte[] data, string inventoryType, string assetType,
|
byte[] data, string inventoryType, string assetType,
|
||||||
int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances,
|
int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances,
|
||||||
bool IsAtestUpload, ref string error);
|
bool IsAtestUpload, bool avatarSkeleton, bool avatarCollider, ref string error);
|
||||||
|
|
||||||
public delegate UUID UpdateItem(UUID itemID, byte[] data);
|
public delegate UUID UpdateItem(UUID itemID, byte[] data);
|
||||||
|
|
||||||
|
@ -531,6 +531,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
int nreqmeshs= 0;
|
int nreqmeshs= 0;
|
||||||
int nreqinstances = 0;
|
int nreqinstances = 0;
|
||||||
bool IsAtestUpload = false;
|
bool IsAtestUpload = false;
|
||||||
|
bool avatarSkeleton = false;
|
||||||
|
bool avatarCollider = false;
|
||||||
|
|
||||||
string assetName = llsdRequest.name;
|
string assetName = llsdRequest.name;
|
||||||
|
|
||||||
|
@ -580,8 +582,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
string error;
|
string error;
|
||||||
int modelcost;
|
int modelcost;
|
||||||
|
|
||||||
|
|
||||||
if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost,
|
if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost,
|
||||||
meshcostdata, out error, ref warning))
|
meshcostdata,out avatarSkeleton, out avatarCollider, out error, ref warning))
|
||||||
{
|
{
|
||||||
LLSDAssetUploadError resperror = new LLSDAssetUploadError();
|
LLSDAssetUploadError resperror = new LLSDAssetUploadError();
|
||||||
resperror.message = error;
|
resperror.message = error;
|
||||||
|
@ -664,7 +667,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
AssetUploader uploader =
|
AssetUploader uploader =
|
||||||
new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
|
new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
|
||||||
llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost,
|
llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost,
|
||||||
texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload);
|
texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload, avatarSkeleton, avatarCollider);
|
||||||
|
|
||||||
m_HostCapsObj.HttpListener.AddStreamHandler(
|
m_HostCapsObj.HttpListener.AddStreamHandler(
|
||||||
new BinaryStreamHandler(
|
new BinaryStreamHandler(
|
||||||
|
@ -711,7 +714,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
|
UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
|
||||||
string assetType, int cost,
|
string assetType, int cost,
|
||||||
UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances,
|
UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances,
|
||||||
bool IsAtestUpload, ref string error)
|
bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider, ref string error)
|
||||||
{
|
{
|
||||||
|
|
||||||
lock (m_ModelCost)
|
lock (m_ModelCost)
|
||||||
|
@ -877,12 +880,60 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
List<UUID> meshAssets = new List<UUID>();
|
List<UUID> meshAssets = new List<UUID>();
|
||||||
for (int i = 0; i < mesh_list.Count; i++)
|
for (int i = 0; i < mesh_list.Count; i++)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
// do we really need this heavy thing?
|
||||||
|
OSD osd = OSDParser.DeserializeLLSDBinary(mesh_list[i]);
|
||||||
|
if (osd is OSDMap)
|
||||||
|
{
|
||||||
|
OSDMap mosd = (OSDMap)osd;
|
||||||
|
if (mosd.ContainsKey("skeleton"))
|
||||||
|
{
|
||||||
|
OSDMap skeleton = (OSDMap)mosd["skeleton"];
|
||||||
|
int sksize = skeleton["size"].AsInteger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr);
|
AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr);
|
||||||
meshAsset.Data = mesh_list[i].AsBinary();
|
meshAsset.Data = mesh_list[i].AsBinary();
|
||||||
if (istest)
|
if (istest)
|
||||||
meshAsset.Local = true;
|
meshAsset.Local = true;
|
||||||
m_assetService.Store(meshAsset);
|
m_assetService.Store(meshAsset);
|
||||||
meshAssets.Add(meshAsset.FullID);
|
meshAssets.Add(meshAsset.FullID);
|
||||||
|
|
||||||
|
|
||||||
|
// test code
|
||||||
|
if (avatarSkeleton)
|
||||||
|
{
|
||||||
|
string name = assetName;
|
||||||
|
if (name.Length > 25)
|
||||||
|
name = name.Substring(0, 24);
|
||||||
|
name += "_Mesh#" + i.ToString();
|
||||||
|
InventoryItemBase meshitem = new InventoryItemBase();
|
||||||
|
meshitem.Owner = m_HostCapsObj.AgentID;
|
||||||
|
meshitem.CreatorId = creatorIDstr;
|
||||||
|
meshitem.CreatorData = String.Empty;
|
||||||
|
meshitem.ID = UUID.Random();
|
||||||
|
meshitem.AssetID = meshAsset.FullID;
|
||||||
|
meshitem.Description = "mesh ";
|
||||||
|
meshitem.Name = name;
|
||||||
|
meshitem.AssetType = (int)AssetType.Mesh;
|
||||||
|
meshitem.InvType = (int)InventoryType.Mesh;
|
||||||
|
meshitem.Folder = UUID.Zero; // send to default
|
||||||
|
|
||||||
|
// If we set PermissionMask.All then when we rez the item the next permissions will replace the current
|
||||||
|
// (owner) permissions. This becomes a problem if next permissions are changed.
|
||||||
|
meshitem.CurrentPermissions
|
||||||
|
= (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
|
||||||
|
|
||||||
|
meshitem.BasePermissions = (uint)PermissionMask.All;
|
||||||
|
meshitem.EveryOnePermissions = 0;
|
||||||
|
meshitem.NextPermissions = (uint)PermissionMask.All;
|
||||||
|
meshitem.CreationDate = Util.UnixTimeSinceEpoch();
|
||||||
|
|
||||||
|
m_Scene.AddInventoryItem(client, meshitem);
|
||||||
|
meshitem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int skipedMeshs = 0;
|
int skipedMeshs = 0;
|
||||||
|
@ -1540,12 +1591,14 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
private int m_nreqmeshs;
|
private int m_nreqmeshs;
|
||||||
private int m_nreqinstances;
|
private int m_nreqinstances;
|
||||||
private bool m_IsAtestUpload;
|
private bool m_IsAtestUpload;
|
||||||
|
private bool m_avatarSkeleton;
|
||||||
|
private bool m_avatarCollider;
|
||||||
|
|
||||||
public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem,
|
public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem,
|
||||||
UUID parentFolderID, string invType, string assetType, string path,
|
UUID parentFolderID, string invType, string assetType, string path,
|
||||||
IHttpServer httpServer, bool dumpAssetsToFile,
|
IHttpServer httpServer, bool dumpAssetsToFile,
|
||||||
int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances,
|
int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances,
|
||||||
bool IsAtestUpload)
|
bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider)
|
||||||
{
|
{
|
||||||
m_assetName = assetName;
|
m_assetName = assetName;
|
||||||
m_assetDes = description;
|
m_assetDes = description;
|
||||||
|
@ -1564,6 +1617,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
m_nreqmeshs = nreqmeshs;
|
m_nreqmeshs = nreqmeshs;
|
||||||
m_nreqinstances = nreqinstances;
|
m_nreqinstances = nreqinstances;
|
||||||
m_IsAtestUpload = IsAtestUpload;
|
m_IsAtestUpload = IsAtestUpload;
|
||||||
|
m_avatarSkeleton = avatarSkeleton;
|
||||||
|
m_avatarCollider = avatarCollider;
|
||||||
|
|
||||||
m_timeoutTimer.Elapsed += TimedOut;
|
m_timeoutTimer.Elapsed += TimedOut;
|
||||||
m_timeoutTimer.Interval = 120000;
|
m_timeoutTimer.Interval = 120000;
|
||||||
|
@ -1608,7 +1663,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
if (handlerUpLoad != null)
|
if (handlerUpLoad != null)
|
||||||
{
|
{
|
||||||
handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,
|
handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,
|
||||||
m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error);
|
m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload,
|
||||||
|
m_avatarSkeleton, m_avatarCollider, ref m_error);
|
||||||
}
|
}
|
||||||
if (m_IsAtestUpload)
|
if (m_IsAtestUpload)
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,12 +96,18 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
// basicCost input region assets upload cost
|
// basicCost input region assets upload cost
|
||||||
// totalcost returns model total upload fee
|
// totalcost returns model total upload fee
|
||||||
// meshcostdata returns detailed costs for viewer
|
// meshcostdata returns detailed costs for viewer
|
||||||
|
// avatarSkeleton if mesh includes a avatar skeleton
|
||||||
|
// useAvatarCollider if we should use physics mesh for avatar
|
||||||
public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost,
|
public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost,
|
||||||
LLSDAssetUploadResponseData meshcostdata, out string error, ref string warning)
|
LLSDAssetUploadResponseData meshcostdata,out bool avatarSkeleton, out bool useAvatarCollider,
|
||||||
|
out string error, ref string warning)
|
||||||
{
|
{
|
||||||
totalcost = 0;
|
totalcost = 0;
|
||||||
error = string.Empty;
|
error = string.Empty;
|
||||||
|
|
||||||
|
avatarSkeleton = false;
|
||||||
|
useAvatarCollider = false;
|
||||||
|
|
||||||
if (resources == null ||
|
if (resources == null ||
|
||||||
resources.instance_list == null ||
|
resources.instance_list == null ||
|
||||||
resources.instance_list.Array.Count == 0)
|
resources.instance_list.Array.Count == 0)
|
||||||
|
@ -145,6 +151,10 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
float meshsfee = 0;
|
float meshsfee = 0;
|
||||||
int numberMeshs = 0;
|
int numberMeshs = 0;
|
||||||
bool haveMeshs = false;
|
bool haveMeshs = false;
|
||||||
|
|
||||||
|
bool curskeleton;
|
||||||
|
bool curAvatarPhys;
|
||||||
|
|
||||||
List<ameshCostParam> meshsCosts = new List<ameshCostParam>();
|
List<ameshCostParam> meshsCosts = new List<ameshCostParam>();
|
||||||
|
|
||||||
if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0)
|
if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0)
|
||||||
|
@ -156,10 +166,20 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
ameshCostParam curCost = new ameshCostParam();
|
ameshCostParam curCost = new ameshCostParam();
|
||||||
byte[] data = (byte[])resources.mesh_list.Array[i];
|
byte[] data = (byte[])resources.mesh_list.Array[i];
|
||||||
|
|
||||||
if (!MeshCost(data, curCost, out error))
|
if (!MeshCost(data, curCost,out curskeleton, out curAvatarPhys, out error))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curskeleton)
|
||||||
|
{
|
||||||
|
if (avatarSkeleton)
|
||||||
|
{
|
||||||
|
error = "model can only contain a avatar skeleton";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
avatarSkeleton = true;
|
||||||
|
}
|
||||||
meshsCosts.Add(curCost);
|
meshsCosts.Add(curCost);
|
||||||
meshsfee += curCost.costFee;
|
meshsfee += curCost.costFee;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +293,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
}
|
}
|
||||||
|
|
||||||
// single mesh asset cost
|
// single mesh asset cost
|
||||||
private bool MeshCost(byte[] data, ameshCostParam cost, out string error)
|
private bool MeshCost(byte[] data, ameshCostParam cost,out bool skeleton, out bool avatarPhys, out string error)
|
||||||
{
|
{
|
||||||
cost.highLODSize = 0;
|
cost.highLODSize = 0;
|
||||||
cost.medLODSize = 0;
|
cost.medLODSize = 0;
|
||||||
|
@ -284,6 +304,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
error = string.Empty;
|
error = string.Empty;
|
||||||
|
|
||||||
|
skeleton = false;
|
||||||
|
avatarPhys = false;
|
||||||
|
|
||||||
if (data == null || data.Length == 0)
|
if (data == null || data.Length == 0)
|
||||||
{
|
{
|
||||||
error = "Missing model information.";
|
error = "Missing model information.";
|
||||||
|
@ -330,6 +353,17 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
int submesh_offset = -1;
|
int submesh_offset = -1;
|
||||||
|
|
||||||
|
if (map.ContainsKey("skeleton"))
|
||||||
|
{
|
||||||
|
tmpmap = (OSDMap)map["skeleton"];
|
||||||
|
if (tmpmap.ContainsKey("offset") && tmpmap.ContainsKey("size"))
|
||||||
|
{
|
||||||
|
int sksize = tmpmap["size"].AsInteger();
|
||||||
|
if(sksize > 0)
|
||||||
|
skeleton = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (map.ContainsKey("physics_convex"))
|
if (map.ContainsKey("physics_convex"))
|
||||||
{
|
{
|
||||||
tmpmap = (OSDMap)map["physics_convex"];
|
tmpmap = (OSDMap)map["physics_convex"];
|
||||||
|
|
Loading…
Reference in New Issue