From 7ce8ccb043002520a82ce14325e991a22e0c292b Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 19 Dec 2008 17:57:03 +0000
Subject: * refactor: Move tree code out into a separate module
---
OpenSim/Region/Environment/Scenes/Scene.cs | 87 +++++++++++++-----------------
1 file changed, 38 insertions(+), 49 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 72748b6..eecfd70 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -6,7 +6,7 @@
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
+ * * Redistributions in binary form must reproduce the above copyrightD
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
@@ -259,6 +259,11 @@ namespace OpenSim.Region.Environment.Scenes
}
public int objectCapacity = 45000;
+
+ ///
+ /// Registered classes that are capable of creating entities.
+ ///
+ protected Dictionary m_entityCreators = new Dictionary();
#endregion
@@ -1753,63 +1758,24 @@ namespace OpenSim.Region.Environment.Scenes
}
}
- public virtual SceneObjectGroup AddNewPrim(UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
+ public virtual SceneObjectGroup AddNewPrim(
+ UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
{
//m_log.DebugFormat(
- // "[SCENE]: Scene.AddNewPrim() called for agent {0} in {1}", ownerID, RegionInfo.RegionName);
+ // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);
+
+ // If an entity creator has been registered for this prim type then use that
+ if (m_entityCreators.ContainsKey((PCode)shape.PCode))
+ return m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
+ // Otherwise, use this default creation code;
SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
-
- SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID);
- // if grass or tree, make phantom
- //rootPart.TrimPermissions();
- if ((rootPart.Shape.PCode == (byte)PCode.Grass)
- || (rootPart.Shape.PCode == (byte)PCode.Tree) || (rootPart.Shape.PCode == (byte)PCode.NewTree))
- {
- rootPart.AddFlag(PrimFlags.Phantom);
- //rootPart.ObjectFlags += (uint)PrimFlags.Phantom;
- if (rootPart.Shape.PCode != (byte)PCode.Grass)
- AdaptTree(ref shape);
- }
-
AddNewSceneObject(sceneObject, true);
sceneObject.SetGroup(groupID, null);
return sceneObject;
}
- protected void AdaptTree(ref PrimitiveBaseShape tree)
- {
- // Tree size has to be adapted depending on its type
- switch ((Tree)tree.State)
- {
- case Tree.Cypress1:
- case Tree.Cypress2:
- tree.Scale = new Vector3(4, 4, 10);
- break;
-
- // case... other tree types
- // tree.Scale = new Vector3(?, ?, ?);
- // break;
-
- default:
- tree.Scale = new Vector3(4, 4, 4);
- break;
- }
- }
-
- public SceneObjectGroup AddTree(UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position,
- Tree treeType, bool newTree)
- {
- PrimitiveBaseShape treeShape = new PrimitiveBaseShape();
- treeShape.PathCurve = 16;
- treeShape.PathEnd = 49900;
- treeShape.PCode = newTree ? (byte)PCode.NewTree : (byte)PCode.Tree;
- treeShape.Scale = scale;
- treeShape.State = (byte)treeType;
- return AddNewPrim(uuid, groupID, position, rotation, treeShape);
- }
-
///
/// Add an object into the scene that has come from storage
///
@@ -3299,6 +3265,15 @@ namespace OpenSim.Region.Environment.Scenes
List