Merge branch 'master' of git://opensimulator.org/git/opensim
commit
7590ebc934
|
@ -52,7 +52,7 @@ namespace OpenSim.Data.MySQL
|
|||
private string m_connectionString;
|
||||
private object m_dbLock = new object();
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
protected Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
@ -119,8 +119,10 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
// Eligibility check
|
||||
//
|
||||
if ((flags & (uint)PrimFlags.Temporary) != 0)
|
||||
return;
|
||||
// PrimFlags.Temporary is not used in OpenSim code and cannot
|
||||
// be guaranteed to always be clear. Don't check it.
|
||||
// if ((flags & (uint)PrimFlags.Temporary) != 0)
|
||||
// return;
|
||||
if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
|
||||
return;
|
||||
|
||||
|
@ -135,7 +137,7 @@ namespace OpenSim.Data.MySQL
|
|||
foreach (SceneObjectPart prim in obj.Parts)
|
||||
{
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
|
||||
cmd.CommandText = "replace into prims (" +
|
||||
"UUID, CreationDate, " +
|
||||
"Name, Text, Description, " +
|
||||
|
@ -171,8 +173,10 @@ namespace OpenSim.Data.MySQL
|
|||
"ParticleSystem, ClickAction, Material, " +
|
||||
"CollisionSound, CollisionSoundVolume, " +
|
||||
"PassTouches, " +
|
||||
"LinkNumber, MediaURL, DynAttrs) " +
|
||||
"values (?UUID, " +
|
||||
"LinkNumber, MediaURL, " +
|
||||
"PhysicsShapeType, Density, GravityModifier, " +
|
||||
"Friction, Restitution, DynAttrs " +
|
||||
") values (" + "?UUID, " +
|
||||
"?CreationDate, ?Name, ?Text, " +
|
||||
"?Description, ?SitName, ?TouchName, " +
|
||||
"?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
|
||||
|
@ -203,15 +207,17 @@ namespace OpenSim.Data.MySQL
|
|||
"?SaleType, ?ColorR, ?ColorG, " +
|
||||
"?ColorB, ?ColorA, ?ParticleSystem, " +
|
||||
"?ClickAction, ?Material, ?CollisionSound, " +
|
||||
"?CollisionSoundVolume, ?PassTouches, ?LinkNumber, " +
|
||||
"?MediaURL, ?DynAttrs)";
|
||||
|
||||
"?CollisionSoundVolume, ?PassTouches, " +
|
||||
"?LinkNumber, ?MediaURL, " +
|
||||
"?PhysicsShapeType, ?Density, ?GravityModifier, " +
|
||||
"?Friction, ?Restitution, ?DynAttrs)";
|
||||
|
||||
FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
|
||||
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
|
||||
cmd.CommandText = "replace into primshapes (" +
|
||||
"UUID, Shape, ScaleX, ScaleY, " +
|
||||
"ScaleZ, PCode, PathBegin, PathEnd, " +
|
||||
|
@ -234,9 +240,9 @@ namespace OpenSim.Data.MySQL
|
|||
"?ProfileEnd, ?ProfileCurve, " +
|
||||
"?ProfileHollow, ?Texture, ?ExtraParams, " +
|
||||
"?State, ?Media)";
|
||||
|
||||
|
||||
FillShapeCommand(cmd, prim);
|
||||
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +588,7 @@ namespace OpenSim.Data.MySQL
|
|||
cmd.CommandText = "insert into terrain (RegionUUID, " +
|
||||
"Revision, Heightfield) values (?RegionUUID, " +
|
||||
"1, ?Heightfield)";
|
||||
|
||||
|
||||
cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
|
@ -741,7 +747,7 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
//No result, so store our default windlight profile and return it
|
||||
nWP.regionID = regionUUID;
|
||||
StoreRegionWindlightSettings(nWP);
|
||||
// StoreRegionWindlightSettings(nWP);
|
||||
return nWP;
|
||||
}
|
||||
else
|
||||
|
@ -1097,7 +1103,8 @@ namespace OpenSim.Data.MySQL
|
|||
"?SunPosition, ?Covenant, ?CovenantChangedDateTime, ?Sandbox, " +
|
||||
"?SunVectorX, ?SunVectorY, ?SunVectorZ, " +
|
||||
"?LoadedCreationDateTime, ?LoadedCreationID, " +
|
||||
"?TerrainImageID, ?TelehubObject, ?ParcelImageID) ";
|
||||
"?TerrainImageID, " +
|
||||
"?TelehubObject, ?ParcelImageID)";
|
||||
|
||||
FillRegionSettingsCommand(cmd, rs);
|
||||
|
||||
|
@ -1300,6 +1307,12 @@ namespace OpenSim.Data.MySQL
|
|||
else
|
||||
prim.DynAttrs = new DAMap();
|
||||
|
||||
prim.PhysicsShapeType = (byte)Convert.ToInt32(row["PhysicsShapeType"].ToString());
|
||||
prim.Density = (float)(double)row["Density"];
|
||||
prim.GravityModifier = (float)(double)row["GravityModifier"];
|
||||
prim.Friction = (float)(double)row["Friction"];
|
||||
prim.Bounciness = (float)(double)row["Restitution"];
|
||||
|
||||
return prim;
|
||||
}
|
||||
|
||||
|
@ -1646,6 +1659,12 @@ namespace OpenSim.Data.MySQL
|
|||
cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
|
||||
cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
|
||||
|
||||
cmd.Parameters.AddWithValue("PhysicsShapeType", prim.PhysicsShapeType);
|
||||
cmd.Parameters.AddWithValue("Density", (double)prim.Density);
|
||||
cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier);
|
||||
cmd.Parameters.AddWithValue("Friction", (double)prim.Friction);
|
||||
cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness);
|
||||
|
||||
if (prim.DynAttrs.Count > 0)
|
||||
cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml());
|
||||
else
|
||||
|
@ -1728,6 +1747,7 @@ namespace OpenSim.Data.MySQL
|
|||
cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime);
|
||||
cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID);
|
||||
cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID);
|
||||
|
||||
cmd.Parameters.AddWithValue("ParcelImageID", settings.ParcelImageID);
|
||||
cmd.Parameters.AddWithValue("TelehubObject", settings.TelehubObject);
|
||||
}
|
||||
|
|
|
@ -910,3 +910,16 @@ BEGIN;
|
|||
ALTER TABLE prims ADD COLUMN DynAttrs TEXT;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 47 #---------------- Extra prim params
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE prims ADD COLUMN `PhysicsShapeType` tinyint(4) NOT NULL default '0';
|
||||
ALTER TABLE prims ADD COLUMN `Density` double NOT NULL default '1000';
|
||||
ALTER TABLE prims ADD COLUMN `GravityModifier` double NOT NULL default '1';
|
||||
ALTER TABLE prims ADD COLUMN `Friction` double NOT NULL default '0.6';
|
||||
ALTER TABLE prims ADD COLUMN `Restitution` double NOT NULL default '0.5';
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
|
|
@ -168,6 +168,10 @@ namespace OpenSim.Framework
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate the key used for storing separate data stores.
|
||||
/// </summary>
|
||||
/// <param name='key'></param>
|
||||
private static void ValidateKey(string key)
|
||||
{
|
||||
if (key.Length < MIN_STORE_NAME_LENGTH)
|
||||
|
@ -188,7 +192,8 @@ namespace OpenSim.Framework
|
|||
}
|
||||
|
||||
public void Add(KeyValuePair<string, OSDMap> kvp)
|
||||
{
|
||||
{
|
||||
ValidateKey(kvp.Key);
|
||||
lock (this)
|
||||
m_map.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
|
|
@ -27,20 +27,24 @@
|
|||
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public interface IScriptHost
|
||||
public enum PhysShapeType : byte
|
||||
{
|
||||
string Name { get; set; }
|
||||
string Description { get; set; }
|
||||
prim = 0,
|
||||
none = 1,
|
||||
convex = 2,
|
||||
|
||||
UUID UUID { get; }
|
||||
UUID OwnerID { get; }
|
||||
UUID CreatorID { get; }
|
||||
Vector3 AbsolutePosition { get; }
|
||||
invalid = 255 // use to mark invalid data in ExtraPhysicsData
|
||||
}
|
||||
|
||||
public struct ExtraPhysicsData
|
||||
{
|
||||
public float Density;
|
||||
public float GravitationModifier;
|
||||
public float Friction;
|
||||
public float Bounce;
|
||||
public PhysShapeType PhysShapeType;
|
||||
|
||||
string SitName { get; set; }
|
||||
string TouchName { get; set; }
|
||||
void SetText(string text, Vector3 color, double alpha);
|
||||
}
|
||||
}
|
|
@ -714,7 +714,7 @@ namespace OpenSim
|
|||
|
||||
return new Scene(
|
||||
regionInfo, circuitManager, sceneGridService,
|
||||
simDataService, estateDataService, false,
|
||||
simDataService, estateDataService,
|
||||
Config, m_version);
|
||||
}
|
||||
|
||||
|
|
|
@ -720,7 +720,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public Scene(RegionInfo regInfo, AgentCircuitManager authen,
|
||||
SceneCommunicationService sceneGridService,
|
||||
ISimulationDataService simDataService, IEstateDataService estateDataService,
|
||||
bool dumpAssetsToFile,
|
||||
IConfigSource config, string simulatorVersion)
|
||||
: this(regInfo)
|
||||
{
|
||||
|
@ -811,8 +810,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
RegisterDefaultSceneEvents();
|
||||
|
||||
DumpAssetsToFile = dumpAssetsToFile;
|
||||
|
||||
// XXX: Don't set the public property since we don't want to activate here. This needs to be handled
|
||||
// better in the future.
|
||||
m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts;
|
||||
|
@ -4482,19 +4479,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
#region Script Engine
|
||||
|
||||
private List<ScriptEngineInterface> ScriptEngines = new List<ScriptEngineInterface>();
|
||||
public bool DumpAssetsToFile;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="scriptEngine"></param>
|
||||
public void AddScriptEngine(ScriptEngineInterface scriptEngine)
|
||||
{
|
||||
ScriptEngines.Add(scriptEngine);
|
||||
scriptEngine.InitializeEngine(this);
|
||||
}
|
||||
|
||||
private bool ScriptDanger(SceneObjectPart part,Vector3 pos)
|
||||
{
|
||||
ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
|
||||
|
|
|
@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
#endregion Enumerations
|
||||
|
||||
public class SceneObjectPart : IScriptHost, ISceneEntity
|
||||
public class SceneObjectPart : ISceneEntity
|
||||
{
|
||||
/// <value>
|
||||
/// Denote all sides of the prim
|
||||
|
@ -302,6 +302,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
protected Vector3 m_lastAcceleration;
|
||||
protected Vector3 m_lastAngularVelocity;
|
||||
protected int m_lastTerseSent;
|
||||
|
||||
protected byte m_physicsShapeType = (byte)PhysShapeType.prim;
|
||||
// TODO: Implement these
|
||||
//protected float m_density = 1000.0f; // in kg/m^3
|
||||
//protected float m_gravitymod = 1.0f;
|
||||
//protected float m_friction = 0.6f; // wood
|
||||
//protected float m_bounce = 0.5f; // wood
|
||||
|
||||
/// <summary>
|
||||
/// Stores media texture data
|
||||
|
@ -1322,6 +1329,69 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
set { m_collisionSoundVolume = value; }
|
||||
}
|
||||
|
||||
public byte DefaultPhysicsShapeType()
|
||||
{
|
||||
byte type;
|
||||
|
||||
if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh))
|
||||
type = (byte)PhysShapeType.convex;
|
||||
else
|
||||
type = (byte)PhysShapeType.prim;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public byte PhysicsShapeType
|
||||
{
|
||||
get { return m_physicsShapeType; }
|
||||
set
|
||||
{
|
||||
byte oldv = m_physicsShapeType;
|
||||
|
||||
if (value >= 0 && value <= (byte)PhysShapeType.convex)
|
||||
{
|
||||
if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this)
|
||||
m_physicsShapeType = DefaultPhysicsShapeType();
|
||||
else
|
||||
m_physicsShapeType = value;
|
||||
}
|
||||
else
|
||||
m_physicsShapeType = DefaultPhysicsShapeType();
|
||||
|
||||
if (m_physicsShapeType != oldv && ParentGroup != null)
|
||||
{
|
||||
if (m_physicsShapeType == (byte)PhysShapeType.none)
|
||||
{
|
||||
if (PhysActor != null)
|
||||
{
|
||||
Velocity = new Vector3(0, 0, 0);
|
||||
Acceleration = new Vector3(0, 0, 0);
|
||||
if (ParentGroup.RootPart == this)
|
||||
AngularVelocity = new Vector3(0, 0, 0);
|
||||
ParentGroup.Scene.RemovePhysicalPrim(1);
|
||||
RemoveFromPhysics();
|
||||
}
|
||||
}
|
||||
else if (PhysActor == null)
|
||||
{
|
||||
ApplyPhysics((uint)Flags, VolumeDetectActive);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Update physics actor
|
||||
}
|
||||
|
||||
if (ParentGroup != null)
|
||||
ParentGroup.HasGroupChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float Density { get; set; }
|
||||
public float GravityModifier { get; set; }
|
||||
public float Friction { get; set; }
|
||||
public float Bounciness { get; set; }
|
||||
|
||||
#endregion Public Properties with only Get
|
||||
|
||||
private uint ApplyMask(uint val, bool set, uint mask)
|
||||
|
@ -1523,9 +1593,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (!ParentGroup.Scene.CollidablePrims)
|
||||
return;
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}",
|
||||
// Name, LocalId, UUID, m_physicalPrim);
|
||||
if (PhysicsShapeType == (byte)PhysShapeType.none)
|
||||
return;
|
||||
|
||||
bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0;
|
||||
bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0;
|
||||
|
@ -3878,6 +3947,26 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateExtraPhysics(ExtraPhysicsData physdata)
|
||||
{
|
||||
if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
|
||||
return;
|
||||
|
||||
if (PhysicsShapeType != (byte)physdata.PhysShapeType)
|
||||
{
|
||||
PhysicsShapeType = (byte)physdata.PhysShapeType;
|
||||
|
||||
}
|
||||
|
||||
if(Density != physdata.Density)
|
||||
Density = physdata.Density;
|
||||
if(GravityModifier != physdata.GravitationModifier)
|
||||
GravityModifier = physdata.GravitationModifier;
|
||||
if(Friction != physdata.Friction)
|
||||
Friction = physdata.Friction;
|
||||
if(Bounciness != physdata.Bounce)
|
||||
Bounciness = physdata.Bounce;
|
||||
}
|
||||
/// <summary>
|
||||
/// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
|
||||
/// </summary>
|
||||
|
@ -3949,6 +4038,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
if (SetPhantom
|
||||
|| ParentGroup.IsAttachment
|
||||
|| PhysicsShapeType == (byte)PhysShapeType.none
|
||||
|| (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
|
||||
{
|
||||
AddFlag(PrimFlags.Phantom);
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* 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
|
||||
* 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 OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||
{
|
||||
public class NullScriptHost : IScriptHost
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Vector3 m_pos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30);
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Object"; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string SitName
|
||||
{
|
||||
get { return String.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string TouchName
|
||||
{
|
||||
get { return String.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public string Description
|
||||
{
|
||||
get { return String.Empty; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public UUID UUID
|
||||
{
|
||||
get { return UUID.Zero; }
|
||||
}
|
||||
|
||||
public UUID OwnerID
|
||||
{
|
||||
get { return UUID.Zero; }
|
||||
}
|
||||
|
||||
public UUID CreatorID
|
||||
{
|
||||
get { return UUID.Zero; }
|
||||
}
|
||||
|
||||
public Vector3 AbsolutePosition
|
||||
{
|
||||
get { return m_pos; }
|
||||
}
|
||||
|
||||
public void SetText(string text, Vector3 color, double alpha)
|
||||
{
|
||||
m_log.Warn("Tried to SetText "+text+" on NullScriptHost");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* 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
|
||||
* 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 OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
//TODO: WHERE TO PLACE THIS?
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||
{
|
||||
public interface ScriptEngineInterface
|
||||
{
|
||||
void InitializeEngine(Scene Sceneworld);
|
||||
void Shutdown();
|
||||
// void StartScript(string ScriptID, IScriptHost ObjectID);
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* 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
|
||||
* 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 OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Original code: Tedd Hansen */
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||
{
|
||||
public class ScriptEngineLoader
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public ScriptEngineInterface LoadScriptEngine(string EngineName)
|
||||
{
|
||||
ScriptEngineInterface ret = null;
|
||||
try
|
||||
{
|
||||
ret =
|
||||
LoadAndInitAssembly(
|
||||
Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine." + EngineName + ".dll"),
|
||||
"OpenSim.Region.ScriptEngine." + EngineName + ".ScriptEngine");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[ScriptEngine]: " +
|
||||
"Error loading assembly \"" + EngineName + "\": " + e.Message + ", " +
|
||||
e.StackTrace.ToString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Does actual loading and initialization of script Assembly
|
||||
/// </summary>
|
||||
/// <param name="FreeAppDomain">AppDomain to load script into</param>
|
||||
/// <param name="FileName">FileName of script assembly (.dll)</param>
|
||||
/// <returns></returns>
|
||||
private ScriptEngineInterface LoadAndInitAssembly(string FileName, string NameSpace)
|
||||
{
|
||||
//Common.SendToDebug("Loading ScriptEngine Assembly " + FileName);
|
||||
// Load .Net Assembly (.dll)
|
||||
// Initialize and return it
|
||||
|
||||
// TODO: Add error handling
|
||||
|
||||
Assembly a;
|
||||
//try
|
||||
//{
|
||||
|
||||
|
||||
// Load to default appdomain (temporary)
|
||||
a = Assembly.LoadFrom(FileName);
|
||||
// Load to specified appdomain
|
||||
// TODO: Insert security
|
||||
//a = FreeAppDomain.Load(FileName);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("[ScriptEngine]: Error loading assembly \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
|
||||
//m_log.Debug("Loading: " + FileName);
|
||||
//foreach (Type _t in a.GetTypes())
|
||||
//{
|
||||
// m_log.Debug("Type: " + _t.ToString());
|
||||
//}
|
||||
|
||||
Type t;
|
||||
//try
|
||||
//{
|
||||
t = a.GetType(NameSpace, true);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
ScriptEngineInterface ret;
|
||||
//try
|
||||
//{
|
||||
ret = (ScriptEngineInterface) Activator.CreateInstance(t);
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* 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
|
||||
* 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 OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes.Scripting
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility functions for use by scripts manipulating the scene.
|
||||
/// </summary>
|
||||
public static class ScriptUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Get an asset id given an item name and an item type.
|
||||
/// </summary>
|
||||
/// <returns>UUID.Zero if the name and type did not match any item.</returns>
|
||||
/// <param name='part'></param>
|
||||
/// <param name='name'></param>
|
||||
/// <param name='type'></param>
|
||||
public static UUID GetAssetIdFromItemName(SceneObjectPart part, string name, int type)
|
||||
{
|
||||
TaskInventoryItem item = part.Inventory.GetInventoryItem(name);
|
||||
|
||||
if (item != null && item.Type == type)
|
||||
return item.AssetID;
|
||||
else
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// accepts a valid UUID, -or- a name of an inventory item.
|
||||
/// Returns a valid UUID or UUID.Zero if key invalid and item not found
|
||||
/// in prim inventory.
|
||||
/// </summary>
|
||||
/// <param name="part">Scene object part to search for inventory item</param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier)
|
||||
{
|
||||
UUID key;
|
||||
|
||||
// if we can parse the string as a key, use it.
|
||||
// else try to locate the name in inventory of object. found returns key,
|
||||
// not found returns UUID.Zero
|
||||
if (!UUID.TryParse(identifier, out key))
|
||||
{
|
||||
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
|
||||
|
||||
if (item != null)
|
||||
key = item.AssetID;
|
||||
else
|
||||
key = UUID.Zero;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the UUID of the asset matching the specified key or name
|
||||
/// and asset type.
|
||||
/// </summary>
|
||||
/// <param name="part">Scene object part to search for inventory item</param>
|
||||
/// <param name="identifier"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type)
|
||||
{
|
||||
UUID key;
|
||||
|
||||
if (!UUID.TryParse(identifier, out key))
|
||||
{
|
||||
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
|
||||
if (item != null && item.Type == (int)type)
|
||||
key = item.AssetID;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -367,6 +367,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2);
|
||||
m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3);
|
||||
m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4);
|
||||
|
||||
m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType);
|
||||
m_SOPXmlProcessors.Add("Density", ProcessDensity);
|
||||
m_SOPXmlProcessors.Add("Friction", ProcessFriction);
|
||||
m_SOPXmlProcessors.Add("Bounce", ProcessBounce);
|
||||
m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier);
|
||||
|
||||
#endregion
|
||||
|
||||
#region TaskInventoryXmlProcessors initialization
|
||||
|
@ -594,6 +601,31 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty);
|
||||
}
|
||||
|
||||
private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty);
|
||||
}
|
||||
|
||||
private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty);
|
||||
}
|
||||
|
||||
private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty);
|
||||
}
|
||||
|
||||
private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty);
|
||||
}
|
||||
|
||||
private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty);
|
||||
}
|
||||
|
||||
private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
List<string> errorNodeNames;
|
||||
|
@ -1257,6 +1289,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString());
|
||||
writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString());
|
||||
|
||||
if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType())
|
||||
writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
|
||||
if (sop.Density != 1000.0f)
|
||||
writer.WriteElementString("Density", sop.Density.ToString().ToLower());
|
||||
if (sop.Friction != 0.6f)
|
||||
writer.WriteElementString("Friction", sop.Friction.ToString().ToLower());
|
||||
if (sop.Bounciness != 0.5f)
|
||||
writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower());
|
||||
if (sop.GravityModifier != 1.0f)
|
||||
writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower());
|
||||
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ using OpenMetaverse.StructuredData;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Scripting;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
@ -256,10 +257,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
[ScriptInvocation]
|
||||
public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID)
|
||||
public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier)
|
||||
{
|
||||
UUID reqID = UUID.Random();
|
||||
Util.FireAndForget(delegate(object o) { DoJsonReadNotecard(reqID,hostID,scriptID,storeID,path,assetID); });
|
||||
Util.FireAndForget(o => DoJsonReadNotecard(reqID, hostID, scriptID, storeID, path, notecardIdentifier));
|
||||
return reqID;
|
||||
}
|
||||
|
||||
|
@ -463,14 +464,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
///
|
||||
/// </summary>
|
||||
// -----------------------------------------------------------------
|
||||
private void DoJsonReadNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, UUID assetID)
|
||||
private void DoJsonReadNotecard(
|
||||
UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier)
|
||||
{
|
||||
UUID assetID;
|
||||
|
||||
if (!UUID.TryParse(notecardIdentifier, out assetID))
|
||||
{
|
||||
SceneObjectPart part = m_scene.GetSceneObjectPart(hostID);
|
||||
assetID = ScriptUtils.GetAssetIdFromItemName(part, notecardIdentifier, (int)AssetType.Notecard);
|
||||
}
|
||||
|
||||
AssetBase a = m_scene.AssetService.Get(assetID.ToString());
|
||||
if (a == null)
|
||||
GenerateRuntimeError(String.Format("Unable to find notecard asset {0}",assetID));
|
||||
GenerateRuntimeError(String.Format("Unable to find notecard asset {0}", assetID));
|
||||
|
||||
if (a.Type != (sbyte)AssetType.Notecard)
|
||||
GenerateRuntimeError(String.Format("Invalid notecard asset {0}",assetID));
|
||||
GenerateRuntimeError(String.Format("Invalid notecard asset {0}", assetID));
|
||||
|
||||
m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID);
|
||||
|
||||
|
@ -483,11 +493,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}",e.Message);
|
||||
m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}", e.Message);
|
||||
}
|
||||
|
||||
GenerateRuntimeError(String.Format("Json parsing failed for {0}",assetID.ToString()));
|
||||
m_comms.DispatchReply(scriptID,0,"",reqID.ToString());
|
||||
GenerateRuntimeError(String.Format("Json parsing failed for {0}", assetID));
|
||||
m_comms.DispatchReply(scriptID, 0, "", reqID.ToString());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
|
|
@ -62,6 +62,7 @@ public static class BSParam
|
|||
public static bool ShouldMeshSculptedPrim { get; private set; } // cause scuplted prims to get meshed
|
||||
public static bool ShouldForceSimplePrimMeshing { get; private set; } // if a cube or sphere, let Bullet do internal shapes
|
||||
public static bool ShouldUseHullsForPhysicalObjects { get; private set; } // 'true' if should create hulls for physical objects
|
||||
public static bool ShouldRemoveZeroWidthTriangles { get; private set; }
|
||||
|
||||
public static float TerrainImplementation { get; private set; }
|
||||
public static float TerrainFriction { get; private set; }
|
||||
|
@ -218,6 +219,11 @@ public static class BSParam
|
|||
(s,cf,p,v) => { ShouldUseHullsForPhysicalObjects = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
|
||||
(s) => { return BSParam.NumericBool(ShouldUseHullsForPhysicalObjects); },
|
||||
(s,p,l,v) => { ShouldUseHullsForPhysicalObjects = BSParam.BoolNumeric(v); } ),
|
||||
new ParameterDefn("ShouldRemoveZeroWidthTriangles", "If true, remove degenerate triangles from meshes",
|
||||
ConfigurationParameters.numericTrue,
|
||||
(s,cf,p,v) => { ShouldRemoveZeroWidthTriangles = cf.GetBoolean(p, BSParam.BoolNumeric(v)); },
|
||||
(s) => { return BSParam.NumericBool(ShouldRemoveZeroWidthTriangles); },
|
||||
(s,p,l,v) => { ShouldRemoveZeroWidthTriangles = BSParam.BoolNumeric(v); } ),
|
||||
|
||||
new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
|
||||
32f,
|
||||
|
|
|
@ -75,6 +75,7 @@ public abstract class BSPhysObject : PhysicsActor
|
|||
PhysicsScene = parentScene;
|
||||
LocalID = localID;
|
||||
PhysObjectName = name;
|
||||
Name = name; // PhysicsActor also has the name of the object. Someday consolidate.
|
||||
TypeName = typeName;
|
||||
|
||||
// We don't have any physical representation yet.
|
||||
|
|
|
@ -608,7 +608,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// Since we're recreating new, get rid of the reference to the previous shape
|
||||
DereferenceShape(prim.PhysShape, shapeCallback);
|
||||
|
||||
newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod);
|
||||
newShape = CreatePhysicalMesh(prim, newMeshKey, prim.BaseShape, prim.Size, lod);
|
||||
// Take evasive action if the mesh was not constructed.
|
||||
newShape = VerifyMeshCreated(newShape, prim);
|
||||
|
||||
|
@ -619,7 +619,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
return true; // 'true' means a new shape has been added to this prim
|
||||
}
|
||||
|
||||
private BulletShape CreatePhysicalMesh(string objName, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
|
||||
private BulletShape CreatePhysicalMesh(BSPhysObject prim, System.UInt64 newMeshKey, PrimitiveBaseShape pbs, OMV.Vector3 size, float lod)
|
||||
{
|
||||
BulletShape newShape = new BulletShape();
|
||||
|
||||
|
@ -631,7 +631,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
IMesh meshData = PhysicsScene.mesher.CreateMesh(objName, pbs, size, lod,
|
||||
IMesh meshData = PhysicsScene.mesher.CreateMesh(prim.PhysObjectName, pbs, size, lod,
|
||||
false, // say it is not physical so a bounding box is not built
|
||||
false // do not cache the mesh and do not use previously built versions
|
||||
);
|
||||
|
@ -640,41 +640,54 @@ public sealed class BSShapeCollection : IDisposable
|
|||
{
|
||||
|
||||
int[] indices = meshData.getIndexListAsInt();
|
||||
// int realIndicesIndex = indices.Length;
|
||||
int realIndicesIndex = indices.Length;
|
||||
float[] verticesAsFloats = meshData.getVertexListAsFloat();
|
||||
|
||||
// Remove degenerate triangles. These are triangles with two of the vertices
|
||||
// are the same. This is complicated by the problem that vertices are not
|
||||
// made unique in sculpties so we have to compare the values in the vertex.
|
||||
int realIndicesIndex = 0;
|
||||
for (int tri = 0; tri < indices.Length; tri += 3)
|
||||
if (BSParam.ShouldRemoveZeroWidthTriangles)
|
||||
{
|
||||
int v1 = indices[tri + 0] * 3;
|
||||
int v2 = indices[tri + 1] * 3;
|
||||
int v3 = indices[tri + 2] * 3;
|
||||
if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0]
|
||||
&& verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1]
|
||||
&& verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2] )
|
||||
|| ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0]
|
||||
&& verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1]
|
||||
&& verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2] )
|
||||
|| ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0]
|
||||
&& verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1]
|
||||
&& verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2] ) )
|
||||
)
|
||||
// Remove degenerate triangles. These are triangles with two of the vertices
|
||||
// are the same. This is complicated by the problem that vertices are not
|
||||
// made unique in sculpties so we have to compare the values in the vertex.
|
||||
realIndicesIndex = 0;
|
||||
for (int tri = 0; tri < indices.Length; tri += 3)
|
||||
{
|
||||
// None of the vertices of the triangles are the same. This is a good triangle;
|
||||
indices[realIndicesIndex + 0] = indices[tri + 0];
|
||||
indices[realIndicesIndex + 1] = indices[tri + 1];
|
||||
indices[realIndicesIndex + 2] = indices[tri + 2];
|
||||
realIndicesIndex += 3;
|
||||
// Compute displacements into vertex array for each vertex of the triangle
|
||||
int v1 = indices[tri + 0] * 3;
|
||||
int v2 = indices[tri + 1] * 3;
|
||||
int v3 = indices[tri + 2] * 3;
|
||||
// Check to see if any two of the vertices are the same
|
||||
if (!( ( verticesAsFloats[v1 + 0] == verticesAsFloats[v2 + 0]
|
||||
&& verticesAsFloats[v1 + 1] == verticesAsFloats[v2 + 1]
|
||||
&& verticesAsFloats[v1 + 2] == verticesAsFloats[v2 + 2])
|
||||
|| ( verticesAsFloats[v2 + 0] == verticesAsFloats[v3 + 0]
|
||||
&& verticesAsFloats[v2 + 1] == verticesAsFloats[v3 + 1]
|
||||
&& verticesAsFloats[v2 + 2] == verticesAsFloats[v3 + 2])
|
||||
|| ( verticesAsFloats[v1 + 0] == verticesAsFloats[v3 + 0]
|
||||
&& verticesAsFloats[v1 + 1] == verticesAsFloats[v3 + 1]
|
||||
&& verticesAsFloats[v1 + 2] == verticesAsFloats[v3 + 2]) )
|
||||
)
|
||||
{
|
||||
// None of the vertices of the triangles are the same. This is a good triangle;
|
||||
indices[realIndicesIndex + 0] = indices[tri + 0];
|
||||
indices[realIndicesIndex + 1] = indices[tri + 1];
|
||||
indices[realIndicesIndex + 2] = indices[tri + 2];
|
||||
realIndicesIndex += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
DetailLog("{0},BSShapeCollection.CreatePhysicalMesh,origTri={1},realTri={2},numVerts={3}",
|
||||
BSScene.DetailLogZero, indices.Length / 3, realIndicesIndex / 3, verticesAsFloats.Length / 3);
|
||||
|
||||
newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World,
|
||||
realIndicesIndex, indices, verticesAsFloats.Length/3, verticesAsFloats);
|
||||
if (realIndicesIndex != 0)
|
||||
{
|
||||
newShape = PhysicsScene.PE.CreateMeshShape(PhysicsScene.World,
|
||||
realIndicesIndex, indices, verticesAsFloats.Length / 3, verticesAsFloats);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhysicsScene.Logger.ErrorFormat("{0} All mesh triangles degenerate. Prim {1} at {2} in {3}",
|
||||
LogHeader, prim.PhysObjectName, prim.RawPosition, PhysicsScene.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
newShape.shapeKey = newMeshKey;
|
||||
|
@ -892,9 +905,11 @@ public sealed class BSShapeCollection : IDisposable
|
|||
// If this mesh has an underlying asset and we have not failed getting it before, fetch the asset
|
||||
if (prim.BaseShape.SculptEntry && !prim.LastAssetBuildFailed && prim.BaseShape.SculptTexture != OMV.UUID.Zero)
|
||||
{
|
||||
prim.LastAssetBuildFailed = true;
|
||||
BSPhysObject xprim = prim;
|
||||
DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lastFailed={1}", prim.LocalID, prim.LastAssetBuildFailed);
|
||||
// This will prevent looping through this code as we keep trying to get the failed shape
|
||||
prim.LastAssetBuildFailed = true;
|
||||
|
||||
BSPhysObject xprim = prim;
|
||||
Util.FireAndForget(delegate
|
||||
{
|
||||
RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod;
|
||||
|
@ -905,7 +920,7 @@ public sealed class BSShapeCollection : IDisposable
|
|||
{
|
||||
bool assetFound = false; // DEBUG DEBUG
|
||||
string mismatchIDs = String.Empty; // DEBUG DEBUG
|
||||
if (yprim.BaseShape.SculptEntry)
|
||||
if (asset != null && yprim.BaseShape.SculptEntry)
|
||||
{
|
||||
if (yprim.BaseShape.SculptTexture.ToString() == asset.ID)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@ using OpenSim.Region.CoreModules.World.Terrain;
|
|||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Animation;
|
||||
using OpenSim.Region.Framework.Scenes.Scripting;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
|
||||
|
@ -333,79 +334,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
}
|
||||
}
|
||||
|
||||
protected UUID InventoryKey(string name, int type)
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
|
||||
|
||||
if (item != null && item.Type == type)
|
||||
return item.AssetID;
|
||||
else
|
||||
return UUID.Zero;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// accepts a valid UUID, -or- a name of an inventory item.
|
||||
/// Returns a valid UUID or UUID.Zero if key invalid and item not found
|
||||
/// in prim inventory.
|
||||
/// </summary>
|
||||
/// <param name="k"></param>
|
||||
/// <returns></returns>
|
||||
protected UUID KeyOrName(string k)
|
||||
{
|
||||
UUID key;
|
||||
|
||||
// if we can parse the string as a key, use it.
|
||||
// else try to locate the name in inventory of object. found returns key,
|
||||
// not found returns UUID.Zero
|
||||
if (!UUID.TryParse(k, out key))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k);
|
||||
|
||||
if (item != null)
|
||||
key = item.AssetID;
|
||||
else
|
||||
key = UUID.Zero;
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the UUID of the asset matching the specified key or name
|
||||
/// and asset type.
|
||||
/// </summary>
|
||||
/// <param name="k"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
protected UUID KeyOrName(string k, AssetType type)
|
||||
{
|
||||
UUID key;
|
||||
|
||||
if (!UUID.TryParse(k, out key))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k);
|
||||
if (item != null && item.Type == (int)type)
|
||||
key = item.AssetID;
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> item in m_host.TaskInventory)
|
||||
{
|
||||
if (item.Value.Type == (int)type && item.Value.Name == k)
|
||||
{
|
||||
key = item.Value.ItemID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
//These are the implementations of the various ll-functions used by the LSL scripts.
|
||||
public LSL_Float llSin(double f)
|
||||
{
|
||||
|
@ -1816,7 +1744,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
UUID textureID = new UUID();
|
||||
|
||||
textureID = InventoryKey(texture, (int)AssetType.Texture);
|
||||
textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture);
|
||||
if (textureID == UUID.Zero)
|
||||
{
|
||||
if (!UUID.TryParse(texture, out textureID))
|
||||
|
@ -2450,7 +2378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.SendSound(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume, false, 0,
|
||||
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0,
|
||||
0, false, false);
|
||||
}
|
||||
}
|
||||
|
@ -2460,7 +2388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_host.AddScriptLPS(1);
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound),
|
||||
m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
|
||||
volume, 20, false);
|
||||
}
|
||||
}
|
||||
|
@ -2470,7 +2398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_host.AddScriptLPS(1);
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound),
|
||||
m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
|
||||
volume, 20, true);
|
||||
}
|
||||
}
|
||||
|
@ -2492,7 +2420,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.SendSound(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume, false, 0,
|
||||
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0,
|
||||
0, true, false);
|
||||
}
|
||||
}
|
||||
|
@ -2504,7 +2432,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.SendSound(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume, true, 0, 0,
|
||||
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, true, 0, 0,
|
||||
false, false);
|
||||
}
|
||||
}
|
||||
|
@ -2521,7 +2449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
if (m_SoundModule != null)
|
||||
m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0);
|
||||
m_SoundModule.PreloadSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 0);
|
||||
ScriptSleep(1000);
|
||||
}
|
||||
|
||||
|
@ -3352,7 +3280,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (presence != null)
|
||||
{
|
||||
// Do NOT try to parse UUID, animations cannot be triggered by ID
|
||||
UUID animID = InventoryKey(anim, (int)AssetType.Animation);
|
||||
UUID animID = ScriptUtils.GetAssetIdFromItemName(m_host, anim, (int)AssetType.Animation);
|
||||
if (animID == UUID.Zero)
|
||||
presence.Animator.AddAnimation(anim, m_host.UUID);
|
||||
else
|
||||
|
@ -3374,7 +3302,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
if (presence != null)
|
||||
{
|
||||
UUID animID = KeyOrName(anim);
|
||||
UUID animID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, anim);
|
||||
|
||||
if (animID == UUID.Zero)
|
||||
presence.Animator.RemoveAnimation(anim);
|
||||
|
@ -4319,7 +4247,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
private void DoLLTeleport(ScenePresence sp, string destination, Vector3 targetPos, Vector3 targetLookAt)
|
||||
{
|
||||
UUID assetID = KeyOrName(destination);
|
||||
UUID assetID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, destination);
|
||||
|
||||
// The destinaion is not an asset ID and also doesn't name a landmark.
|
||||
// Use it as a sim name
|
||||
|
@ -4386,7 +4314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_host.AddScriptLPS(1);
|
||||
|
||||
// TODO: Parameter check logic required.
|
||||
m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound);
|
||||
m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound);
|
||||
m_host.CollisionSoundVolume = (float)impact_volume;
|
||||
}
|
||||
|
||||
|
@ -5912,7 +5840,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.TriggerSoundLimited(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume,
|
||||
ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume,
|
||||
bottom_south_west, top_north_east);
|
||||
}
|
||||
}
|
||||
|
@ -6346,7 +6274,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
|
||||
prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1));
|
||||
prules.Texture = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, rules.GetLSLStringItem(i + 1));
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_SRC_BURST_RATE:
|
||||
|
@ -7269,9 +7197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
UUID sculptId;
|
||||
|
||||
if (!UUID.TryParse(map, out sculptId))
|
||||
{
|
||||
sculptId = InventoryKey(map, (int)AssetType.Texture);
|
||||
}
|
||||
sculptId = ScriptUtils.GetAssetIdFromItemName(m_host, map, (int)AssetType.Texture);
|
||||
|
||||
if (sculptId == UUID.Zero)
|
||||
return;
|
||||
|
@ -7668,6 +7594,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
part.ScriptSetPhysicsStatus(physics);
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
|
||||
if (remain < 1)
|
||||
return null;
|
||||
|
||||
int shape_type = rules.GetLSLIntegerItem(idx++);
|
||||
|
||||
ExtraPhysicsData physdata = new ExtraPhysicsData();
|
||||
physdata.Density = part.Density;
|
||||
physdata.Bounce = part.Bounciness;
|
||||
physdata.GravitationModifier = part.GravityModifier;
|
||||
physdata.PhysShapeType = (PhysShapeType)shape_type;
|
||||
|
||||
part.UpdateExtraPhysics(physdata);
|
||||
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
|
||||
if (remain < 1)
|
||||
return null;
|
||||
|
|
|
@ -661,6 +661,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
public const int PRIM_MEDIA_PERM_GROUP = 2;
|
||||
public const int PRIM_MEDIA_PERM_ANYONE = 4;
|
||||
|
||||
public const int PRIM_PHYSICS_SHAPE_TYPE = 30;
|
||||
public const int PRIM_PHYSICS_SHAPE_PRIM = 0;
|
||||
public const int PRIM_PHYSICS_SHAPE_CONVEX = 2;
|
||||
public const int PRIM_PHYSICS_SHAPE_NONE = 1;
|
||||
|
||||
public const int PRIM_PHYSICS_MATERIAL = 31;
|
||||
public const int DENSITY = 1;
|
||||
public const int FRICTION = 2;
|
||||
public const int RESTITUTION = 4;
|
||||
public const int GRAVITY_MULTIPLIER = 8;
|
||||
|
||||
// extra constants for llSetPrimMediaParams
|
||||
public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0);
|
||||
public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000);
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace OpenSim.Tests.Common
|
|||
SceneCommunicationService scs = new SceneCommunicationService();
|
||||
|
||||
TestScene testScene = new TestScene(
|
||||
regInfo, m_acm, scs, m_simDataService, m_estateDataService, false, configSource, null);
|
||||
regInfo, m_acm, scs, m_simDataService, m_estateDataService, configSource, null);
|
||||
|
||||
INonSharedRegionModule godsModule = new GodsModule();
|
||||
godsModule.Initialise(new IniConfigSource());
|
||||
|
|
|
@ -41,10 +41,9 @@ namespace OpenSim.Tests.Common.Mock
|
|||
public TestScene(
|
||||
RegionInfo regInfo, AgentCircuitManager authen,
|
||||
SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService,
|
||||
bool dumpAssetsToFile,
|
||||
IConfigSource config, string simulatorVersion)
|
||||
: base(regInfo, authen, sceneGridService, simDataService, estateDataService,
|
||||
dumpAssetsToFile, config, simulatorVersion)
|
||||
config, simulatorVersion)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -45,4 +45,8 @@ ExternalHostName = "SYSTEMIP"
|
|||
; *
|
||||
|
||||
; RegionType = "Mainland"
|
||||
|
||||
; *
|
||||
; * UUID of texture to use as a maptile for this region.
|
||||
; * Only set if you have disabled dynamic generation of the map tile from the region contents.
|
||||
; MaptileStaticUUID = "00000000-0000-0000-0000-000000000000"
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue