Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork

avinationmerge
ubit 2012-05-15 17:05:14 +02:00
commit 9ee6afb887
4 changed files with 200 additions and 62 deletions

View File

@ -170,6 +170,7 @@ namespace OpenSim.Data.MySQL
"ParticleSystem, ClickAction, Material, " +
"CollisionSound, CollisionSoundVolume, " +
"PassTouches, " +
"PassCollisions, " +
"LinkNumber, MediaURL, KeyframeMotion, " +
"PhysicsShapeType, Density, GravityModifier, " +
"Friction, Restitution) values (" + "?UUID, " +
@ -203,7 +204,7 @@ namespace OpenSim.Data.MySQL
"?SaleType, ?ColorR, ?ColorG, " +
"?ColorB, ?ColorA, ?ParticleSystem, " +
"?ClickAction, ?Material, ?CollisionSound, " +
"?CollisionSoundVolume, ?PassTouches, " +
"?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " +
"?LinkNumber, ?MediaURL, ?KeyframeMotion, " +
"?PhysicsShapeType, ?Density, ?GravityModifier, " +
"?Friction, ?Restitution)";
@ -1231,6 +1232,7 @@ namespace OpenSim.Data.MySQL
prim.CollisionSoundVolume = (float)(double)row["CollisionSoundVolume"];
prim.PassTouches = ((sbyte)row["PassTouches"] != 0);
prim.PassCollisions = ((sbyte)row["PassCollisions"] != 0);
prim.LinkNum = (int)row["LinkNumber"];
if (!(row["MediaURL"] is System.DBNull))
@ -1605,6 +1607,11 @@ namespace OpenSim.Data.MySQL
else
cmd.Parameters.AddWithValue("PassTouches", 0);
if (prim.PassCollisions)
cmd.Parameters.AddWithValue("PassCollisions", 1);
else
cmd.Parameters.AddWithValue("PassCollisions", 0);
cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);

View File

