Restrict accessible of ODECharacter Shell and Body. Add method doc and some error log lines.

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2012-01-24 18:46:24 +00:00
parent 71b11f557d
commit 356e8516f0
2 changed files with 28 additions and 13 deletions

View File

@ -135,10 +135,19 @@ namespace OpenSim.Region.Physics.OdePlugin
| CollisionCategories.Body | CollisionCategories.Body
| CollisionCategories.Character | CollisionCategories.Character
| CollisionCategories.Land); | CollisionCategories.Land);
internal IntPtr Body = IntPtr.Zero; /// <summary>
/// Body for dynamics simulation
/// </summary>
internal IntPtr Body { get; private set; }
private OdeScene _parent_scene; private OdeScene _parent_scene;
internal IntPtr Shell = IntPtr.Zero;
internal IntPtr Amotor = IntPtr.Zero; /// <summary>
/// Collision geometry
/// </summary>
internal IntPtr Shell { get; private set; }
private IntPtr Amotor = IntPtr.Zero;
private d.Mass ShellMass; private d.Mass ShellMass;
private int m_eventsubscription = 0; private int m_eventsubscription = 0;
@ -1024,6 +1033,13 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param name="tensor"></param> /// <param name="tensor"></param>
private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor) private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor)
{ {
if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
{
m_log.ErrorFormat(
"[ODE CHARACTER]: Creating ODE structures for {0} even though some already exist. Shell = {1}, Body = {2}, Amotor = {3}",
Name, Shell, Body, Amotor);
}
int dAMotorEuler = 1; int dAMotorEuler = 1;
// _parent_scene.waitForSpaceUnlock(_parent_scene.space); // _parent_scene.waitForSpaceUnlock(_parent_scene.space);
if (CAPSULE_LENGTH <= 0) if (CAPSULE_LENGTH <= 0)
@ -1141,6 +1157,14 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary> /// </summary>
internal void DestroyOdeStructures() internal void DestroyOdeStructures()
{ {
// Create avatar capsule and related ODE data
if (Shell == IntPtr.Zero || Body == IntPtr.Zero || Amotor == IntPtr.Zero)
{
m_log.ErrorFormat(
"[ODE CHARACTER]: Destroying ODE structures for {0} even though some are already null. Shell = {1}, Body = {2}, Amotor = {3}",
Name, Shell, Body, Amotor);
}
// destroy avatar capsule and related ODE data // destroy avatar capsule and related ODE data
if (Amotor != IntPtr.Zero) if (Amotor != IntPtr.Zero)
{ {
@ -1266,15 +1290,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (m_tainted_isPhysical) if (m_tainted_isPhysical)
{ {
// Create avatar capsule and related ODE data
if (!(Shell == IntPtr.Zero && Body == IntPtr.Zero && Amotor == IntPtr.Zero))
{
m_log.Warn("[ODE CHARACTER]: re-creating the following avatar ODE data for " + Name + ", even though it already exists - "
+ (Shell!=IntPtr.Zero ? "Shell ":"")
+ (Body!=IntPtr.Zero ? "Body ":"")
+ (Amotor!=IntPtr.Zero ? "Amotor ":""));
}
CreateOdeStructures(_position.X, _position.Y, _position.Z, m_tensor); CreateOdeStructures(_position.X, _position.Y, _position.Z, m_tensor);
_parent_scene.AddCharacter(this); _parent_scene.AddCharacter(this);
} }

View File

@ -1522,7 +1522,7 @@ namespace OpenSim.Region.Physics.OdePlugin
chr.CollidingGround = false; chr.CollidingGround = false;
chr.CollidingObj = false; chr.CollidingObj = false;
// test the avatar's geometry for collision with the space // Test the avatar's geometry for collision with the space
// This will return near and the space that they are the closest to // This will return near and the space that they are the closest to
// And we'll run this again against the avatar and the space segment // And we'll run this again against the avatar and the space segment
// This will return with a bunch of possible objects in the space segment // This will return with a bunch of possible objects in the space segment