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

View File

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

View File

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

View File

@ -1001,6 +1001,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
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"));
}

View File

@ -540,7 +540,6 @@ namespace OpenSim.Region.Physics.Meshing
profileBegin = 0.5f * profileBegin + 0.5f;
profileEnd = 0.5f * profileEnd + 0.5f;
}
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)
{
// m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
#if SPAM
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
#endif
Mesh mesh = null;
ulong key = 0;

View File

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

View File

@ -26,7 +26,7 @@
*/
//#define USE_DRAWSTUFF
//#define SPAM
#define SPAM
using System;
using System.Collections.Generic;
@ -312,7 +312,6 @@ namespace OpenSim.Region.Physics.OdePlugin
#endif
}
_watermap = new float[258 * 258];
// 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)
iPropertiesNotSupportedDefault++;
if (iPropertiesNotSupportedDefault == 0)
{
#if SPAM
@ -2703,7 +2701,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
foreach (OdeCharacter character in _taintedActors)
{
character.ProcessTaints(timeStep);
processedtaints = true;