diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 162 |
1 files changed, 88 insertions, 74 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2b1fba0..046553b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -125,12 +125,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
125 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 125 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
126 | 126 | ||
127 | /// <value> | 127 | /// <value> |
128 | /// Is this sop a root part? | 128 | /// Is this a root part? |
129 | /// </value> | 129 | /// </value> |
130 | 130 | /// <remarks> | |
131 | /// This will return true even if the whole object is attached to an avatar. | ||
132 | /// </remarks> | ||
131 | public bool IsRoot | 133 | public bool IsRoot |
132 | { | 134 | { |
133 | get { return ParentGroup.RootPart == this; } | 135 | get { return ParentGroup.RootPart == this; } |
134 | } | 136 | } |
135 | 137 | ||
136 | #region Fields | 138 | #region Fields |
@@ -159,15 +161,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
159 | /// If another thread is simultaneously turning physics off on this part then this refernece could become | 161 | /// If another thread is simultaneously turning physics off on this part then this refernece could become |
160 | /// null at any time. | 162 | /// null at any time. |
161 | /// </remarks> | 163 | /// </remarks> |
162 | public PhysicsActor PhysActor | 164 | public PhysicsActor PhysActor { get; set; } |
163 | { | ||
164 | get { return m_physActor; } | ||
165 | set | ||
166 | { | ||
167 | // m_log.DebugFormat("[SOP]: PhysActor set to {0} for {1} {2}", value, Name, UUID); | ||
168 | m_physActor = value; | ||
169 | } | ||
170 | } | ||
171 | 165 | ||
172 | //Xantor 20080528 Sound stuff: | 166 | //Xantor 20080528 Sound stuff: |
173 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. | 167 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. |
@@ -187,10 +181,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
187 | public uint TimeStampLastActivity; // Will be used for AutoReturn | 181 | public uint TimeStampLastActivity; // Will be used for AutoReturn |
188 | 182 | ||
189 | public uint TimeStampTerse; | 183 | public uint TimeStampTerse; |
190 | |||
191 | public UUID FromItemID; | ||
192 | |||
193 | public UUID FromFolderID; | ||
194 | 184 | ||
195 | public int STATUS_ROTATE_X; | 185 | public int STATUS_ROTATE_X; |
196 | 186 | ||
@@ -266,7 +256,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
266 | 256 | ||
267 | private bool m_passTouches; | 257 | private bool m_passTouches; |
268 | 258 | ||
269 | private PhysicsActor m_physActor; | ||
270 | protected Vector3 m_acceleration; | 259 | protected Vector3 m_acceleration; |
271 | protected Vector3 m_angularVelocity; | 260 | protected Vector3 m_angularVelocity; |
272 | 261 | ||
@@ -1112,6 +1101,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1112 | } | 1101 | } |
1113 | } | 1102 | } |
1114 | 1103 | ||
1104 | /// <summary> | ||
1105 | /// The parent ID of this part. | ||
1106 | /// </summary> | ||
1107 | /// <remarks> | ||
1108 | /// If this is a root part which is not attached to an avatar then the value will be 0. | ||
1109 | /// If this is a root part which is attached to an avatar then the value is the local id of that avatar. | ||
1110 | /// If this is a child part then the value is the local ID of the root part. | ||
1111 | /// </remarks> | ||
1115 | public uint ParentID | 1112 | public uint ParentID |
1116 | { | 1113 | { |
1117 | get { return _parentID; } | 1114 | get { return _parentID; } |
@@ -1488,40 +1485,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1488 | if (VolumeDetectActive) | 1485 | if (VolumeDetectActive) |
1489 | isPhantom = false; | 1486 | isPhantom = false; |
1490 | 1487 | ||
1491 | // Added clarification.. since A rigid body is an object that you can kick around, etc. | ||
1492 | bool RigidBody = isPhysical && !isPhantom; | ||
1493 | |||
1494 | // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition | 1488 | // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition |
1495 | // or flexible | 1489 | // or flexible |
1496 | if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 1490 | if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1497 | { | 1491 | { |
1498 | try | 1492 | // Added clarification.. since A rigid body is an object that you can kick around, etc. |
1499 | { | 1493 | bool rigidBody = isPhysical && !isPhantom; |
1500 | PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( | ||
1501 | string.Format("{0}/{1}", Name, UUID), | ||
1502 | Shape, | ||
1503 | AbsolutePosition, | ||
1504 | Scale, | ||
1505 | RotationOffset, | ||
1506 | RigidBody, | ||
1507 | m_localId); | ||
1508 | } | ||
1509 | catch | ||
1510 | { | ||
1511 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | ||
1512 | PhysActor = null; | ||
1513 | } | ||
1514 | 1494 | ||
1515 | // Basic Physics can also return null as well as an exception catch. | 1495 | PhysicsActor pa = AddToPhysics(rigidBody); |
1516 | PhysicsActor pa = PhysActor; | ||
1517 | 1496 | ||
1518 | if (pa != null) | 1497 | if (pa != null) |
1519 | { | ||
1520 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | ||
1521 | pa.SetMaterial(Material); | ||
1522 | DoPhysicsPropertyUpdate(RigidBody, true); | ||
1523 | pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | 1498 | pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); |
1524 | } | ||
1525 | } | 1499 | } |
1526 | } | 1500 | } |
1527 | } | 1501 | } |
@@ -4322,41 +4296,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
4322 | if (ParentGroup.Scene == null) | 4296 | if (ParentGroup.Scene == null) |
4323 | return; | 4297 | return; |
4324 | 4298 | ||
4325 | if (ParentGroup.Scene.CollidablePrims && PhysActor == null) | 4299 | if (ParentGroup.Scene.CollidablePrims && pa == null) |
4326 | { | 4300 | { |
4327 | // It's not phantom anymore. So make sure the physics engine get's knowledge of it | 4301 | pa = AddToPhysics(UsePhysics); |
4328 | PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( | ||
4329 | string.Format("{0}/{1}", Name, UUID), | ||
4330 | Shape, | ||
4331 | AbsolutePosition, | ||
4332 | Scale, | ||
4333 | RotationOffset, | ||
4334 | UsePhysics, | ||
4335 | m_localId); | ||
4336 | 4302 | ||
4337 | PhysActor.SetMaterial(Material); | 4303 | if (pa != null) |
4338 | DoPhysicsPropertyUpdate(UsePhysics, true); | ||
4339 | |||
4340 | if (!ParentGroup.IsDeleted) | ||
4341 | { | 4304 | { |
4342 | if (LocalId == ParentGroup.RootPart.LocalId) | 4305 | pa.SetMaterial(Material); |
4306 | DoPhysicsPropertyUpdate(UsePhysics, true); | ||
4307 | |||
4308 | if (!ParentGroup.IsDeleted) | ||
4343 | { | 4309 | { |
4344 | ParentGroup.CheckSculptAndLoad(); | 4310 | if (LocalId == ParentGroup.RootPart.LocalId) |
4311 | { | ||
4312 | ParentGroup.CheckSculptAndLoad(); | ||
4313 | } | ||
4314 | } | ||
4315 | |||
4316 | if ( | ||
4317 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4318 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4319 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4320 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4321 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4322 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4323 | (CollisionSound != UUID.Zero) | ||
4324 | ) | ||
4325 | { | ||
4326 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4327 | pa.SubscribeEvents(1000); | ||
4345 | } | 4328 | } |
4346 | } | ||
4347 | |||
4348 | if ( | ||
4349 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4350 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4351 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4352 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4353 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4354 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4355 | (CollisionSound != UUID.Zero) | ||
4356 | ) | ||
4357 | { | ||
4358 | PhysActor.OnCollisionUpdate += PhysicsCollision; | ||
4359 | PhysActor.SubscribeEvents(1000); | ||
4360 | } | 4329 | } |
4361 | } | 4330 | } |
4362 | else // it already has a physical representation | 4331 | else // it already has a physical representation |
@@ -4418,7 +4387,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
4418 | } | 4387 | } |
4419 | 4388 | ||
4420 | /// <summary> | 4389 | /// <summary> |
4421 | /// This removes the part from physics | 4390 | /// Adds this part to the physics scene. |
4391 | /// </summary> | ||
4392 | /// <remarks>This method also sets the PhysActor property.</remarks> | ||
4393 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | ||
4394 | /// <returns> | ||
4395 | /// The physics actor. null if there was a failure. | ||
4396 | /// </returns> | ||
4397 | private PhysicsActor AddToPhysics(bool rigidBody) | ||
4398 | { | ||
4399 | PhysicsActor pa; | ||
4400 | |||
4401 | try | ||
4402 | { | ||
4403 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | ||
4404 | string.Format("{0}/{1}", Name, UUID), | ||
4405 | Shape, | ||
4406 | AbsolutePosition, | ||
4407 | Scale, | ||
4408 | RotationOffset, | ||
4409 | rigidBody, | ||
4410 | m_localId); | ||
4411 | } | ||
4412 | catch | ||
4413 | { | ||
4414 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | ||
4415 | pa = null; | ||
4416 | } | ||
4417 | |||
4418 | // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical | ||
4419 | // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor | ||
4420 | // being set. | ||
4421 | PhysActor = pa; | ||
4422 | |||
4423 | // Basic Physics can also return null as well as an exception catch. | ||
4424 | if (pa != null) | ||
4425 | { | ||
4426 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | ||
4427 | pa.SetMaterial(Material); | ||
4428 | DoPhysicsPropertyUpdate(rigidBody, true); | ||
4429 | } | ||
4430 | |||
4431 | return pa; | ||
4432 | } | ||
4433 | |||
4434 | /// <summary> | ||
4435 | /// This removes the part from the physics scene. | ||
4422 | /// </summary> | 4436 | /// </summary> |
4423 | /// <remarks> | 4437 | /// <remarks> |
4424 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4438 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |