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

iar_mods
Justin Clark-Casey (justincc) 2012-01-24 18:46:24 +00:00
parent a0fb1e1788
commit 8b035dc3c7
2 changed files with 27 additions and 12 deletions

View File

@ -134,9 +134,18 @@ namespace OpenSim.Region.Physics.OdePlugin
| CollisionCategories.Body
| CollisionCategories.Character
| CollisionCategories.Land);
internal IntPtr Body = IntPtr.Zero;
/// <summary>
/// Body for dynamics simulation
/// </summary>
internal IntPtr Body { get; private set; }
private OdeScene _parent_scene;
internal IntPtr Shell = IntPtr.Zero;
/// <summary>
/// Collision geometry
/// </summary>
internal IntPtr Shell { get; private set; }
private IntPtr Amotor = IntPtr.Zero;
private d.Mass ShellMass;
@ -1018,6 +1027,13 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param name="tensor"></param>
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;
// _parent_scene.waitForSpaceUnlock(_parent_scene.space);
if (CAPSULE_LENGTH <= 0)
@ -1135,6 +1151,14 @@ namespace OpenSim.Region.Physics.OdePlugin
/// </summary>
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
if (Amotor != IntPtr.Zero)
{
@ -1260,15 +1284,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
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);
_parent_scene.AddCharacter(this);
}

View File

@ -1525,7 +1525,7 @@ namespace OpenSim.Region.Physics.OdePlugin
chr.CollidingGround = 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
// 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