bug fixs, added a default physics shape estimator based on being a mesh or not and use it on unlink if new root part as type none. Viewer doesn't get updated even with fullupdates we are missing something still

avinationmerge
UbitUmarov 2012-03-14 18:24:04 +00:00
parent c0f70d17fc
commit cf9ebd301c
4 changed files with 82 additions and 18 deletions

View File

@ -7029,7 +7029,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
physdata.Bounce = phsblock.Restitution;
physdata.Density = phsblock.Density;
physdata.Friction = phsblock.Friction;
physdata.GravitationModifier = phsblock.GravityMultiplier;
}
handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
}
return true;

View File

@ -2723,6 +2723,10 @@ namespace OpenSim.Region.Framework.Scenes
// When we delete a group, we currently have to force persist to the database if the object id has changed
// (since delete works by deleting all rows which have a given object id)
// this is as it seems to be in sl now
if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none)
linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;

View File

@ -986,7 +986,11 @@ namespace OpenSim.Region.Framework.Scenes
public PrimitiveBaseShape Shape
{
get { return m_shape; }
set { m_shape = value;}
set
{
m_shape = value;
m_physicsShapeType = DefaultPhysicsShapeType();
}
}
/// <summary>
@ -1377,31 +1381,68 @@ namespace OpenSim.Region.Framework.Scenes
{
if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial)
{
m_material = (Material)value;
m_friction = SOPMaterialData.friction(m_material);
m_bounce = SOPMaterialData.bounce(m_material);
if (PhysActor != null)
bool update = false;
if (m_material != (Material)value)
{
PhysActor.SetMaterial((int)value);
update = true;
m_material = (Material)value;
}
if (m_friction != SOPMaterialData.friction(m_material))
{
update = true;
m_friction = SOPMaterialData.friction(m_material);
}
if (m_bounce != SOPMaterialData.bounce(m_material))
{
update = true;
m_bounce = SOPMaterialData.bounce(m_material);
}
if (update)
{
if (PhysActor != null)
{
PhysActor.SetMaterial((int)value);
}
if(ParentGroup != null)
ParentGroup.HasGroupChanged = true;
ScheduleFullUpdateIfNone();
}
}
}
}
// not a propriety to move to methods place later
public byte DefaultPhysicsShapeType()
{
byte type;
if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh))
type = (byte)PhysShapeType.convex;
else
type = (byte)PhysShapeType.prim;
return type;
}
public byte PhysicsShapeType
{
get { return m_physicsShapeType; }
set
{
if (value < 0 || value >= (byte)PhysShapeType.convex)
value = (byte)PhysShapeType.prim; //convex not supported ?
else if (value == (byte)PhysShapeType.none)
if (value >= 0 && value <= (byte)PhysShapeType.convex)
{
if (ParentGroup == null || ParentGroup.RootPart == this)
value = (byte)PhysShapeType.prim;
if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this)
m_physicsShapeType = DefaultPhysicsShapeType();
else
m_physicsShapeType = value;
ScheduleFullUpdateIfNone();
}
m_physicsShapeType = value;
else
m_physicsShapeType = DefaultPhysicsShapeType();
}
}
@ -1413,6 +1454,7 @@ namespace OpenSim.Region.Framework.Scenes
if (value >=1 && value <= 22587.0)
{
m_density = value;
ScheduleFullUpdateIfNone();
}
}
}
@ -1423,6 +1465,7 @@ namespace OpenSim.Region.Framework.Scenes
set
{ if( value >= -1 && value <=28.0f)
m_gravitymod = value;
ScheduleFullUpdateIfNone();
}
}
@ -1434,6 +1477,7 @@ namespace OpenSim.Region.Framework.Scenes
if (value >= 0 && value <= 255.0f)
{
m_friction = value;
ScheduleFullUpdateIfNone();
}
}
}
@ -1446,6 +1490,7 @@ namespace OpenSim.Region.Framework.Scenes
if (value >= 0 && value <= 1.0f)
{
m_bounce = value;
ScheduleFullUpdateIfNone();
}
}
}
@ -2942,6 +2987,19 @@ namespace OpenSim.Region.Framework.Scenes
APIDTarget = Quaternion.Identity;
}
public void ScheduleFullUpdateIfNone()
{
if (ParentGroup == null)
return;
// ??? ParentGroup.HasGroupChanged = true;
if (UpdateFlag != UpdateRequired.FULL)
ScheduleFullUpdate();
}
/// <summary>
/// Schedules this prim for a full update
/// </summary>

View File

@ -597,22 +597,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader)
{
obj.Density = (byte)reader.ReadElementContentAsInt("Density", String.Empty);
obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty);
}
private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader)
{
obj.Friction = (byte)reader.ReadElementContentAsInt("Friction", String.Empty);
obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty);
}
private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader)
{
obj.Bounciness = (byte)reader.ReadElementContentAsInt("Bounce", String.Empty);
obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty);
}
private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader)
{
obj.GravityModifier = (byte)reader.ReadElementContentAsInt("GravityModifier", String.Empty);
obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty);
}
private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader)
@ -1321,7 +1321,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (sop.sopVehicle != null)
sop.sopVehicle.ToXml2(writer);
if(sop.PhysicsShapeType != (byte)PhysShapeType.prim)
if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType())
writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
if (sop.Density != 1000.0f)
writer.WriteElementString("Density", sop.Density.ToString().ToLower());