From d2499c4c314b290c42f454913305d97c6eec92d6 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Fri, 7 Dec 2012 15:54:46 +0000
Subject: *TEST* Use new avatar size in ubitODE.
---
OpenSim/Framework/AvatarSkeleton.cs | 3 +-
.../Avatar/AvatarFactory/AvatarFactoryModule.cs | 11 ++++-
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++
OpenSim/Region/Physics/Manager/PhysicsActor.cs | 5 +++
.../Region/Physics/UbitOdePlugin/ODECharacter.cs | 48 ++++++++++++++++++++--
OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 1 +
6 files changed, 68 insertions(+), 6 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/AvatarSkeleton.cs b/OpenSim/Framework/AvatarSkeleton.cs
index 269099b..7a49f22 100644
--- a/OpenSim/Framework/AvatarSkeleton.cs
+++ b/OpenSim/Framework/AvatarSkeleton.cs
@@ -275,7 +275,8 @@ namespace OpenSim.Framework
size += pelvisToFoot;
m_standSize = new Vector3(0.45f, 0.6f, size);
- m_feetOffset = 0.5f * size - pelvisToFoot;
+ // m_feetOffset = 0.5f * size - pelvisToFoot;
+ m_feetOffset = 0.0f;
}
}
}
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 8496005..d557a28 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -174,12 +174,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// m_log.DebugFormat(
// "[AVFACTORY]: Setting visual params for {0} to {1}",
// client.Name, string.Join(", ", visualParamsStrings));
-
+/*
float oldHeight = sp.Appearance.AvatarHeight;
changed = sp.Appearance.SetVisualParams(visualParams);
if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
+ */
+ float oldoff = sp.Appearance.AvatarFeetOffset;
+ Vector3 oldbox = sp.Appearance.AvatarBoxSize;
+ changed = sp.Appearance.SetVisualParams(visualParams);
+ float off = sp.Appearance.AvatarFeetOffset;
+ Vector3 box = sp.Appearance.AvatarBoxSize;
+ if(oldoff != off || oldbox != box)
+ ((ScenePresence)sp).SetSize(box,off);
+
}
// Process the baked texture array
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index f5d609d..b6eae8e 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1260,6 +1260,12 @@ namespace OpenSim.Region.Framework.Scenes
PhysicsActor.Size = new Vector3(0.45f, 0.6f, height);
}
+ public void SetSize(Vector3 size, float feetoffset)
+ {
+ if (PhysicsActor != null && !IsChildAgent)
+ PhysicsActor.setAvatarSize(size, feetoffset);
+ }
+
///
/// Complete Avatar's movement into the region.
///
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index e1168bd..0405dad 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -175,6 +175,11 @@ namespace OpenSim.Region.Physics.Manager
public abstract Vector3 Size { get; set; }
+ public virtual void setAvatarSize(Vector3 size, float feetOffset)
+ {
+ Size = size;
+ }
+
public virtual bool Phantom { get; set; }
public virtual bool IsVolumeDtc
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index fd6b8aa..9c245e6 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -90,13 +90,12 @@ namespace OpenSim.Region.Physics.OdePlugin
public float PID_D;
public float PID_P;
+ private float m_feetOffset = 0;
private float feetOff = 0;
private float feetSZ = 0.5f;
const float feetScale = 0.8f;
- const float sizeZAdjust = 0.18f;
private float boneOff = 0;
-
public float walkDivisor = 1.3f;
public float runDivisor = 0.8f;
private bool flying = false;
@@ -475,6 +474,28 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
+ public override void setAvatarSize(Vector3 size, float feetOffset)
+ {
+ if (size.IsFinite())
+ {
+ if (size.X < 0.01f)
+ size.X = 0.01f;
+ if (size.Y < 0.01f)
+ size.Y = 0.01f;
+ if (size.Z < 0.01f)
+ size.Z = 0.01f;
+
+ strAvatarSize st = new strAvatarSize();
+ st.size = size;
+ st.offset = feetOffset;
+ AddChange(changes.AvatarSize, st);
+ }
+ else
+ {
+ m_log.Warn("[PHYSICS]: Got a NaN AvatarSize from Scene on a Character");
+ }
+
+ }
///
/// This creates the Avatar's physical Surrogate at the position supplied
///
@@ -673,7 +694,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// sizes one day should came from visual parameters
float sx = m_size.X;
float sy = m_size.Y;
- float sz = m_size.Z + sizeZAdjust;
+ float sz = m_size.Z;
+
float topsx = sx * 0.9f;
float midsx = sx;
@@ -693,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float midsz = sz - topsz - feetsz;
float bonesz = sz;
- float bot = -sz * 0.5f;
+ float bot = -sz * 0.5f + m_feetOffset;
boneOff = bot + 0.3f;
@@ -754,6 +776,7 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetOffsetPosition(feetbox, 0, 0, feetz);
d.GeomSetOffsetPosition(midbox, 0, 0, midz);
d.GeomSetOffsetPosition(topbox, 0, 0, topz);
+ d.GeomSetOffsetPosition(bonebox, 0, 0, m_feetOffset);
// The purpose of the AMotor here is to keep the avatar's physical
// surrogate from rotating while moving
@@ -1402,6 +1425,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{
}
+ private void changeAvatarSize(strAvatarSize st)
+ {
+ m_feetOffset = st.offset;
+ changeSize(st.size);
+ }
+
private void changeSize(Vector3 pSize)
{
if (pSize.IsFinite())
@@ -1609,6 +1638,10 @@ namespace OpenSim.Region.Physics.OdePlugin
changeSize((Vector3)arg);
break;
+ case changes.AvatarSize:
+ changeAvatarSize((strAvatarSize)arg);
+ break;
+
case changes.Momentum:
changeMomentum((Vector3)arg);
break;
@@ -1656,5 +1689,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{
_parent_scene.AddChange((PhysicsActor)this, what, arg);
}
+
+ private struct strAvatarSize
+ {
+ public Vector3 size;
+ public float offset;
+ }
+
}
}
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 2b4d368..7d1d2fe 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.OdePlugin
PIDHoverActive,
Size,
+ AvatarSize,
Shape,
PhysRepData,
AddPhysRep,
--
cgit v1.1