diff options
author | UbitUmarov | 2012-09-20 14:32:30 +0100 |
---|---|---|
committer | UbitUmarov | 2012-09-20 14:32:30 +0100 |
commit | bf987f96d2339f1471ad5fc5b3df5a7a8b484d6e (patch) | |
tree | 072ce2e6c6086fe5de4031d5e5d741ad1a27ba7f /OpenSim/Region | |
parent | be more tolerant to small prims, skipping them, only failing if they are (diff) | |
download | opensim-SC_OLD-bf987f96d2339f1471ad5fc5b3df5a7a8b484d6e.zip opensim-SC_OLD-bf987f96d2339f1471ad5fc5b3df5a7a8b484d6e.tar.gz opensim-SC_OLD-bf987f96d2339f1471ad5fc5b3df5a7a8b484d6e.tar.bz2 opensim-SC_OLD-bf987f96d2339f1471ad5fc5b3df5a7a8b484d6e.tar.xz |
Fix model upload rotations and offsets ( i hope )
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 159 |
1 files changed, 56 insertions, 103 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index d66076d..a139ea8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -128,9 +128,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
128 | } | 128 | } |
129 | private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; | 129 | private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; |
130 | 130 | ||
131 | // private bool m_addNewTextures = false; | ||
132 | // private bool m_addNewMeshes = false; | ||
133 | |||
134 | public BunchOfCaps(Scene scene, Caps caps) | 131 | public BunchOfCaps(Scene scene, Caps caps) |
135 | { | 132 | { |
136 | m_Scene = scene; | 133 | m_Scene = scene; |
@@ -641,6 +638,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
641 | } | 638 | } |
642 | } | 639 | } |
643 | 640 | ||
641 | // strings to types | ||
644 | if (inventoryType == "sound") | 642 | if (inventoryType == "sound") |
645 | { | 643 | { |
646 | inType = (sbyte)InventoryType.Sound; | 644 | inType = (sbyte)InventoryType.Sound; |
@@ -687,45 +685,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
687 | textureAsset.Data = texture_list[i].AsBinary(); | 685 | textureAsset.Data = texture_list[i].AsBinary(); |
688 | m_assetService.Store(textureAsset); | 686 | m_assetService.Store(textureAsset); |
689 | textures.Add(textureAsset.FullID); | 687 | textures.Add(textureAsset.FullID); |
690 | /* | ||
691 | don't do this | ||
692 | replace it by optionaly making model textures cost less than if individually uploaded | ||
693 | since they can't be used for other purpuses | ||
694 | |||
695 | // save it to inventory | ||
696 | if (m_addNewTextures && AddNewInventoryItem != null) | ||
697 | { | ||
698 | string name = assetName; | ||
699 | if (name.Length > 25) | ||
700 | name = name.Substring(0, 24); | ||
701 | name += "_Texture#" + i.ToString(); | ||
702 | InventoryItemBase texitem = new InventoryItemBase(); | ||
703 | texitem.Owner = m_HostCapsObj.AgentID; | ||
704 | texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); | ||
705 | texitem.CreatorData = String.Empty; | ||
706 | texitem.ID = UUID.Random(); | ||
707 | texitem.AssetID = textureAsset.FullID; | ||
708 | texitem.Description = "mesh model texture"; | ||
709 | texitem.Name = name; | ||
710 | texitem.AssetType = (int)AssetType.Texture; | ||
711 | texitem.InvType = (int)InventoryType.Texture; | ||
712 | texitem.Folder = UUID.Zero; // send to default | ||
713 | |||
714 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current | ||
715 | // (owner) permissions. This becomes a problem if next permissions are changed. | ||
716 | texitem.CurrentPermissions | ||
717 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | ||
718 | |||
719 | texitem.BasePermissions = (uint)PermissionMask.All; | ||
720 | texitem.EveryOnePermissions = 0; | ||
721 | texitem.NextPermissions = (uint)PermissionMask.All; | ||
722 | texitem.CreationDate = Util.UnixTimeSinceEpoch(); | ||
723 | |||
724 | AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); | ||
725 | texitem = null; | ||
726 | } | ||
727 | */ | ||
728 | textureAsset = null; | ||
729 | } | 688 | } |
730 | 689 | ||
731 | // create and store meshs assets | 690 | // create and store meshs assets |
@@ -736,47 +695,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
736 | meshAsset.Data = mesh_list[i].AsBinary(); | 695 | meshAsset.Data = mesh_list[i].AsBinary(); |
737 | m_assetService.Store(meshAsset); | 696 | m_assetService.Store(meshAsset); |
738 | meshAssets.Add(meshAsset.FullID); | 697 | meshAssets.Add(meshAsset.FullID); |
739 | |||
740 | /* this was a test, funny and showed viewers deal with mesh inventory itens | ||
741 | * nut also same reason as for textures | ||
742 | * let integrated in a model cost eventually less than hipotetical independent meshs assets | ||
743 | * that will be in inventory | ||
744 | // save it to inventory | ||
745 | if (m_addNewMeshes && AddNewInventoryItem != null) | ||
746 | { | ||
747 | string name = assetName; | ||
748 | if (name.Length > 25) | ||
749 | name = name.Substring(0, 24); | ||
750 | name += "_Mesh#" + i.ToString(); | ||
751 | InventoryItemBase meshitem = new InventoryItemBase(); | ||
752 | meshitem.Owner = m_HostCapsObj.AgentID; | ||
753 | meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); | ||
754 | meshitem.CreatorData = String.Empty; | ||
755 | meshitem.ID = UUID.Random(); | ||
756 | meshitem.AssetID = meshAsset.FullID; | ||
757 | meshitem.Description = "mesh "; | ||
758 | meshitem.Name = name; | ||
759 | meshitem.AssetType = (int)AssetType.Mesh; | ||
760 | meshitem.InvType = (int)InventoryType.Mesh; | ||
761 | meshitem.Folder = UUID.Zero; // send to default | ||
762 | |||
763 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current | ||
764 | // (owner) permissions. This becomes a problem if next permissions are changed. | ||
765 | meshitem.CurrentPermissions | ||
766 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | ||
767 | |||
768 | meshitem.BasePermissions = (uint)PermissionMask.All; | ||
769 | meshitem.EveryOnePermissions = 0; | ||
770 | meshitem.NextPermissions = (uint)PermissionMask.All; | ||
771 | meshitem.CreationDate = Util.UnixTimeSinceEpoch(); | ||
772 | |||
773 | AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); | ||
774 | meshitem = null; | ||
775 | } | ||
776 | */ | ||
777 | meshAsset = null; | ||
778 | } | 698 | } |
779 | 699 | ||
700 | int skipedMeshs = 0; | ||
780 | // build prims from instances | 701 | // build prims from instances |
781 | for (int i = 0; i < instance_list.Count; i++) | 702 | for (int i = 0; i < instance_list.Count; i++) |
782 | { | 703 | { |
@@ -784,9 +705,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
784 | 705 | ||
785 | // skip prims that are 2 small | 706 | // skip prims that are 2 small |
786 | Vector3 scale = inner_instance_list["scale"].AsVector3(); | 707 | Vector3 scale = inner_instance_list["scale"].AsVector3(); |
787 | 708 | ||
788 | if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) | 709 | if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) |
710 | { | ||
711 | skipedMeshs++; | ||
789 | continue; | 712 | continue; |
713 | } | ||
790 | 714 | ||
791 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); | 715 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); |
792 | 716 | ||
@@ -836,21 +760,33 @@ namespace OpenSim.Region.ClientStack.Linden | |||
836 | 760 | ||
837 | pbs.TextureEntry = textureEntry.GetBytes(); | 761 | pbs.TextureEntry = textureEntry.GetBytes(); |
838 | 762 | ||
839 | int meshindx = inner_instance_list["mesh"].AsInteger(); | 763 | bool hasmesh = false; |
840 | if (meshAssets.Count > meshindx) | 764 | if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ... |
841 | { | 765 | { |
842 | pbs.SculptEntry = true; | 766 | int meshindx = inner_instance_list["mesh"].AsInteger(); |
843 | pbs.SculptType = (byte)SculptType.Mesh; | 767 | if (meshAssets.Count > meshindx) |
844 | pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction | 768 | { |
845 | // data will be requested from asset on rez (i hope) | 769 | pbs.SculptEntry = true; |
770 | pbs.SculptType = (byte)SculptType.Mesh; | ||
771 | pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction | ||
772 | // data will be requested from asset on rez (i hope) | ||
773 | hasmesh = true; | ||
774 | } | ||
846 | } | 775 | } |
847 | 776 | ||
848 | Vector3 position = inner_instance_list["position"].AsVector3(); | 777 | Vector3 position = inner_instance_list["position"].AsVector3(); |
849 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); | 778 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); |
850 | 779 | ||
780 | // for now viwers do send fixed defaults | ||
781 | // but this may change | ||
782 | // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); | ||
783 | byte physicsShapeType = (byte)PhysShapeType.prim; // default for mesh is simple convex | ||
784 | if(hasmesh) | ||
785 | physicsShapeType = (byte) PhysShapeType.convex; // default for mesh is simple convex | ||
786 | // int material = inner_instance_list["material"].AsInteger(); | ||
787 | byte material = (byte)Material.Wood; | ||
788 | |||
851 | // no longer used - begin ------------------------ | 789 | // no longer used - begin ------------------------ |
852 | // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); | ||
853 | // int material = inner_instance_list["material"].AsInteger(); | ||
854 | // int mesh = inner_instance_list["mesh"].AsInteger(); | 790 | // int mesh = inner_instance_list["mesh"].AsInteger(); |
855 | 791 | ||
856 | // OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; | 792 | // OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; |
@@ -872,7 +808,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
872 | = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); | 808 | = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); |
873 | 809 | ||
874 | prim.Scale = scale; | 810 | prim.Scale = scale; |
875 | prim.OffsetPosition = position; | 811 | // prim.OffsetPosition = position; |
876 | rotations.Add(rotation); | 812 | rotations.Add(rotation); |
877 | positions.Add(position); | 813 | positions.Add(position); |
878 | prim.UUID = UUID.Random(); | 814 | prim.UUID = UUID.Random(); |
@@ -883,6 +819,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
883 | prim.CreationDate = Util.UnixTimeSinceEpoch(); | 819 | prim.CreationDate = Util.UnixTimeSinceEpoch(); |
884 | prim.Name = assetName; | 820 | prim.Name = assetName; |
885 | prim.Description = ""; | 821 | prim.Description = ""; |
822 | prim.Material = material; | ||
823 | prim.PhysicsShapeType = physicsShapeType; | ||
886 | 824 | ||
887 | // prim.BaseMask = (uint)base_mask; | 825 | // prim.BaseMask = (uint)base_mask; |
888 | // prim.EveryoneMask = (uint)everyone_mask; | 826 | // prim.EveryoneMask = (uint)everyone_mask; |
@@ -896,25 +834,40 @@ namespace OpenSim.Region.ClientStack.Linden | |||
896 | grp.AddPart(prim); | 834 | grp.AddPart(prim); |
897 | } | 835 | } |
898 | 836 | ||
899 | // Fix first link number | 837 | Vector3 rootPos = positions[0]; |
838 | |||
900 | if (grp.Parts.Length > 1) | 839 | if (grp.Parts.Length > 1) |
840 | { | ||
841 | // Fix first link number | ||
901 | grp.RootPart.LinkNum++; | 842 | grp.RootPart.LinkNum++; |
902 | 843 | ||
903 | Vector3 rootPos = positions[0]; | 844 | Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]); |
904 | grp.AbsolutePosition = rootPos; | 845 | Quaternion tmprot; |
905 | for (int i = 0; i < positions.Count; i++) | 846 | Vector3 offset; |
906 | { | 847 | |
907 | Vector3 offset = positions[i] - rootPos; | 848 | // fix children rotations and positions |
908 | grp.Parts[i].OffsetPosition = offset; | 849 | for (int i = 1; i < rotations.Count; i++) |
909 | } | 850 | { |
851 | tmprot = rotations[i]; | ||
852 | tmprot = rootRotConj * tmprot; | ||
853 | |||
854 | grp.Parts[i].RotationOffset = tmprot; | ||
910 | 855 | ||
911 | for (int i = 0; i < rotations.Count; i++) | 856 | offset = positions[i] - rootPos; |
857 | |||
858 | offset *= rootRotConj; | ||
859 | grp.Parts[i].OffsetPosition = offset; | ||
860 | } | ||
861 | |||
862 | grp.AbsolutePosition = rootPos; | ||
863 | grp.UpdateGroupRotationR(rotations[0]); | ||
864 | } | ||
865 | else | ||
912 | { | 866 | { |
913 | if (i != 0) | 867 | grp.AbsolutePosition = rootPos; |
914 | grp.Parts[i].RotationOffset = rotations[i]; | 868 | grp.UpdateGroupRotationR(rotations[0]); |
915 | } | 869 | } |
916 | 870 | ||
917 | grp.UpdateGroupRotationR(rotations[0]); | ||
918 | data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); | 871 | data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); |
919 | } | 872 | } |
920 | 873 | ||