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

avinationmerge
UbitUmarov 2012-03-13 17:56:32 +00:00
parent ebcd4910a2
commit 3de3b9e63c
7 changed files with 281 additions and 22 deletions

View File

@ -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;
}
}

View File

@ -124,7 +124,7 @@ namespace OpenSim.Framework
public delegate void ObjectDrop(uint localID, IClientAPI remoteClient); public delegate void ObjectDrop(uint localID, IClientAPI remoteClient);
public delegate void UpdatePrimFlags( 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); public delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient);

View File

@ -7006,10 +7006,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// 46,47,48 are special positions within the packet // 46,47,48 are special positions within the packet
// This may change so perhaps we need a better way // This may change so perhaps we need a better way
// of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?) // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
/*
bool UsePhysics = (data[46] != 0) ? true : false; bool UsePhysics = (data[46] != 0) ? true : false;
bool IsTemporary = (data[47] != 0) ? true : false; bool IsTemporary = (data[47] != 0) ? true : false;
bool IsPhantom = (data[48] != 0) ? true : false; bool IsPhantom = (data[48] != 0) ? true : false;
handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this); 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; return true;
} }

View File

@ -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;
}
}
}

View File

@ -4882,7 +4882,7 @@ Environment.Exit(1);
private void CheckHeartbeat() private void CheckHeartbeat()
{ {
if (m_firstHeartbeat) // if (m_firstHeartbeat)
return; return;
if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)

View File

@ -1536,7 +1536,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="SetPhantom"></param> /// <param name="SetPhantom"></param>
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
protected internal void UpdatePrimFlags( 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); SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null) if (group != null)
@ -1544,7 +1544,14 @@ namespace OpenSim.Region.Framework.Scenes
if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) 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 // VolumeDetect can't be set via UI and will always be off when a change is made there
if (PhysData.PhysShapeType == PhysShapeType.invalid)
group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false);
else
{
SceneObjectPart part = GetSceneObjectPart(localID);
if (part != null)
part.UpdateExtraPhysics(PhysData);
}
} }
} }
} }

View File

@ -296,6 +296,12 @@ namespace OpenSim.Region.Framework.Scenes
protected Vector3 m_force; protected Vector3 m_force;
protected Vector3 m_torque; 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
/// <summary> /// <summary>
/// Stores media texture data /// Stores media texture data
/// </summary> /// </summary>
@ -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 public bool PassTouches
{ {
get { return m_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 #endregion Public Properties with only Get
private uint ApplyMask(uint val, bool set, uint mask) 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;
}
/// <summary> /// <summary>
/// Update the flags on this prim. This covers properties such as phantom, physics and temporary. /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
/// </summary> /// </summary>