@ -123,10 +123,16 @@ namespace OpenSim.Region.Framework.Scenes
/// </value>
public const int ALL_SIDES = -1;
private const scriptEvents PhyscicsNeededSubsEvents = (
private const scriptEvents PhysicsNeededSubsEvents = (
scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end |
scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end
);
private const scriptEvents PhyscicsPhantonSubsEvents = (
scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end
);
private const scriptEvents PhyscicsVolumeDtcSubsEvents = (
scriptEvents.collision_start | scriptEvents.collision_end
);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -1882,7 +1888,10 @@ namespace OpenSim.Region.Framework.Scenes
{
if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment
&& !(Shape.PathCurve == (byte)Extrusion.Flexible))
{
AddToPhysics(isPhysical, isPhantom, building, isPhysical);
UpdatePhysicsSubscribedEvents(); // not sure if appliable here
}
else
PhysActor = null; // just to be sure
}
@ -1975,6 +1984,7 @@ namespace OpenSim.Region.Framework.Scenes
bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0);
dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
// dupe.UpdatePhysicsSubscribedEvents(); // not sure...
}
if (dupe.PhysActor != null)
@ -2564,7 +2574,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0)
if ((ParentGroup.RootPart.ScriptEvents & ev) != 0)
sendToRoot = true;
}
if (sendToRoot && ParentGroup.RootPart != this)
@ -2602,6 +2612,21 @@ namespace OpenSim.Region.Framework.Scenes
List<uint> endedColliders = new List<uint>();
List<uint> startedColliders = new List<uint>();
if (collissionswith.Count == 0)
{
if (m_lastColliders.Count == 0)
return; // nothing to do
foreach (uint localID in m_lastColliders)
{
endedColliders.Add(localID);
}
m_lastColliders.Clear();
}
else
{
// calculate things that started colliding this time
// and build up list of colliders this time
foreach (uint localid in collissionswith.Keys)
@ -2625,22 +2650,20 @@ namespace OpenSim.Region.Framework.Scenes
// remove things that ended colliding from the last colliders list
foreach (uint localID in endedColliders)
m_lastColliders.Remove(localID);
}
// play the sound.
if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f)
SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false);
SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart);
if(!ParentGroup.RootPart.VolumeDetectActive)
SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding);
SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd);
if (startedColliders.Contains(0))
{
SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart);
if (m_lastColliders.Contains(0))
SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding);
else
SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart);
}
if (endedColliders.Contains(0))
SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd);
}
@ -4382,26 +4405,28 @@ namespace OpenSim.Region.Framework.Scenes
{
if (pa == null)
{
AddToPhysics(UsePhysics, SetPhantom, building , false);
AddToPhysics(UsePhysics, SetPhantom, building, false);
pa = PhysActor;
/*
if (pa != null)
{
if (
// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
// (CollisionSound != UUID.Zero)
// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
(CollisionSound != UUID.Zero)
)
{
pa.OnCollisionUpdate += PhysicsCollision;
pa.SubscribeEvents(1000);
}
}
*/
}
else // it already has a physical representation
@ -4413,9 +4438,13 @@ namespace OpenSim.Region.Framework.Scenes
else
pa.SetVolumeDetect(0);
*/
if (pa.Building != building)
pa.Building = building;
}
UpdatePhysicsSubscribedEvents();
}
}
@ -4538,8 +4567,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <remarks>
/// This isn't the same as turning off physical, since even without being physical the prim has a physics
/// representation for collision detection. Rather, this would be used in situations such as making a prim
/// phantom.
/// representation for collision detection.
/// </remarks>
public void RemoveFromPhysics()
{
@ -4703,8 +4731,51 @@ namespace OpenSim.Region.Framework.Scenes
ScheduleFullUpdate();
}
private void UpdatePhysicsSubscribedEvents()
{
PhysicsActor pa = PhysActor;
if (pa == null)
return;
pa.OnCollisionUpdate -= PhysicsCollision;
bool hassound = ( CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f);
scriptEvents CombinedEvents = AggregateScriptEvents;
// merge with root part
if (ParentGroup != null && ParentGroup.RootPart != null)
CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents;
// submit to this part case
if (VolumeDetectActive)
{
CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
hassound = false;
}
else if ((Flags & PrimFlags.Phantom) != 0)
CombinedEvents &= PhyscicsPhantonSubsEvents;
else
CombinedEvents &= PhysicsNeededSubsEvents;
if (hassound || CombinedEvents != 0)
{
// subscribe to physics updates.
pa.OnCollisionUpdate += PhysicsCollision;
pa.SubscribeEvents(50); // 20 reports per second
}
else
{
pa.UnSubscribeEvents();
}
}
public void aggregateScriptEvents()
{
if (ParentGroup == null || ParentGroup.RootPart == null)
return;
AggregateScriptEvents = 0;
// Aggregate script events
@ -4736,7 +4807,7 @@ namespace OpenSim.Region.Framework.Scenes
{
objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
}
/*
PhysicsActor pa = PhysActor;
if (pa != null)
{
@ -4747,7 +4818,7 @@ namespace OpenSim.Region.Framework.Scenes
// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
)
{
// subscribe to physics updates.
@ -4760,6 +4831,9 @@ namespace OpenSim.Region.Framework.Scenes
pa.OnCollisionUpdate -= PhysicsCollision;
}
}
*/
UpdatePhysicsSubscribedEvents();
//if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
//{
// ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;

View File

@ -194,8 +194,10 @@ namespace OpenSim.Region.Physics.OdePlugin
public int givefakeori = 0;
private Quaternion fakeori;
public int m_eventsubscription;
private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
private int m_eventsubscription;
private int m_cureventsubscription;
private CollisionEventUpdate CollisionEventsThisFrame = null;
private bool SentEmptyCollisionsEvent;
public volatile bool childPrim;
@ -931,12 +933,21 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void SubscribeEvents(int ms)
{
m_eventsubscription = ms;
m_cureventsubscription = 0;
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
SentEmptyCollisionsEvent = false;
_parent_scene.AddCollisionEventReporting(this);
}
public override void UnSubscribeEvents()
{
_parent_scene.RemoveCollisionEventReporting(this);
if (CollisionEventsThisFrame != null)
{
CollisionEventsThisFrame.Clear();
CollisionEventsThisFrame = null;
}
m_eventsubscription = 0;
}
@ -944,7 +955,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
}
@ -953,14 +963,34 @@ namespace OpenSim.Region.Physics.OdePlugin
if (CollisionEventsThisFrame == null)
return;
if (m_cureventsubscription < m_eventsubscription)
return;
m_cureventsubscription = 0;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (!SentEmptyCollisionsEvent || ncolisions > 0)
{
base.SendCollisionUpdate(CollisionEventsThisFrame);
if (CollisionEventsThisFrame.m_objCollisionList.Count == 0)
CollisionEventsThisFrame = null;
if (ncolisions == 0)
SentEmptyCollisionsEvent = true;
else
CollisionEventsThisFrame = new CollisionEventUpdate();
{
SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear();
}
}
}
internal void AddCollisionFrameTime(int t)
{
// protect it from overflow crashing
if (m_cureventsubscription + t >= int.MaxValue)
m_cureventsubscription = 0;
m_cureventsubscription += t;
}
public override bool SubscribedEvents()
{
if (m_eventsubscription > 0)

View File

@ -620,8 +620,6 @@ namespace OpenSim.Region.Physics.OdePlugin
return d.JointCreateContactPtr(world, contactgroup, contact);
}
private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom)
{
if (ContactgeomsArray == IntPtr.Zero || index >= contactsPerCollision)
@ -1153,6 +1151,31 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
break;
case ActorTypes.Ground:
case ActorTypes.Unknown:
default:
switch ((ActorTypes)p2.PhysicsActorType)
{
case ActorTypes.Agent:
if (p2 is OdeCharacter)
{
cc2 = (OdeCharacter)p2;
obj2LocalID = cc2.m_localID;
if (p2events)
cc2.AddCollisionEvent(0, contact);
}
break;
case ActorTypes.Prim:
if (p2 is OdePrim)
{
cp2 = (OdePrim)p2;
obj2LocalID = cp2.m_localID;
if (p2events)
cp2.AddCollisionEvent(0, contact);
}
break;
}
break;
}
}
@ -1875,7 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
case ActorTypes.Prim:
OdePrim pobj = (OdePrim)obj;
if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
{
pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
pobj.SendCollisions();
}
break;
}
}