From c658fa1c0dd83f23c66ccfedb12e8ab02ff01d0a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 7 Feb 2013 11:05:21 -0800 Subject: [PATCH 1/2] Add plumbing for physics properties to get to the physics engine. Addition of entries to PhysicsActor and setting code in SceneObjectPart. --- .../Framework/Scenes/SceneObjectPart.cs | 56 +++++++++++++++++-- .../Region/Physics/Manager/PhysicsActor.cs | 5 ++ 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b00f388520..a3c7ed3ca2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1387,10 +1387,46 @@ namespace OpenSim.Region.Framework.Scenes } } - public float Density { get; set; } - public float GravityModifier { get; set; } - public float Friction { get; set; } - public float Restitution { get; set; } + private float m_density = 10f; + public float Density { + get { return m_density; } + set + { + m_density = value; + if (PhysActor != null) + PhysActor.Density = m_density; + } + } + private float m_gravityModifier = 1f; + public float GravityModifier { + get { return m_gravityModifier; } + set + { + m_gravityModifier = value; + if (PhysActor != null) + PhysActor.GravityModifier = m_gravityModifier; + } + } + private float m_friction = 0.5f; + public float Friction { + get { return m_friction; } + set + { + m_friction = value; + if (PhysActor != null) + PhysActor.Friction = m_friction; + } + } + private float m_restitution = 0f; + public float Restitution { + get { return m_restitution; } + set + { + m_restitution = value; + if (PhysActor != null) + PhysActor.Restitution = m_restitution; + } + } #endregion Public Properties with only Get @@ -1896,8 +1932,18 @@ namespace OpenSim.Region.Framework.Scenes { ParentGroup.Scene.AddPhysicalPrim(1); + // Update initial values for various physical properties + pa.SetMaterial(Material); + pa.Density = Density; + pa.Friction = Friction; + pa.Restitution = Restitution; + pa.GravityModifier = GravityModifier; + + // Link up callbacks for property updates from the physics engine pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; pa.OnOutOfBounds += PhysicsOutOfBounds; + + // If this is a child prim, tell the physics engine about the parent if (ParentID != 0 && ParentID != LocalId) { PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; @@ -4062,7 +4108,6 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) { - pa.SetMaterial(Material); DoPhysicsPropertyUpdate(UsePhysics, true); if ( @@ -4175,7 +4220,6 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) { pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info - pa.SetMaterial(Material); DoPhysicsPropertyUpdate(rigidBody, true); } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index d119791cc6..4820ca471c 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -235,6 +235,11 @@ namespace OpenSim.Region.Physics.Manager public abstract float Mass { get; } public abstract Vector3 Force { get; set; } + public virtual float Density { get; set; } + public virtual float Friction { get; set; } + public virtual float Restitution { get; set; } + public virtual float GravityModifier { get; set; } + public abstract int VehicleType { get; set; } public abstract void VehicleFloatParam(int param, float value); public abstract void VehicleVectorParam(int param, Vector3 value); From 9089757ea2cabe49f40de64b7e6befa13a4553c1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 21:05:58 +0000 Subject: [PATCH 2/2] Revert "Add plumbing for physics properties to get to the physics engine." This reverts commit c658fa1c0dd83f23c66ccfedb12e8ab02ff01d0a. --- .../Framework/Scenes/SceneObjectPart.cs | 56 ++----------------- .../Region/Physics/Manager/PhysicsActor.cs | 5 -- 2 files changed, 6 insertions(+), 55 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a3c7ed3ca2..b00f388520 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1387,46 +1387,10 @@ namespace OpenSim.Region.Framework.Scenes } } - private float m_density = 10f; - public float Density { - get { return m_density; } - set - { - m_density = value; - if (PhysActor != null) - PhysActor.Density = m_density; - } - } - private float m_gravityModifier = 1f; - public float GravityModifier { - get { return m_gravityModifier; } - set - { - m_gravityModifier = value; - if (PhysActor != null) - PhysActor.GravityModifier = m_gravityModifier; - } - } - private float m_friction = 0.5f; - public float Friction { - get { return m_friction; } - set - { - m_friction = value; - if (PhysActor != null) - PhysActor.Friction = m_friction; - } - } - private float m_restitution = 0f; - public float Restitution { - get { return m_restitution; } - set - { - m_restitution = value; - if (PhysActor != null) - PhysActor.Restitution = m_restitution; - } - } + public float Density { get; set; } + public float GravityModifier { get; set; } + public float Friction { get; set; } + public float Restitution { get; set; } #endregion Public Properties with only Get @@ -1932,18 +1896,8 @@ namespace OpenSim.Region.Framework.Scenes { ParentGroup.Scene.AddPhysicalPrim(1); - // Update initial values for various physical properties - pa.SetMaterial(Material); - pa.Density = Density; - pa.Friction = Friction; - pa.Restitution = Restitution; - pa.GravityModifier = GravityModifier; - - // Link up callbacks for property updates from the physics engine pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; pa.OnOutOfBounds += PhysicsOutOfBounds; - - // If this is a child prim, tell the physics engine about the parent if (ParentID != 0 && ParentID != LocalId) { PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; @@ -4108,6 +4062,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) { + pa.SetMaterial(Material); DoPhysicsPropertyUpdate(UsePhysics, true); if ( @@ -4220,6 +4175,7 @@ namespace OpenSim.Region.Framework.Scenes if (pa != null) { pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info + pa.SetMaterial(Material); DoPhysicsPropertyUpdate(rigidBody, true); } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 4820ca471c..d119791cc6 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -235,11 +235,6 @@ namespace OpenSim.Region.Physics.Manager public abstract float Mass { get; } public abstract Vector3 Force { get; set; } - public virtual float Density { get; set; } - public virtual float Friction { get; set; } - public virtual float Restitution { get; set; } - public virtual float GravityModifier { get; set; } - public abstract int VehicleType { get; set; } public abstract void VehicleFloatParam(int param, float value); public abstract void VehicleVectorParam(int param, Vector3 value);