initial introdution of physics actor building control.

avinationmerge
UbitUmarov 2012-02-08 23:14:53 +00:00
parent 6cc9aa30ac
commit 6af01f6767
5 changed files with 60 additions and 11 deletions

View File

@ -417,7 +417,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.AttachedAvatar = UUID.Zero; so.AttachedAvatar = UUID.Zero;
rootPart.SetParentLocalId(0); rootPart.SetParentLocalId(0);
so.ClearPartAttachmentData(); so.ClearPartAttachmentData();
rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive,false);
so.HasGroupChanged = true; so.HasGroupChanged = true;
rootPart.Rezzed = DateTime.Now; rootPart.Rezzed = DateTime.Now;
rootPart.RemFlag(PrimFlags.TemporaryOnRez); rootPart.RemFlag(PrimFlags.TemporaryOnRez);

View File

@ -4766,7 +4766,7 @@ Environment.Exit(1);
bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
if (wasUsingPhysics) if (wasUsingPhysics)
{ {
jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock
} }
} }

View File

@ -1281,7 +1281,8 @@ namespace OpenSim.Region.Framework.Scenes
m_rootPart.SetParentLocalId(0); m_rootPart.SetParentLocalId(0);
AttachmentPoint = (byte)0; AttachmentPoint = (byte)0;
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); // must check if buildind should be true or false here
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false);
HasGroupChanged = true; HasGroupChanged = true;
RootPart.Rezzed = DateTime.Now; RootPart.Rezzed = DateTime.Now;
RootPart.RemFlag(PrimFlags.TemporaryOnRez); RootPart.RemFlag(PrimFlags.TemporaryOnRez);
@ -1581,21 +1582,33 @@ namespace OpenSim.Region.Framework.Scenes
public void ApplyPhysics() public void ApplyPhysics()
{ {
// Apply physics to the root prim // Apply physics to the root prim
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); // m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive);
// Apply physics to child prims // Apply physics to child prims
SceneObjectPart[] parts = m_parts.GetArray(); SceneObjectPart[] parts = m_parts.GetArray();
if (parts.Length > 1) if (parts.Length > 1)
{ {
ResetChildPrimPhysicsPositions();
// Apply physics to the root prim
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true);
for (int i = 0; i < parts.Length; i++) for (int i = 0; i < parts.Length; i++)
{ {
SceneObjectPart part = parts[i]; SceneObjectPart part = parts[i];
if (part.LocalId != m_rootPart.LocalId) if (part.LocalId != m_rootPart.LocalId)
part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); // part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive);
} part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true);
}
// Hack to get the physics scene geometries in the right spot // Hack to get the physics scene geometries in the right spot
ResetChildPrimPhysicsPositions(); // ResetChildPrimPhysicsPositions();
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
}
else
{
// Apply physics to the root prim
m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false);
} }
} }
@ -1829,13 +1842,16 @@ namespace OpenSim.Region.Framework.Scenes
pbs, pbs,
newPart.AbsolutePosition, newPart.AbsolutePosition,
newPart.Scale, newPart.Scale,
newPart.RotationOffset, //newPart.RotationOffset,
newPart.GetWorldRotation(),
part.PhysActor.IsPhysical, part.PhysActor.IsPhysical,
newPart.LocalId); newPart.LocalId);
newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); newPart.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true);
} }
} }
if (dupe.m_rootPart.PhysActor != null && userExposed)
dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building
if (userExposed) if (userExposed)
{ {
@ -2849,12 +2865,31 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/*
RootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); RootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect);
for (int i = 0; i < parts.Length; i++) for (int i = 0; i < parts.Length; i++)
{ {
if (parts[i] != RootPart) if (parts[i] != RootPart)
parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect);
} }
*/
if (parts.Length > 1)
{
m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true);
for (int i = 0; i < parts.Length; i++)
{
if (parts[i].UUID != m_rootPart.UUID)
parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true);
}
if (m_rootPart.PhysActor != null)
m_rootPart.PhysActor.Building = false;
}
else
m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false);
} }
} }

View File

@ -1503,7 +1503,8 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
/// <param name="rootObjectFlags"></param> /// <param name="rootObjectFlags"></param>
/// <param name="VolumeDetectActive"></param> /// <param name="VolumeDetectActive"></param>
public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) // public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive)
public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building)
{ {
if (!ParentGroup.Scene.CollidablePrims) if (!ParentGroup.Scene.CollidablePrims)
return; return;
@ -1557,6 +1558,8 @@ namespace OpenSim.Region.Framework.Scenes
PhysActor.SetMaterial(Material); PhysActor.SetMaterial(Material);
DoPhysicsPropertyUpdate(RigidBody, true); DoPhysicsPropertyUpdate(RigidBody, true);
PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
if (!building)
PhysActor.Building = false;
} }
} }
} }
@ -1792,6 +1795,10 @@ namespace OpenSim.Region.Framework.Scenes
if (!isNew) if (!isNew)
ParentGroup.Scene.RemovePhysicalPrim(1); ParentGroup.Scene.RemovePhysicalPrim(1);
Velocity = new Vector3(0, 0, 0);
Acceleration = new Vector3(0, 0, 0);
AngularVelocity = new Vector3(0, 0, 0);
PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
PhysActor.delink(); PhysActor.delink();
@ -4268,7 +4275,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="SetTemporary"></param> /// <param name="SetTemporary"></param>
/// <param name="SetPhantom"></param> /// <param name="SetPhantom"></param>
/// <param name="SetVD"></param> /// <param name="SetVD"></param>
public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) // public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD)
public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building)
{ {
bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
@ -4286,6 +4294,9 @@ namespace OpenSim.Region.Framework.Scenes
// that... // that...
// ... if VD is changed, all others are not. // ... if VD is changed, all others are not.
// ... if one of the others is changed, VD is not. // ... if one of the others is changed, VD is not.
// do this first
if (building && PhysActor != null && PhysActor.Building != building)
PhysActor.Building = building;
if (SetVD) // VD is active, special logic applies if (SetVD) // VD is active, special logic applies
{ {
// State machine logic for VolumeDetect // State machine logic for VolumeDetect
@ -4448,6 +4459,9 @@ namespace OpenSim.Region.Framework.Scenes
} }
// m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
// and last in case we have a new actor and not building
if (PhysActor != null && PhysActor.Building != building)
PhysActor.Building = building;
if (ParentGroup != null) if (ParentGroup != null)
{ {
ParentGroup.HasGroupChanged = true; ParentGroup.HasGroupChanged = true;

View File

@ -2062,7 +2062,7 @@ namespace OpenSim.Region.Physics.OdePlugin
SetInStaticSpace(this); SetInStaticSpace(this);
} }
m_building = false; // REMOVE THIS LATER // m_building = false; // REMOVE THIS LATER
if (m_isphysical && Body == IntPtr.Zero) if (m_isphysical && Body == IntPtr.Zero)