From 3de3b9e63c07bc4b8e6c76d60167f9ead8a07f49 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Tue, 13 Mar 2012 17:56:32 +0000
Subject: initial suport for ExtraPhysical parts parameters. Reading from
llclientView to SOP including SOPserialization (not to databases). No action
on physics still. No send to viewer, etc
---
OpenSim/Framework/ExtraPhysicsData.cs | 50 +++++++++
OpenSim/Framework/IClientAPI.cs | 2 +-
.../Region/ClientStack/Linden/UDP/LLClientView.cs | 29 +++++-
OpenSim/Region/Framework/Scenes/SOPMaterial.cs | 95 +++++++++++++++++
OpenSim/Region/Framework/Scenes/Scene.cs | 2 +-
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 11 +-
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 114 ++++++++++++++++++---
7 files changed, 281 insertions(+), 22 deletions(-)
create mode 100644 OpenSim/Framework/ExtraPhysicsData.cs
create mode 100644 OpenSim/Region/Framework/Scenes/SOPMaterial.cs
diff --git a/OpenSim/Framework/ExtraPhysicsData.cs b/OpenSim/Framework/ExtraPhysicsData.cs
new file mode 100644
index 0000000..9e7334f
--- /dev/null
+++ b/OpenSim/Framework/ExtraPhysicsData.cs
@@ -0,0 +1,50 @@
+/*
+ * 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 OpenMetaverse;
+
+namespace OpenSim.Framework
+{
+ public enum PhysShapeType : byte
+ {
+ prim = 0,
+ none = 1,
+ convex = 2,
+
+ 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;
+
+ }
+}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 1bd4749..c70b2a0 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -124,7 +124,7 @@ namespace OpenSim.Framework
public delegate void ObjectDrop(uint localID, IClientAPI remoteClient);
public delegate void UpdatePrimFlags(
- uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, IClientAPI remoteClient);
+ uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom,ExtraPhysicsData PhysData, IClientAPI remoteClient);
public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient);
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 18af623..23beaec 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -7006,10 +7006,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// 46,47,48 are special positions within the packet
// This may change so perhaps we need a better way
// of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
- bool UsePhysics = (data[46] != 0) ? true : false;
- bool IsTemporary = (data[47] != 0) ? true : false;
- bool IsPhantom = (data[48] != 0) ? true : false;
- handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
+ /*
+ bool UsePhysics = (data[46] != 0) ? true : false;
+ bool IsTemporary = (data[47] != 0) ? true : false;
+ bool IsPhantom = (data[48] != 0) ? true : false;
+ handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
+ */
+ bool UsePhysics = flags.AgentData.UsePhysics;
+ bool IsPhantom = flags.AgentData.IsPhantom;
+ bool IsTemporary = flags.AgentData.IsTemporary;
+ ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
+ ExtraPhysicsData physdata = new ExtraPhysicsData();
+
+ if (blocks == null || blocks.Length == 0)
+ {
+ physdata.PhysShapeType = PhysShapeType.invalid;
+ }
+ else
+ {
+ ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
+ physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
+ physdata.Bounce = phsblock.Restitution;
+ physdata.Density = phsblock.Density;
+ physdata.Friction = phsblock.Friction;
+ }
+ handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
}
return true;
}
diff --git a/OpenSim/Region/Framework/Scenes/SOPMaterial.cs b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs
new file mode 100644
index 0000000..10ac37c
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs
@@ -0,0 +1,95 @@
+/*
+ * 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
+{
+ public static class SOPMaterialData
+ {
+ public enum SopMaterial : int // redundante and not in use for now
+ {
+ Stone = 0,
+ Metal = 1,
+ Glass = 2,
+ Wood = 3,
+ Flesh = 4,
+ Plastic = 5,
+ Rubber = 6,
+ light = 7 // compatibility with old viewers
+ }
+
+ private struct MaterialData
+ {
+ public float friction;
+ public float bounce;
+ public MaterialData(float f, float b)
+ {
+ friction = f;
+ bounce = b;
+ }
+ }
+
+ private static MaterialData[] m_materialdata = {
+ new MaterialData(0.8f,0.4f), // Stone
+ new MaterialData(0.3f,0.4f), // Metal
+ new MaterialData(0.2f,0.7f), // Glass
+ new MaterialData(0.6f,0.5f), // Wood
+ new MaterialData(0.9f,0.3f), // Flesh
+ new MaterialData(0.4f,0.7f), // Plastic
+ new MaterialData(0.9f,0.95f), // Rubber
+ new MaterialData(0.0f,0.0f) // light ??
+ };
+
+ public static Material MaxMaterial
+ {
+ get { return (Material)(m_materialdata.Length - 1); }
+ }
+
+ public static float friction(Material material)
+ {
+ int indx = (int)material;
+ if (indx < m_materialdata.Length)
+ return (m_materialdata[indx].friction);
+ else
+ return 0;
+ }
+
+ public static float bounce(Material material)
+ {
+ int indx = (int)material;
+ if (indx < m_materialdata.Length)
+ return (m_materialdata[indx].bounce);
+ else
+ return 0;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a3358a5..24e6eb1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4882,7 +4882,7 @@ Environment.Exit(1);
private void CheckHeartbeat()
{
- if (m_firstHeartbeat)
+// if (m_firstHeartbeat)
return;
if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index e6e3ad0..7b77ea0 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1536,7 +1536,7 @@ namespace OpenSim.Region.Framework.Scenes
///
///
protected internal void UpdatePrimFlags(
- uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, IClientAPI remoteClient)
+ uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient)
{
SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null)
@@ -1544,7 +1544,14 @@ namespace OpenSim.Region.Framework.Scenes
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId))
{
// VolumeDetect can't be set via UI and will always be off when a change is made there
- group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false);
+ if (PhysData.PhysShapeType == PhysShapeType.invalid)
+ group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false);
+ else
+ {
+ SceneObjectPart part = GetSceneObjectPart(localID);
+ if (part != null)
+ part.UpdateExtraPhysics(PhysData);
+ }
}
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index f647544..ace53f6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -295,7 +295,13 @@ namespace OpenSim.Region.Framework.Scenes
protected float m_buoyancy = 0.0f;
protected Vector3 m_force;
protected Vector3 m_torque;
-
+
+ protected byte m_physicsShapeType = (byte)PhysShapeType.prim;
+ 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
+
///
/// Stores media texture data
///
@@ -556,19 +562,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- public byte Material
- {
- get { return (byte) m_material; }
- set
- {
- m_material = (Material)value;
- if (PhysActor != null)
- {
- PhysActor.SetMaterial((int)value);
- }
- }
- }
-
public bool PassTouches
{
get { return m_passTouches; }
@@ -1377,6 +1370,87 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public byte Material
+ {
+ get { return (byte)m_material; }
+ set
+ {
+ if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial)
+ {
+ m_material = (Material)value;
+ m_friction = SOPMaterialData.friction(m_material);
+ m_bounce = SOPMaterialData.bounce(m_material);
+ if (PhysActor != null)
+ {
+ PhysActor.SetMaterial((int)value);
+ }
+ }
+ }
+ }
+
+ public byte PhysicsShapeType
+ {
+ get { return m_physicsShapeType; }
+ set
+ {
+ if (value < 0 || value >= (byte)PhysShapeType.convex)
+ value = (byte)PhysShapeType.prim; //convex not supported ?
+
+ else if (value == (byte)PhysShapeType.none)
+ {
+ if (ParentGroup == null || ParentGroup.RootPart == this)
+ value = (byte)PhysShapeType.prim;
+ }
+ m_physicsShapeType = value;
+ }
+ }
+
+ public float Density // in kg/m^3
+ {
+ get { return m_density; }
+ set
+ {
+ if (value >=1 && value <= 22587.0)
+ {
+ m_density = value;
+ }
+ }
+ }
+
+ public float GravityModifier
+ {
+ get { return m_gravitymod; }
+ set
+ { if( value >= -1 && value <=28.0f)
+ m_gravitymod = value;
+ }
+ }
+
+ public float Friction
+ {
+ get { return m_friction; }
+ set
+ {
+ if (value >= 0 && value <= 255.0f)
+ {
+ m_friction = value;
+ }
+ }
+ }
+
+ public float Bounciness
+ {
+ get { return m_bounce; }
+ set
+ {
+ if (value >= 0 && value <= 1.0f)
+ {
+ m_bounce = value;
+ }
+ }
+ }
+
+
#endregion Public Properties with only Get
private uint ApplyMask(uint val, bool set, uint mask)
@@ -4334,6 +4408,18 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+
+ public void UpdateExtraPhysics(ExtraPhysicsData physdata)
+ {
+ if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
+ return;
+
+ PhysicsShapeType = (byte)physdata.PhysShapeType;
+ Density = physdata.Density;
+ GravityModifier = physdata.GravitationModifier;
+ Friction = physdata.Friction;
+ Bounciness = physdata.Bounce;
+ }
///
/// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
///
--
cgit v1.1