aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2010-05-08 13:31:36 +0100
committerMelanie2010-05-08 13:31:36 +0100
commit14fcc2510ef9f1effc06d7e99b57f7f74de08eac (patch)
treee52f145ef2aac9a9cc7fb32a6a40e62f67991743 /OpenSim/Region
parentMerge branch 'master' into careminster-presence-refactor (diff)
parenttest commit for panda (diff)
downloadopensim-SC_OLD-14fcc2510ef9f1effc06d7e99b57f7f74de08eac.zip
opensim-SC_OLD-14fcc2510ef9f1effc06d7e99b57f7f74de08eac.tar.gz
opensim-SC_OLD-14fcc2510ef9f1effc06d7e99b57f7f74de08eac.tar.bz2
opensim-SC_OLD-14fcc2510ef9f1effc06d7e99b57f7f74de08eac.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml4
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs116
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs69
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs153
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs13
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs21
-rw-r--r--OpenSim/Region/Physics/Meshing/PrimMesher.cs103
-rw-r--r--OpenSim/Region/Physics/Meshing/SculptMap.cs176
-rw-r--r--OpenSim/Region/Physics/Meshing/SculptMesh.cs152
14 files changed, 719 insertions, 143 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index f2b03e4..ef37f63 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -526,11 +526,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
526 { 526 {
527 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 527 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
528 528
529 OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId); 529 //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId);
530 GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString());
530 531
531 if (pinfo != null) 532 if (uinfo != null)
532 { 533 {
533 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID); 534 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
534 if (regionInfo == null) 535 if (regionInfo == null)
535 { 536 {
536 // can't find the Home region: Tell viewer and abort 537 // can't find the Home region: Tell viewer and abort
@@ -539,7 +540,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
539 } 540 }
540 // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point... 541 // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point...
541 ((Scene)(client.Scene)).RequestTeleportLocation( 542 ((Scene)(client.Scene)).RequestTeleportLocation(
542 client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt, 543 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
543 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); 544 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
544 } 545 }
545 } 546 }
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 28593fc..137dfec 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
154 bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason); 154 bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
155 if (success) 155 if (success)
156 // Log them out of this grid 156 // Log them out of this grid
157 m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); 157 m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID);
158 158
159 return success; 159 return success;
160 } 160 }
@@ -238,6 +238,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
238 { 238 {
239 if (obj.IsLoggingOut) 239 if (obj.IsLoggingOut)
240 { 240 {
241 object sp = null;
242 if (obj.Scene.TryGetScenePresence(obj.AgentId, out sp))
243 {
244 if (((ScenePresence)sp).IsChildAgent)
245 return;
246 }
247
241 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); 248 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
242 249
243 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 250 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
index 0a5ff3f..ee07075 100644
--- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
+++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml
@@ -59,9 +59,11 @@
59 <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" /> 59 <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" />
60 60
61 <RegionModule id="LocalGridUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser.LocalGridUserServicesConnector" /> 61 <RegionModule id="LocalGridUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser.LocalGridUserServicesConnector" />
62 62 <RegionModule id="RemoteGridUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser.RemoteGridUserServicesConnector" />
63
63 <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" /> 64 <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" />
64 <RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" /> 65 <RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" />
66
65 <!-- Service connectors IN modules --> 67 <!-- Service connectors IN modules -->
66 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> 68 <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
67 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> 69 <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
new file mode 100644
index 0000000..6c01927
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
@@ -0,0 +1,116 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Services.Interfaces;
34
35using OpenMetaverse;
36using log4net;
37
38namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
39{
40 public class ActivityDetector
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 private IGridUserService m_GridUserService;
45 private Scene m_aScene;
46
47 public ActivityDetector(IGridUserService guservice)
48 {
49 m_GridUserService = guservice;
50 m_log.DebugFormat("[ACTIVITY DETECTOR]: starting ");
51 }
52
53 public void AddRegion(Scene scene)
54 {
55 // For now the only events we listen to are these
56 // But we could trigger the position update more often
57 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
58 scene.EventManager.OnNewClient += OnNewClient;
59 scene.EventManager.OnAvatarEnteringNewParcel += OnEnteringNewParcel;
60
61 if (m_aScene == null)
62 m_aScene = scene;
63 }
64
65 public void RemoveRegion(Scene scene)
66 {
67 scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
68 scene.EventManager.OnNewClient -= OnNewClient;
69 }
70
71 public void OnMakeRootAgent(ScenePresence sp)
72 {
73 m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
74
75 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
76 }
77
78 public void OnNewClient(IClientAPI client)
79 {
80 client.OnConnectionClosed += OnConnectionClose;
81 }
82
83 public void OnConnectionClose(IClientAPI client)
84 {
85 if (client.IsLoggingOut)
86 {
87 object sp = null;
88 Vector3 position = new Vector3(128, 128, 0);
89 Vector3 lookat = new Vector3(0, 1, 0);
90
91 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
92 {
93 if (sp is ScenePresence)
94 {
95 if (((ScenePresence)sp).IsChildAgent)
96 return;
97
98 position = ((ScenePresence)sp).AbsolutePosition;
99 lookat = ((ScenePresence)sp).Lookat;
100 }
101 }
102 m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
103 m_GridUserService.LoggedOut(client.AgentId.ToString(), client.Scene.RegionInfo.RegionID, position, lookat);
104 }
105
106 }
107
108 void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID)
109 {
110 // TODO: grab the parcel ID from ILandModule
111 // and send that along
112 m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
113 }
114
115 }
116}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
index d5fae23..d914a57 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs
@@ -41,13 +41,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
41{ 41{
42 public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService 42 public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
45 47
46 private IGridUserService m_service; 48 private IGridUserService m_GridUserService;
49
50 private ActivityDetector m_ActivityDetector;
47 51
48 private bool m_Enabled = false; 52 private bool m_Enabled = false;
49 53
50 public Type ReplaceableInterface 54 #region ISharedRegionModule
55
56 public Type ReplaceableInterface
51 { 57 {
52 get { return null; } 58 get { return null; }
53 } 59 }
@@ -68,7 +74,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
68 IConfig userConfig = source.Configs["GridUserService"]; 74 IConfig userConfig = source.Configs["GridUserService"];
69 if (userConfig == null) 75 if (userConfig == null)
70 { 76 {
71 m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from ini files"); 77 m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from OpenSim.ini");
72 return; 78 return;
73 } 79 }
74 80
@@ -81,15 +87,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
81 } 87 }
82 88
83 Object[] args = new Object[] { source }; 89 Object[] args = new Object[] { source };
84 m_service = ServerUtils.LoadPlugin<IGridUserService>(serviceDll, args); 90 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(serviceDll, args);
85 91
86 if (m_service == null) 92 if (m_GridUserService == null)
87 { 93 {
88 m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: Can't load GridUser service"); 94 m_log.ErrorFormat(
95 "[LOCAL GRID USER SERVICE CONNECTOR]: Cannot load user account service specified as {0}", serviceDll);
89 return; 96 return;
90 } 97 }
98
99 m_ActivityDetector = new ActivityDetector(this);
100
91 m_Enabled = true; 101 m_Enabled = true;
92 m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local GridUser connector enabled"); 102
103 m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local grid user connector enabled");
93 } 104 }
94 } 105 }
95 } 106 }
@@ -111,29 +122,57 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
111 if (!m_Enabled) 122 if (!m_Enabled)
112 return; 123 return;
113 124
114 scene.RegisterModuleInterface<IGridUserService>(m_service); 125 scene.RegisterModuleInterface<IGridUserService>(m_GridUserService);
126 m_ActivityDetector.AddRegion(scene);
115 } 127 }
116 128
117 public void RemoveRegion(Scene scene) 129 public void RemoveRegion(Scene scene)
118 { 130 {
119 if (!m_Enabled) 131 if (!m_Enabled)
120 return; 132 return;
133
134 scene.UnregisterModuleInterface<IGridUserService>(this);
135 m_ActivityDetector.RemoveRegion(scene);
121 } 136 }
122 137
123 public void RegionLoaded(Scene scene) 138 public void RegionLoaded(Scene scene)
124 { 139 {
125 if (!m_Enabled) 140 if (!m_Enabled)
126 return; 141 return;
142
143 m_log.InfoFormat("[LOCAL GRID USER SERVICE CONNECTOR]: Enabled local grid user for region {0}", scene.RegionInfo.RegionName);
127 } 144 }
128 145
129 public GridUserInfo GetGridUserInfo(string userID) 146 #endregion
147
148 #region IGridUserService
149
150 public GridUserInfo LoggedIn(string userID)
130 { 151 {
131 return m_service.GetGridUserInfo(userID); 152 return m_GridUserService.LoggedIn(userID);
132 } 153 }
133 154
134 public bool StoreGridUserInfo(GridUserInfo info) 155 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
135 { 156 {
136 return m_service.StoreGridUserInfo(info); 157 return m_GridUserService.LoggedOut(userID, regionID, lastPosition, lastLookAt);
137 } 158 }
159
160 public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt)
161 {
162 return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt);
163 }
164
165 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
166 {
167 return m_GridUserService.SetLastPosition(userID, regionID, lastPosition, lastLookAt);
168 }
169
170 public GridUserInfo GetGridUserInfo(string userID)
171 {
172 return m_GridUserService.GetGridUserInfo(userID);
173 }
174
175 #endregion
176
138 } 177 }
139} \ No newline at end of file 178}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs
new file mode 100644
index 0000000..e3e2e61
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs
@@ -0,0 +1,153 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Server.Base;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors;
36
37using OpenMetaverse;
38using log4net;
39using Nini.Config;
40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
42{
43 public class RemoteGridUserServicesConnector : ISharedRegionModule, IGridUserService
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 #region ISharedRegionModule
48
49 private bool m_Enabled = false;
50
51 private ActivityDetector m_ActivityDetector;
52 private IGridUserService m_RemoteConnector;
53
54 public Type ReplaceableInterface
55 {
56 get { return null; }
57 }
58
59 public string Name
60 {
61 get { return "RemoteGridUserServicesConnector"; }
62 }
63
64 public void Initialise(IConfigSource source)
65 {
66 IConfig moduleConfig = source.Configs["Modules"];
67 if (moduleConfig != null)
68 {
69 string name = moduleConfig.GetString("GridUserServices", "");
70 if (name == Name)
71 {
72 m_RemoteConnector = new GridUserServicesConnector(source);
73
74 m_Enabled = true;
75
76 m_ActivityDetector = new ActivityDetector(this);
77
78 m_log.Info("[REMOTE GRID USER CONNECTOR]: Remote grid user enabled");
79 }
80 }
81
82 }
83
84 public void PostInitialise()
85 {
86 }
87
88 public void Close()
89 {
90 }
91
92 public void AddRegion(Scene scene)
93 {
94 if (!m_Enabled)
95 return;
96
97 scene.RegisterModuleInterface<IGridUserService>(this);
98 m_ActivityDetector.AddRegion(scene);
99
100 m_log.InfoFormat("[REMOTE GRID USER CONNECTOR]: Enabled remote grid user for region {0}", scene.RegionInfo.RegionName);
101
102 }
103
104 public void RemoveRegion(Scene scene)
105 {
106 if (!m_Enabled)
107 return;
108
109 m_ActivityDetector.RemoveRegion(scene);
110 }
111
112 public void RegionLoaded(Scene scene)
113 {
114 if (!m_Enabled)
115 return;
116
117 }
118
119 #endregion
120
121 #region IGridUserService
122
123 public GridUserInfo LoggedIn(string userID)
124 {
125 m_log.Warn("[REMOTE GRID USER CONNECTOR]: LoggedIn not implemented at the simulators");
126 return null;
127 }
128
129 public bool LoggedOut(string userID, UUID region, Vector3 position, Vector3 lookat)
130 {
131 return m_RemoteConnector.LoggedOut(userID, region, position, lookat);
132 }
133
134
135 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
136 {
137 return m_RemoteConnector.SetHome(userID, regionID, position, lookAt);
138 }
139
140 public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
141 {
142 return m_RemoteConnector.SetLastPosition(userID, regionID, position, lookAt);
143 }
144
145 public GridUserInfo GetGridUserInfo(string userID)
146 {
147 return m_RemoteConnector.GetGridUserInfo(userID);
148 }
149
150 #endregion
151
152 }
153}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
index c402a3f..49dd633 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs
@@ -167,9 +167,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
167 return false; 167 return false;
168 } 168 }
169 169
170 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) 170 public bool LogoutAgent(UUID sessionID)
171 { 171 {
172 return m_PresenceService.LogoutAgent(sessionID, position, lookat); 172 return m_PresenceService.LogoutAgent(sessionID);
173 } 173 }
174 174
175 175
@@ -178,9 +178,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
178 return m_PresenceService.LogoutRegionAgents(regionID); 178 return m_PresenceService.LogoutRegionAgents(regionID);
179 } 179 }
180 180
181 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 181 public bool ReportAgent(UUID sessionID, UUID regionID)
182 { 182 {
183 return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt); 183 return m_PresenceService.ReportAgent(sessionID, regionID);
184 } 184 }
185 185
186 public PresenceInfo GetAgent(UUID sessionID) 186 public PresenceInfo GetAgent(UUID sessionID)
@@ -193,11 +193,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
193 return m_PresenceService.GetAgents(userIDs); 193 return m_PresenceService.GetAgents(userIDs);
194 } 194 }
195 195
196 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
197 {
198 return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt);
199 }
200
201 #endregion 196 #endregion
202 197
203 } 198 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
index 7a75a89..62b8278 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
72 public void OnMakeRootAgent(ScenePresence sp) 72 public void OnMakeRootAgent(ScenePresence sp)
73 { 73 {
74 m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); 74 m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
75 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 75 m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID);
76 } 76 }
77 77
78 public void OnNewClient(IClientAPI client) 78 public void OnNewClient(IClientAPI client)
@@ -85,19 +85,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
85 if (client.IsLoggingOut) 85 if (client.IsLoggingOut)
86 { 86 {
87 object sp = null; 87 object sp = null;
88 Vector3 position = new Vector3(128, 128, 0);
89 Vector3 lookat = new Vector3(0, 1, 0);
90
91 if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) 88 if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
92 { 89 {
93 if (sp is ScenePresence) 90 if (sp is ScenePresence)
94 { 91 {
95 position = ((ScenePresence)sp).AbsolutePosition; 92 if (((ScenePresence)sp).IsChildAgent)
96 lookat = ((ScenePresence)sp).Lookat; 93 return;
97 } 94 }
98 } 95 }
99 96
100 m_PresenceService.LogoutAgent(client.SessionId, position, lookat); 97 m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
98 m_PresenceService.LogoutAgent(client.SessionId);
101 } 99 }
102 100
103 } 101 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
index 5f3666e..bf4e9ab 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs
@@ -127,9 +127,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
127 return false; 127 return false;
128 } 128 }
129 129
130 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) 130 public bool LogoutAgent(UUID sessionID)
131 { 131 {
132 return m_RemoteConnector.LogoutAgent(sessionID, position, lookat); 132 return m_RemoteConnector.LogoutAgent(sessionID);
133 } 133 }
134 134
135 135
@@ -138,9 +138,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
138 return m_RemoteConnector.LogoutRegionAgents(regionID); 138 return m_RemoteConnector.LogoutRegionAgents(regionID);
139 } 139 }
140 140
141 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 141 public bool ReportAgent(UUID sessionID, UUID regionID)
142 { 142 {
143 return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt); 143 return m_RemoteConnector.ReportAgent(sessionID, regionID);
144 } 144 }
145 145
146 public PresenceInfo GetAgent(UUID sessionID) 146 public PresenceInfo GetAgent(UUID sessionID)
@@ -153,11 +153,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
153 return m_RemoteConnector.GetAgents(userIDs); 153 return m_RemoteConnector.GetAgents(userIDs);
154 } 154 }
155 155
156 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
157 {
158 return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt);
159 }
160
161 #endregion 156 #endregion
162 157
163 } 158 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
index 63a28fc..ef910f4 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs
@@ -90,27 +90,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests
90 PresenceInfo result = m_LocalConnector.GetAgent(session1); 90 PresenceInfo result = m_LocalConnector.GetAgent(session1);
91 Assert.IsNotNull(result, "Retrieved GetAgent is null"); 91 Assert.IsNotNull(result, "Retrieved GetAgent is null");
92 Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match"); 92 Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match");
93 Assert.IsTrue(result.Online, "Agent just logged in but is offline");
94 93
95 UUID region1 = UUID.Random(); 94 UUID region1 = UUID.Random();
96 bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); 95 bool r = m_LocalConnector.ReportAgent(session1, region1);
97 Assert.IsTrue(r, "First ReportAgent returned false"); 96 Assert.IsTrue(r, "First ReportAgent returned false");
98 result = m_LocalConnector.GetAgent(session1); 97 result = m_LocalConnector.GetAgent(session1);
99 Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)"); 98 Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)");
100 99
101 UUID region2 = UUID.Random(); 100 UUID region2 = UUID.Random();
102 r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero); 101 r = m_LocalConnector.ReportAgent(session1, region2);
103 Assert.IsTrue(r, "Second ReportAgent returned false"); 102 Assert.IsTrue(r, "Second ReportAgent returned false");
104 result = m_LocalConnector.GetAgent(session1); 103 result = m_LocalConnector.GetAgent(session1);
105 Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)"); 104 Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)");
106 105
107 r = m_LocalConnector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY); 106 r = m_LocalConnector.LogoutAgent(session1);
108 Assert.IsTrue(r, "LogoutAgent returned false"); 107 Assert.IsTrue(r, "LogoutAgent returned false");
109 result = m_LocalConnector.GetAgent(session1); 108 result = m_LocalConnector.GetAgent(session1);
110 Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); 109 Assert.IsNull(result, "Agent session is still stored after logout");
111 Assert.IsFalse(result.Online, "Agent is reported to be Online after logout");
112 110
113 r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); 111 r = m_LocalConnector.ReportAgent(session1, region1);
114 Assert.IsFalse(r, "ReportAgent of non-logged in user returned true"); 112 Assert.IsFalse(r, "ReportAgent of non-logged in user returned true");
115 } 113 }
116 } 114 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0ca5948..2197ced 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -318,7 +318,18 @@ namespace OpenSim.Region.Framework.Scenes
318 return m_AvatarService; 318 return m_AvatarService;
319 } 319 }
320 } 320 }
321 321
322 protected IGridUserService m_GridUserService;
323 public IGridUserService GridUserService
324 {
325 get
326 {
327 if (m_GridUserService == null)
328 m_GridUserService = RequestModuleInterface<IGridUserService>();
329 return m_GridUserService;
330 }
331 }
332
322 protected IXMLRPC m_xmlrpcModule; 333 protected IXMLRPC m_xmlrpcModule;
323 protected IWorldComm m_worldCommModule; 334 protected IWorldComm m_worldCommModule;
324 public IAttachmentsModule AttachmentsModule { get; set; } 335 public IAttachmentsModule AttachmentsModule { get; set; }
@@ -1334,8 +1345,8 @@ namespace OpenSim.Region.Framework.Scenes
1334 if (defaultRegions != null && defaultRegions.Count >= 1) 1345 if (defaultRegions != null && defaultRegions.Count >= 1)
1335 home = defaultRegions[0]; 1346 home = defaultRegions[0];
1336 1347
1337 if (PresenceService != null && home != null) 1348 if (GridUserService != null && home != null)
1338 PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); 1349 GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
1339 else 1350 else
1340 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", 1351 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
1341 first, last); 1352 first, last);
@@ -3123,7 +3134,7 @@ namespace OpenSim.Region.Framework.Scenes
3123 /// <param name="flags"></param> 3134 /// <param name="flags"></param>
3124 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3135 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3125 { 3136 {
3126 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3137 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3127 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3138 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3128 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3139 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3129 else 3140 else
@@ -3577,7 +3588,7 @@ namespace OpenSim.Region.Framework.Scenes
3577 3588
3578 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID); 3589 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
3579 3590
3580 if (pinfo == null || (pinfo != null && pinfo.Online == false)) 3591 if (pinfo == null)
3581 { 3592 {
3582 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); 3593 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3583 return false; 3594 return false;
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
index 932943c..53022ad 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
@@ -257,7 +257,6 @@ namespace PrimMesher
257 public int uv2; 257 public int uv2;
258 public int uv3; 258 public int uv3;
259 259
260
261 public Face(int v1, int v2, int v3) 260 public Face(int v1, int v2, int v3)
262 { 261 {
263 primFace = 0; 262 primFace = 0;
@@ -630,6 +629,9 @@ namespace PrimMesher
630 internal int numOuterVerts = 0; 629 internal int numOuterVerts = 0;
631 internal int numHollowVerts = 0; 630 internal int numHollowVerts = 0;
632 631
632 internal int outerFaceNumber = -1;
633 internal int hollowFaceNumber = -1;
634
633 internal bool calcVertexNormals = false; 635 internal bool calcVertexNormals = false;
634 internal int bottomFaceNumber = 0; 636 internal int bottomFaceNumber = 0;
635 internal int numPrimFaces = 0; 637 internal int numPrimFaces = 0;
@@ -936,10 +938,10 @@ namespace PrimMesher
936 938
937 if (calcVertexNormals && hasProfileCut) 939 if (calcVertexNormals && hasProfileCut)
938 { 940 {
941 int lastOuterVertIndex = this.numOuterVerts - 1;
942
939 if (hasHollow) 943 if (hasHollow)
940 { 944 {
941 int lastOuterVertIndex = this.numOuterVerts - 1;
942
943 this.cut1CoordIndices.Add(0); 945 this.cut1CoordIndices.Add(0);
944 this.cut1CoordIndices.Add(this.coords.Count - 1); 946 this.cut1CoordIndices.Add(this.coords.Count - 1);
945 947
@@ -955,6 +957,12 @@ namespace PrimMesher
955 957
956 else 958 else
957 { 959 {
960 this.cut1CoordIndices.Add(0);
961 this.cut1CoordIndices.Add(1);
962
963 this.cut2CoordIndices.Add(lastOuterVertIndex);
964 this.cut2CoordIndices.Add(0);
965
958 this.cutNormal1.X = this.vertexNormals[1].Y; 966 this.cutNormal1.X = this.vertexNormals[1].Y;
959 this.cutNormal1.Y = -this.vertexNormals[1].X; 967 this.cutNormal1.Y = -this.vertexNormals[1].X;
960 968
@@ -979,11 +987,14 @@ namespace PrimMesher
979 // I know it's ugly but so is the whole concept of prim face numbers 987 // I know it's ugly but so is the whole concept of prim face numbers
980 988
981 int faceNum = 1; // start with outer faces 989 int faceNum = 1; // start with outer faces
990 this.outerFaceNumber = faceNum;
991
982 int startVert = hasProfileCut && !hasHollow ? 1 : 0; 992 int startVert = hasProfileCut && !hasHollow ? 1 : 0;
983 if (startVert > 0) 993 if (startVert > 0)
984 this.faceNumbers.Add(-1); 994 this.faceNumbers.Add(-1);
985 for (int i = 0; i < this.numOuterVerts - 1; i++) 995 for (int i = 0; i < this.numOuterVerts - 1; i++)
986 this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum); 996 //this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum);
997 this.faceNumbers.Add(sides < 5 && i < sides ? faceNum++ : faceNum);
987 998
988 //if (!hasHollow && !hasProfileCut) 999 //if (!hasHollow && !hasProfileCut)
989 // this.bottomFaceNumber = faceNum++; 1000 // this.bottomFaceNumber = faceNum++;
@@ -993,12 +1004,15 @@ namespace PrimMesher
993 if (sides > 4 && (hasHollow || hasProfileCut)) 1004 if (sides > 4 && (hasHollow || hasProfileCut))
994 faceNum++; 1005 faceNum++;
995 1006
1007 if (sides < 5 && (hasHollow || hasProfileCut) && this.numOuterVerts < sides)
1008 faceNum++;
1009
996 if (hasHollow) 1010 if (hasHollow)
997 { 1011 {
998 for (int i = 0; i < this.numHollowVerts; i++) 1012 for (int i = 0; i < this.numHollowVerts; i++)
999 this.faceNumbers.Add(faceNum); 1013 this.faceNumbers.Add(faceNum);
1000 1014
1001 faceNum++; 1015 this.hollowFaceNumber = faceNum++;
1002 } 1016 }
1003 //if (hasProfileCut || hasHollow) 1017 //if (hasProfileCut || hasHollow)
1004 // this.bottomFaceNumber = faceNum++; 1018 // this.bottomFaceNumber = faceNum++;
@@ -1006,11 +1020,11 @@ namespace PrimMesher
1006 1020
1007 if (hasHollow && hasProfileCut) 1021 if (hasHollow && hasProfileCut)
1008 this.faceNumbers.Add(faceNum++); 1022 this.faceNumbers.Add(faceNum++);
1023
1009 for (int i = 0; i < this.faceNumbers.Count; i++) 1024 for (int i = 0; i < this.faceNumbers.Count; i++)
1010 if (this.faceNumbers[i] == -1) 1025 if (this.faceNumbers[i] == -1)
1011 this.faceNumbers[i] = faceNum++; 1026 this.faceNumbers[i] = faceNum++;
1012 1027
1013
1014 this.numPrimFaces = faceNum; 1028 this.numPrimFaces = faceNum;
1015 } 1029 }
1016 1030
@@ -1455,11 +1469,15 @@ namespace PrimMesher
1455 public float revolutions = 1.0f; 1469 public float revolutions = 1.0f;
1456 public int stepsPerRevolution = 24; 1470 public int stepsPerRevolution = 24;
1457 1471
1472 private int profileOuterFaceNumber = -1;
1473 private int profileHollowFaceNumber = -1;
1474
1458 private bool hasProfileCut = false; 1475 private bool hasProfileCut = false;
1459 private bool hasHollow = false; 1476 private bool hasHollow = false;
1460 public bool calcVertexNormals = false; 1477 public bool calcVertexNormals = false;
1461 private bool normalsProcessed = false; 1478 private bool normalsProcessed = false;
1462 public bool viewerMode = false; 1479 public bool viewerMode = false;
1480 public bool sphereMode = false;
1463 1481
1464 public int numPrimFaces = 0; 1482 public int numPrimFaces = 0;
1465 1483
@@ -1491,10 +1509,35 @@ namespace PrimMesher
1491 s += "\nradius...............: " + this.radius.ToString(); 1509 s += "\nradius...............: " + this.radius.ToString();
1492 s += "\nrevolutions..........: " + this.revolutions.ToString(); 1510 s += "\nrevolutions..........: " + this.revolutions.ToString();
1493 s += "\nstepsPerRevolution...: " + this.stepsPerRevolution.ToString(); 1511 s += "\nstepsPerRevolution...: " + this.stepsPerRevolution.ToString();
1512 s += "\nsphereMode...........: " + this.sphereMode.ToString();
1513 s += "\nhasProfileCut........: " + this.hasProfileCut.ToString();
1514 s += "\nhasHollow............: " + this.hasHollow.ToString();
1515 s += "\nviewerMode...........: " + this.viewerMode.ToString();
1494 1516
1495 return s; 1517 return s;
1496 } 1518 }
1497 1519
1520 public int ProfileOuterFaceNumber
1521 {
1522 get { return profileOuterFaceNumber; }
1523 }
1524
1525 public int ProfileHollowFaceNumber
1526 {
1527 get { return profileHollowFaceNumber; }
1528 }
1529
1530 public bool HasProfileCut
1531 {
1532 get { return hasProfileCut; }
1533 }
1534
1535 public bool HasHollow
1536 {
1537 get { return hasHollow; }
1538 }
1539
1540
1498 /// <summary> 1541 /// <summary>
1499 /// Constructs a PrimMesh object and creates the profile for extrusion. 1542 /// Constructs a PrimMesh object and creates the profile for extrusion.
1500 /// </summary> 1543 /// </summary>
@@ -1531,8 +1574,12 @@ namespace PrimMesher
1531 if (hollow < 0.0f) 1574 if (hollow < 0.0f)
1532 this.hollow = 0.0f; 1575 this.hollow = 0.0f;
1533 1576
1534 this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); 1577 //if (sphereMode)
1535 this.hasHollow = (this.hollow > 0.001f); 1578 // this.hasProfileCut = this.profileEnd - this.profileStart < 0.4999f;
1579 //else
1580 // //this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f);
1581 // this.hasProfileCut = this.profileEnd - this.profileStart < 0.9999f;
1582 //this.hasHollow = (this.hollow > 0.001f);
1536 } 1583 }
1537 1584
1538 /// <summary> 1585 /// <summary>
@@ -1540,6 +1587,8 @@ namespace PrimMesher
1540 /// </summary> 1587 /// </summary>
1541 public void Extrude(PathType pathType) 1588 public void Extrude(PathType pathType)
1542 { 1589 {
1590 bool needEndFaces = false;
1591
1543 this.coords = new List<Coord>(); 1592 this.coords = new List<Coord>();
1544 this.faces = new List<Face>(); 1593 this.faces = new List<Face>();
1545 1594
@@ -1565,6 +1614,12 @@ namespace PrimMesher
1565 steps = (int)(steps * 4.5 * length); 1614 steps = (int)(steps * 4.5 * length);
1566 } 1615 }
1567 1616
1617 if (sphereMode)
1618 this.hasProfileCut = this.profileEnd - this.profileStart < 0.4999f;
1619 else
1620 //this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f);
1621 this.hasProfileCut = this.profileEnd - this.profileStart < 0.9999f;
1622 this.hasHollow = (this.hollow > 0.001f);
1568 1623
1569 float twistBegin = this.twistBegin / 360.0f * twoPi; 1624 float twistBegin = this.twistBegin / 360.0f * twoPi;
1570 float twistEnd = this.twistEnd / 360.0f * twoPi; 1625 float twistEnd = this.twistEnd / 360.0f * twoPi;
@@ -1634,6 +1689,32 @@ namespace PrimMesher
1634 1689
1635 this.numPrimFaces = profile.numPrimFaces; 1690 this.numPrimFaces = profile.numPrimFaces;
1636 1691
1692 //profileOuterFaceNumber = profile.faceNumbers[0];
1693 //if (!needEndFaces)
1694 // profileOuterFaceNumber--;
1695 //profileOuterFaceNumber = needEndFaces ? 1 : 0;
1696
1697
1698 //if (hasHollow)
1699 //{
1700 // if (needEndFaces)
1701 // profileHollowFaceNumber = profile.faceNumbers[profile.numOuterVerts + 1];
1702 // else
1703 // profileHollowFaceNumber = profile.faceNumbers[profile.numOuterVerts] - 1;
1704 //}
1705
1706
1707 profileOuterFaceNumber = profile.outerFaceNumber;
1708 if (!needEndFaces)
1709 profileOuterFaceNumber--;
1710
1711 if (hasHollow)
1712 {
1713 profileHollowFaceNumber = profile.hollowFaceNumber;
1714 if (!needEndFaces)
1715 profileHollowFaceNumber--;
1716 }
1717
1637 int cut1Vert = -1; 1718 int cut1Vert = -1;
1638 int cut2Vert = -1; 1719 int cut2Vert = -1;
1639 if (hasProfileCut) 1720 if (hasProfileCut)
@@ -1673,7 +1754,7 @@ namespace PrimMesher
1673 1754
1674 path.Create(pathType, steps); 1755 path.Create(pathType, steps);
1675 1756
1676 bool needEndFaces = false; 1757
1677 if (pathType == PathType.Circular) 1758 if (pathType == PathType.Circular)
1678 { 1759 {
1679 needEndFaces = false; 1760 needEndFaces = false;
@@ -1761,7 +1842,7 @@ namespace PrimMesher
1761 int startVert = coordsLen + 1; 1842 int startVert = coordsLen + 1;
1762 int endVert = this.coords.Count; 1843 int endVert = this.coords.Count;
1763 1844
1764 if (sides < 5 || this.hasProfileCut || hollow > 0.0f) 1845 if (sides < 5 || this.hasProfileCut || this.hasHollow)
1765 startVert--; 1846 startVert--;
1766 1847
1767 for (int i = startVert; i < endVert; i++) 1848 for (int i = startVert; i < endVert; i++)
@@ -1813,11 +1894,13 @@ namespace PrimMesher
1813 u1 -= (int)u1; 1894 u1 -= (int)u1;
1814 if (u2 < 0.1f) 1895 if (u2 < 0.1f)
1815 u2 = 1.0f; 1896 u2 = 1.0f;
1897 //this.profileOuterFaceNumber = primFaceNum;
1816 } 1898 }
1817 else if (whichVert > profile.coords.Count - profile.numHollowVerts - 1) 1899 else if (whichVert > profile.coords.Count - profile.numHollowVerts - 1)
1818 { 1900 {
1819 u1 *= 2.0f; 1901 u1 *= 2.0f;
1820 u2 *= 2.0f; 1902 u2 *= 2.0f;
1903 //this.profileHollowFaceNumber = primFaceNum;
1821 } 1904 }
1822 } 1905 }
1823 1906
diff --git a/OpenSim/Region/Physics/Meshing/SculptMap.cs b/OpenSim/Region/Physics/Meshing/SculptMap.cs
new file mode 100644
index 0000000..d2d71de
--- /dev/null
+++ b/OpenSim/Region/Physics/Meshing/SculptMap.cs
@@ -0,0 +1,176 @@
1/*
2 * Copyright (c) Contributors
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28// to build without references to System.Drawing, comment this out
29#define SYSTEM_DRAWING
30
31using System;
32using System.Collections.Generic;
33using System.Text;
34
35#if SYSTEM_DRAWING
36using System.Drawing;
37using System.Drawing.Imaging;
38
39namespace PrimMesher
40{
41 public class SculptMap
42 {
43 public int width;
44 public int height;
45 public byte[] redBytes;
46 public byte[] greenBytes;
47 public byte[] blueBytes;
48
49 public SculptMap()
50 {
51 }
52
53 public SculptMap(Bitmap bm, int lod)
54 {
55 int bmW = bm.Width;
56 int bmH = bm.Height;
57
58 if (bmW == 0 || bmH == 0)
59 throw new Exception("SculptMap: bitmap has no data");
60
61 int numLodPixels = lod * 2 * lod * 2; // (32 * 2)^2 = 64^2 pixels for default sculpt map image
62
63 bool needsScaling = false;
64
65 width = bmW;
66 height = bmH;
67 while (width * height > numLodPixels)
68 {
69 width >>= 1;
70 height >>= 1;
71 needsScaling = true;
72 }
73
74
75
76 try
77 {
78 if (needsScaling)
79 bm = ScaleImage(bm, width, height,
80 System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor);
81 }
82
83 catch (Exception e)
84 {
85 throw new Exception("Exception in ScaleImage(): e: " + e.ToString());
86 }
87
88 if (width * height > lod * lod)
89 {
90 width >>= 1;
91 height >>= 1;
92 }
93
94 int numBytes = (width + 1) * (height + 1);
95 redBytes = new byte[numBytes];
96 greenBytes = new byte[numBytes];
97 blueBytes = new byte[numBytes];
98
99 int byteNdx = 0;
100
101 try
102 {
103 for (int y = 0; y <= height; y++)
104 {
105 for (int x = 0; x <= width; x++)
106 {
107 int bmY = y < height ? y * 2 : y * 2 - 1;
108 int bmX = x < width ? x * 2 : x * 2 - 1;
109 Color c = bm.GetPixel(bmX, bmY);
110
111 redBytes[byteNdx] = c.R;
112 greenBytes[byteNdx] = c.G;
113 blueBytes[byteNdx] = c.B;
114
115 ++byteNdx;
116 }
117 }
118 }
119 catch (Exception e)
120 {
121 throw new Exception("Caught exception processing byte arrays in SculptMap(): e: " + e.ToString());
122 }
123
124 width++;
125 height++;
126 }
127
128 public List<List<Coord>> ToRows(bool mirror)
129 {
130 int numRows = height;
131 int numCols = width;
132
133 List<List<Coord>> rows = new List<List<Coord>>(numRows);
134
135 float pixScale = 1.0f / 255;
136
137 int rowNdx, colNdx;
138 int smNdx = 0;
139
140 for (rowNdx = 0; rowNdx < numRows; rowNdx++)
141 {
142 List<Coord> row = new List<Coord>(numCols);
143 for (colNdx = 0; colNdx < numCols; colNdx++)
144 {
145 if (mirror)
146 row.Add(new Coord(-(redBytes[smNdx] * pixScale - 0.5f), (greenBytes[smNdx] * pixScale - 0.5f), blueBytes[smNdx] * pixScale - 0.5f));
147 else
148 row.Add(new Coord(redBytes[smNdx] * pixScale - 0.5f, greenBytes[smNdx] * pixScale - 0.5f, blueBytes[smNdx] * pixScale - 0.5f));
149
150 ++smNdx;
151 }
152 rows.Add(row);
153 }
154 return rows;
155 }
156
157 private Bitmap ScaleImage(Bitmap srcImage, int destWidth, int destHeight,
158 System.Drawing.Drawing2D.InterpolationMode interpMode)
159 {
160 Bitmap scaledImage = new Bitmap(srcImage, destWidth, destHeight);
161 scaledImage.SetResolution(96.0f, 96.0f);
162
163 Graphics grPhoto = Graphics.FromImage(scaledImage);
164 grPhoto.InterpolationMode = interpMode;
165
166 grPhoto.DrawImage(srcImage,
167 new Rectangle(0, 0, destWidth, destHeight),
168 new Rectangle(0, 0, srcImage.Width, srcImage.Height),
169 GraphicsUnit.Pixel);
170
171 grPhoto.Dispose();
172 return scaledImage;
173 }
174 }
175}
176#endif
diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
index ebc5be6..6aa8fe4 100644
--- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs
+++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs
@@ -53,50 +53,6 @@ namespace PrimMesher
53 public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; 53 public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 };
54 54
55#if SYSTEM_DRAWING 55#if SYSTEM_DRAWING
56 private Bitmap ScaleImage(Bitmap srcImage, float scale, bool removeAlpha)
57 {
58 int sourceWidth = srcImage.Width;
59 int sourceHeight = srcImage.Height;
60 int sourceX = 0;
61 int sourceY = 0;
62
63 int destX = 0;
64 int destY = 0;
65 int destWidth = (int)(srcImage.Width * scale);
66 int destHeight = (int)(srcImage.Height * scale);
67
68 Bitmap scaledImage;
69
70 if (removeAlpha)
71 {
72 if (srcImage.PixelFormat == PixelFormat.Format32bppArgb)
73 for (int y = 0; y < srcImage.Height; y++)
74 for (int x = 0; x < srcImage.Width; x++)
75 {
76 Color c = srcImage.GetPixel(x, y);
77 srcImage.SetPixel(x, y, Color.FromArgb(255, c.R, c.G, c.B));
78 }
79
80 scaledImage = new Bitmap(destWidth, destHeight,
81 PixelFormat.Format24bppRgb);
82 }
83 else
84 scaledImage = new Bitmap(srcImage, destWidth, destHeight);
85
86 scaledImage.SetResolution(96.0f, 96.0f);
87
88 Graphics grPhoto = Graphics.FromImage(scaledImage);
89 grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
90
91 grPhoto.DrawImage(srcImage,
92 new Rectangle(destX, destY, destWidth, destHeight),
93 new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
94 GraphicsUnit.Pixel);
95
96 grPhoto.Dispose();
97 return scaledImage;
98 }
99
100 56
101 public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) 57 public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode)
102 { 58 {
@@ -106,6 +62,7 @@ namespace PrimMesher
106 return sculptMesh; 62 return sculptMesh;
107 } 63 }
108 64
65
109 public SculptMesh(string fileName, int sculptType, int lod, int viewerMode, int mirror, int invert) 66 public SculptMesh(string fileName, int sculptType, int lod, int viewerMode, int mirror, int invert)
110 { 67 {
111 Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); 68 Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName);
@@ -296,36 +253,53 @@ namespace PrimMesher
296 return rows; 253 return rows;
297 } 254 }
298 255
299 256 private List<List<Coord>> bitmap2CoordsSampled(Bitmap bitmap, int scale, bool mirror)
300 void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert)
301 { 257 {
302 coords = new List<Coord>(); 258 int numRows = bitmap.Height / scale;
303 faces = new List<Face>(); 259 int numCols = bitmap.Width / scale;
304 normals = new List<Coord>(); 260 List<List<Coord>> rows = new List<List<Coord>>(numRows);
305 uvs = new List<UVCoord>();
306 261
307 sculptType = (SculptType)(((int)sculptType) & 0x07); 262 float pixScale = 1.0f / 256.0f;
308 263
309 if (mirror) 264 int imageX, imageY = 0;
310 if (sculptType == SculptType.plane) 265
311 invert = !invert; 266 int rowNdx, colNdx;
312 267
313 float sculptBitmapLod = (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); 268 for (rowNdx = 0; rowNdx <= numRows; rowNdx++)
269 {
270 List<Coord> row = new List<Coord>(numCols);
271 imageY = rowNdx * scale;
272 if (rowNdx == numRows) imageY--;
273 for (colNdx = 0; colNdx <= numCols; colNdx++)
274 {
275 imageX = colNdx * scale;
276 if (colNdx == numCols) imageX--;
314 277
315 float sourceScaleFactor = (float)(lod) / sculptBitmapLod; 278 Color c = bitmap.GetPixel(imageX, imageY);
279 if (c.A != 255)
280 {
281 bitmap.SetPixel(imageX, imageY, Color.FromArgb(255, c.R, c.G, c.B));
282 c = bitmap.GetPixel(imageX, imageY);
283 }
316 284
317 float fScale = 1.0f / sourceScaleFactor; 285 if (mirror)
286 row.Add(new Coord(-(c.R * pixScale - 0.5f), c.G * pixScale - 0.5f, c.B * pixScale - 0.5f));
287 else
288 row.Add(new Coord(c.R * pixScale - 0.5f, c.G * pixScale - 0.5f, c.B * pixScale - 0.5f));
318 289
319 int iScale = (int)fScale; 290 }
320 if (iScale < 1) iScale = 1; 291 rows.Add(row);
321 if (iScale > 2 && iScale % 2 == 0) 292 }
322 _SculptMesh(bitmap2Coords(ScaleImage(sculptBitmap, 64.0f / sculptBitmapLod, true), 64 / lod, mirror), sculptType, viewerMode, mirror, invert); 293 return rows;
323 else
324 _SculptMesh(bitmap2Coords(sculptBitmap, iScale, mirror), sculptType, viewerMode, mirror, invert);
325 } 294 }
326#endif
327 295
328 296
297 void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert)
298 {
299 _SculptMesh(new SculptMap(sculptBitmap, lod).ToRows(mirror), sculptType, viewerMode, mirror, invert);
300 }
301#endif
302
329 void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) 303 void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert)
330 { 304 {
331 coords = new List<Coord>(); 305 coords = new List<Coord>();
@@ -349,8 +323,18 @@ namespace PrimMesher
349 323
350 if (sculptType != SculptType.plane) 324 if (sculptType != SculptType.plane)
351 { 325 {
352 for (int rowNdx = 0; rowNdx < rows.Count; rowNdx++) 326 if (rows.Count % 2 == 0)
353 rows[rowNdx].Add(rows[rowNdx][0]); 327 {
328 for (int rowNdx = 0; rowNdx < rows.Count; rowNdx++)
329 rows[rowNdx].Add(rows[rowNdx][0]);
330 }
331 else
332 {
333 int lastIndex = rows[0].Count - 1;
334
335 for (int i = 0; i < rows.Count; i++)
336 rows[i][0] = rows[i][lastIndex];
337 }
354 } 338 }
355 339
356 Coord topPole = rows[0][width / 2]; 340 Coord topPole = rows[0][width / 2];
@@ -358,23 +342,41 @@ namespace PrimMesher
358 342
359 if (sculptType == SculptType.sphere) 343 if (sculptType == SculptType.sphere)
360 { 344 {
361 int count = rows[0].Count; 345 if (rows.Count % 2 == 0)
362 List<Coord> topPoleRow = new List<Coord>(count); 346 {
363 List<Coord> bottomPoleRow = new List<Coord>(count); 347 int count = rows[0].Count;
348 List<Coord> topPoleRow = new List<Coord>(count);
349 List<Coord> bottomPoleRow = new List<Coord>(count);
364 350
365 for (int i = 0; i < count; i++) 351 for (int i = 0; i < count; i++)
352 {
353 topPoleRow.Add(topPole);
354 bottomPoleRow.Add(bottomPole);
355 }
356 rows.Insert(0, topPoleRow);
357 rows.Add(bottomPoleRow);
358 }
359 else
366 { 360 {
367 topPoleRow.Add(topPole); 361 int count = rows[0].Count;
368 bottomPoleRow.Add(bottomPole); 362
363 List<Coord> topPoleRow = rows[0];
364 List<Coord> bottomPoleRow = rows[rows.Count - 1];
365
366 for (int i = 0; i < count; i++)
367 {
368 topPoleRow[i] = topPole;
369 bottomPoleRow[i] = bottomPole;
370 }
369 } 371 }
370 rows.Insert(0, topPoleRow);
371 rows.Add(bottomPoleRow);
372 } 372 }
373 else if (sculptType == SculptType.torus) 373
374 if (sculptType == SculptType.torus)
374 rows.Add(rows[0]); 375 rows.Add(rows[0]);
375 376
376 int coordsDown = rows.Count; 377 int coordsDown = rows.Count;
377 int coordsAcross = rows[0].Count; 378 int coordsAcross = rows[0].Count;
379 int lastColumn = coordsAcross - 1;
378 380
379 float widthUnit = 1.0f / (coordsAcross - 1); 381 float widthUnit = 1.0f / (coordsAcross - 1);
380 float heightUnit = 1.0f / (coordsDown - 1); 382 float heightUnit = 1.0f / (coordsDown - 1);