minor: code tidy and inserted log lines for future use.

Unable to get to the bottom of why resizing a mesh fails to properly reset the physics proxy, when toggling phantom does
After a mesh is generated, the existing sculptdata is set to zero in PrimitiveBaseShape to save memory
When phantom is toggled, the sculptdata is regenerated before remeshing.
But on resize, the sculptdata is not regenerated.
So clearly, resetting sculptdata is possible, but haven't quite been able to pin down how this is being done when phantom is toggled.
bulletsim
Justin Clark-Casey (justincc) 2011-07-09 00:35:30 +01:00
parent c3d82bdcb1
commit 5e8900dfd0
7 changed files with 72 additions and 43 deletions

View File

@ -213,6 +213,8 @@ namespace OpenSim.Framework
/// <param name="prim"></param> /// <param name="prim"></param>
public PrimitiveBaseShape(Primitive prim) public PrimitiveBaseShape(Primitive prim)
{ {
// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID);
PCode = (byte)prim.PrimData.PCode; PCode = (byte)prim.PrimData.PCode;
ExtraParams = new byte[1]; ExtraParams = new byte[1];
@ -613,29 +615,39 @@ namespace OpenSim.Framework
} }
} }
public byte SculptType { public byte SculptType
get { {
get
{
return _sculptType; return _sculptType;
} }
set { set
{
_sculptType = value; _sculptType = value;
} }
} }
public byte[] SculptData { public byte[] SculptData
get { {
get
{
return _sculptData; return _sculptData;
} }
set { set
{
// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Setting SculptData to data with length {0}", value.Length);
_sculptData = value; _sculptData = value;
} }
} }
public int FlexiSoftness { public int FlexiSoftness
get { {
get
{
return _flexiSoftness; return _flexiSoftness;
} }
set { set
{
_flexiSoftness = value; _flexiSoftness = value;
} }
} }
@ -849,6 +861,8 @@ namespace OpenSim.Framework
public byte[] ExtraParamsToBytes() public byte[] ExtraParamsToBytes()
{ {
// m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()");
ushort FlexiEP = 0x10; ushort FlexiEP = 0x10;
ushort LightEP = 0x20; ushort LightEP = 0x20;
ushort SculptEP = 0x30; ushort SculptEP = 0x30;
@ -864,18 +878,21 @@ namespace OpenSim.Framework
TotalBytesLength += 16;// data TotalBytesLength += 16;// data
TotalBytesLength += 2 + 4; // type TotalBytesLength += 2 + 4; // type
} }
if (_lightEntry) if (_lightEntry)
{ {
ExtraParamsNum++; ExtraParamsNum++;
TotalBytesLength += 16;// data TotalBytesLength += 16;// data
TotalBytesLength += 2 + 4; // type TotalBytesLength += 2 + 4; // type
} }
if (_sculptEntry) if (_sculptEntry)
{ {
ExtraParamsNum++; ExtraParamsNum++;
TotalBytesLength += 17;// data TotalBytesLength += 17;// data
TotalBytesLength += 2 + 4; // type TotalBytesLength += 2 + 4; // type
} }
if (_projectionEntry) if (_projectionEntry)
{ {
ExtraParamsNum++; ExtraParamsNum++;
@ -885,7 +902,6 @@ namespace OpenSim.Framework
byte[] returnbytes = new byte[TotalBytesLength]; byte[] returnbytes = new byte[TotalBytesLength];
// uint paramlength = ExtraParamsNum; // uint paramlength = ExtraParamsNum;
// Stick in the number of parameters // Stick in the number of parameters
@ -905,6 +921,7 @@ namespace OpenSim.Framework
Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length); Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length);
i += FlexiData.Length; i += FlexiData.Length;
} }
if (_lightEntry) if (_lightEntry)
{ {
byte[] LightData = GetLightBytes(); byte[] LightData = GetLightBytes();
@ -919,6 +936,7 @@ namespace OpenSim.Framework
Array.Copy(LightData, 0, returnbytes, i, LightData.Length); Array.Copy(LightData, 0, returnbytes, i, LightData.Length);
i += LightData.Length; i += LightData.Length;
} }
if (_sculptEntry) if (_sculptEntry)
{ {
byte[] SculptData = GetSculptBytes(); byte[] SculptData = GetSculptBytes();
@ -933,6 +951,7 @@ namespace OpenSim.Framework
Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length); Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length);
i += SculptData.Length; i += SculptData.Length;
} }
if (_projectionEntry) if (_projectionEntry)
{ {
byte[] ProjectionData = GetProjectionBytes(); byte[] ProjectionData = GetProjectionBytes();
@ -946,6 +965,7 @@ namespace OpenSim.Framework
Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length); Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length);
i += ProjectionData.Length; i += ProjectionData.Length;
} }
if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry) if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry)
{ {
byte[] returnbyte = new byte[1]; byte[] returnbyte = new byte[1];
@ -953,10 +973,7 @@ namespace OpenSim.Framework
return returnbyte; return returnbyte;
} }
return returnbytes; return returnbytes;
//m_log.Info("[EXTRAPARAMS]: Length = " + m_shape.ExtraParams.Length.ToString());
} }
public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data) public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data)
@ -1027,7 +1044,6 @@ namespace OpenSim.Framework
extraParamCount = data[i++]; extraParamCount = data[i++];
} }
for (int k = 0; k < extraParamCount; k++) for (int k = 0; k < extraParamCount; k++)
{ {
ushort epType = Utils.BytesToUInt16(data, i); ushort epType = Utils.BytesToUInt16(data, i);
@ -1071,7 +1087,6 @@ namespace OpenSim.Framework
_sculptEntry = false; _sculptEntry = false;
if (!lGotFilter) if (!lGotFilter)
_projectionEntry = false; _projectionEntry = false;
} }
public void ReadSculptData(byte[] data, int pos) public void ReadSculptData(byte[] data, int pos)
@ -1100,6 +1115,7 @@ namespace OpenSim.Framework
if (_sculptType != (byte)1 && _sculptType != (byte)2 && _sculptType != (byte)3 && _sculptType != (byte)4) if (_sculptType != (byte)1 && _sculptType != (byte)2 && _sculptType != (byte)3 && _sculptType != (byte)4)
_sculptType = 4; _sculptType = 4;
} }
_sculptTexture = SculptUUID; _sculptTexture = SculptUUID;
_sculptType = SculptTypel; _sculptType = SculptTypel;
//m_log.Info("[SCULPT]:" + SculptUUID.ToString()); //m_log.Info("[SCULPT]:" + SculptUUID.ToString());

View File

@ -250,11 +250,9 @@ namespace OpenSim.Region.ClientStack.Linden
case 0x40: case 0x40:
pbs.ReadProjectionData(extraParam.ExtraParamData, 0); pbs.ReadProjectionData(extraParam.ExtraParamData, 0);
break; break;
}
} }
}
pbs.PathBegin = (ushort) obj.PathBegin; pbs.PathBegin = (ushort) obj.PathBegin;
pbs.PathCurve = (byte) obj.PathCurve; pbs.PathCurve = (byte) obj.PathCurve;
pbs.PathEnd = (ushort) obj.PathEnd; pbs.PathEnd = (ushort) obj.PathEnd;

View File

@ -2958,7 +2958,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void SculptTextureCallback(UUID textureID, AssetBase texture) public void SculptTextureCallback(UUID textureID, AssetBase texture)
{ {
if (m_shape.SculptEntry) if (m_shape.SculptEntry)

View File

@ -1001,6 +1001,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessShpSculptData(PrimitiveBaseShape shp, XmlTextReader reader) private static void ProcessShpSculptData(PrimitiveBaseShape shp, XmlTextReader reader)
{ {
// m_log.DebugFormat("[SCENE OBJECT SERIALIZER]: Setting sculpt data length {0}", shp.SculptData.Length);
shp.SculptData = Convert.FromBase64String(reader.ReadElementString("SculptData")); shp.SculptData = Convert.FromBase64String(reader.ReadElementString("SculptData"));
} }

View File

@ -540,7 +540,6 @@ namespace OpenSim.Region.Physics.Meshing
profileBegin = 0.5f * profileBegin + 0.5f; profileBegin = 0.5f * profileBegin + 0.5f;
profileEnd = 0.5f * profileEnd + 0.5f; profileEnd = 0.5f * profileEnd + 0.5f;
} }
int hollowSides = sides; int hollowSides = sides;
@ -660,7 +659,9 @@ namespace OpenSim.Region.Physics.Meshing
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
{ {
// m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName); #if SPAM
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
#endif
Mesh mesh = null; Mesh mesh = null;
ulong key = 0; ulong key = 0;

View File

@ -38,6 +38,9 @@
* switch between 'VEHICLE' parameter use and general dynamics * switch between 'VEHICLE' parameter use and general dynamics
* settings use. * settings use.
*/ */
//#define SPAM
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
@ -746,7 +749,6 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
} }
d.BodyDestroy(Body); d.BodyDestroy(Body);
lock (childrenPrim) lock (childrenPrim)
{ {
@ -775,7 +777,6 @@ namespace OpenSim.Region.Physics.OdePlugin
d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags);
} }
Body = IntPtr.Zero; Body = IntPtr.Zero;
} }
} }
@ -858,7 +859,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public void ProcessTaints(float timestep) public void ProcessTaints(float timestep)
{ {
//Console.WriteLine("ProcessTaints for " + Name); Console.WriteLine("ProcessTaints for " + Name);
if (m_taintadd) if (m_taintadd)
{ {
changeadd(timestep); changeadd(timestep);
@ -885,19 +886,15 @@ namespace OpenSim.Region.Physics.OdePlugin
rotate(timestep); rotate(timestep);
} }
} }
//
if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent))
changePhysicsStatus(timestep); changePhysicsStatus(timestep);
//
if (!_size.ApproxEquals(m_taintsize,0f)) if (!_size.ApproxEquals(m_taintsize, 0f))
changesize(timestep); changesize(timestep);
//
if (m_taintshape) if (m_taintshape)
changeshape(timestep); changeshape(timestep);
//
if (m_taintforce) if (m_taintforce)
changeAddForce(timestep); changeAddForce(timestep);
@ -925,7 +922,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
changeAngularLock(timestep); changeAngularLock(timestep);
} }
else else
{ {
@ -1424,10 +1420,11 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
lock (_parent_scene.OdeLock) lock (_parent_scene.OdeLock)
{ {
//Console.WriteLine("changeadd 1"); #if SPAM
Console.WriteLine("changeadd 1");
#endif
CreateGeom(m_targetSpace, _mesh); CreateGeom(m_targetSpace, _mesh);
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
@ -1890,6 +1887,10 @@ Console.WriteLine(" JointCreateFixed");
public void changesize(float timestamp) public void changesize(float timestamp)
{ {
#if SPAM
m_log.DebugFormat("[ODE PRIM]: Called changesize");
#endif
string oldname = _parent_scene.geom_name_map[prim_geom]; string oldname = _parent_scene.geom_name_map[prim_geom];
if (_size.X <= 0) _size.X = 0.01f; if (_size.X <= 0) _size.X = 0.01f;
@ -1899,8 +1900,9 @@ Console.WriteLine(" JointCreateFixed");
// Cleanup of old prim geometry // Cleanup of old prim geometry
if (_mesh != null) if (_mesh != null)
{ {
// Cleanup meshing here // TODO: Cleanup meshing here
} }
//kill body to rebuild //kill body to rebuild
if (IsPhysical && Body != IntPtr.Zero) if (IsPhysical && Body != IntPtr.Zero)
{ {
@ -1917,11 +1919,13 @@ Console.WriteLine(" JointCreateFixed");
disableBody(); disableBody();
} }
} }
if (d.SpaceQuery(m_targetSpace, prim_geom)) if (d.SpaceQuery(m_targetSpace, prim_geom))
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace); _parent_scene.waitForSpaceUnlock(m_targetSpace);
d.SpaceRemove(m_targetSpace, prim_geom); d.SpaceRemove(m_targetSpace, prim_geom);
} }
d.GeomDestroy(prim_geom); d.GeomDestroy(prim_geom);
prim_geom = IntPtr.Zero; prim_geom = IntPtr.Zero;
// we don't need to do space calculation because the client sends a position update also. // we don't need to do space calculation because the client sends a position update also.
@ -1941,13 +1945,19 @@ Console.WriteLine(" JointCreateFixed");
mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
//IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
//Console.WriteLine("changesize 1"); #if SPAM
Console.WriteLine("changesize 1");
#endif
CreateGeom(m_targetSpace, mesh); CreateGeom(m_targetSpace, mesh);
} }
else else
{ {
_mesh = null; _mesh = null;
//Console.WriteLine("changesize 2");
#if SPAM
Console.WriteLine("changesize 2");
#endif
CreateGeom(m_targetSpace, _mesh); CreateGeom(m_targetSpace, _mesh);
} }
@ -2030,6 +2040,7 @@ Console.WriteLine(" JointCreateFixed");
prim_geom = IntPtr.Zero; prim_geom = IntPtr.Zero;
m_log.ErrorFormat("[PHYSICS]: PrimGeom dead for {0}", Name); m_log.ErrorFormat("[PHYSICS]: PrimGeom dead for {0}", Name);
} }
prim_geom = IntPtr.Zero; prim_geom = IntPtr.Zero;
// we don't need to do space calculation because the client sends a position update also. // we don't need to do space calculation because the client sends a position update also.
if (_size.X <= 0) _size.X = 0.01f; if (_size.X <= 0) _size.X = 0.01f;
@ -2039,7 +2050,7 @@ Console.WriteLine(" JointCreateFixed");
if (_parent_scene.needsMeshing(_pbs)) if (_parent_scene.needsMeshing(_pbs))
{ {
// Don't need to re-enable body.. it's done in SetMesh // Don't need to re-enable body.. it's done in CreateMesh
float meshlod = _parent_scene.meshSculptLOD; float meshlod = _parent_scene.meshSculptLOD;
if (IsPhysical) if (IsPhysical)
@ -2047,13 +2058,18 @@ Console.WriteLine(" JointCreateFixed");
IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
// createmesh returns null when it doesn't mesh. // createmesh returns null when it doesn't mesh.
//Console.WriteLine("changeshape needed meshing"); #if SPAM
Console.WriteLine("changeshape needed meshing");
#endif
CreateGeom(m_targetSpace, mesh); CreateGeom(m_targetSpace, mesh);
} }
else else
{ {
_mesh = null; _mesh = null;
//Console.WriteLine("changeshape not need meshing");
#if SPAM
Console.WriteLine("changeshape not need meshing");
#endif
CreateGeom(m_targetSpace, null); CreateGeom(m_targetSpace, null);
} }

View File

@ -26,7 +26,7 @@
*/ */
//#define USE_DRAWSTUFF //#define USE_DRAWSTUFF
//#define SPAM #define SPAM
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -312,7 +312,6 @@ namespace OpenSim.Region.Physics.OdePlugin
#endif #endif
} }
_watermap = new float[258 * 258]; _watermap = new float[258 * 258];
// Zero out the prim spaces array (we split our space into smaller spaces so // Zero out the prim spaces array (we split our space into smaller spaces so
@ -2563,7 +2562,6 @@ namespace OpenSim.Region.Physics.OdePlugin
if (pbs.SculptEntry && meshSculptedPrim) if (pbs.SculptEntry && meshSculptedPrim)
iPropertiesNotSupportedDefault++; iPropertiesNotSupportedDefault++;
if (iPropertiesNotSupportedDefault == 0) if (iPropertiesNotSupportedDefault == 0)
{ {
#if SPAM #if SPAM
@ -2703,7 +2701,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
foreach (OdeCharacter character in _taintedActors) foreach (OdeCharacter character in _taintedActors)
{ {
character.ProcessTaints(timeStep); character.ProcessTaints(timeStep);
processedtaints = true; processedtaints = true;