diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4193d22..05cc822 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -138,13 +138,14 @@ public sealed class BSPrim : PhysicsActor | |||
138 | _isPhysical = pisPhysical; | 138 | _isPhysical = pisPhysical; |
139 | _isVolumeDetect = false; | 139 | _isVolumeDetect = false; |
140 | _subscribedEventsMs = 0; | 140 | _subscribedEventsMs = 0; |
141 | _friction = _scene.Params.defaultFriction; // TODO: compute based on object material | 141 | _friction = _scene.Params.defaultFriction; // TODO: compute based on object material |
142 | _density = _scene.Params.defaultDensity; // TODO: compute based on object material | 142 | _density = _scene.Params.defaultDensity; // TODO: compute based on object material |
143 | _restitution = _scene.Params.defaultRestitution; | 143 | _restitution = _scene.Params.defaultRestitution; |
144 | _linkset = new BSLinkset(_scene, this); // a linkset of one | 144 | _linkset = new BSLinkset(_scene, this); // a linkset of one |
145 | _vehicle = new BSDynamics(this); // add vehicleness | 145 | _vehicle = new BSDynamics(this); // add vehicleness |
146 | _mass = CalculateMass(); | 146 | _mass = CalculateMass(); |
147 | // do the actual object creation at taint time | 147 | // do the actual object creation at taint time |
148 | DetailLog("{0},BSPrim.constructor,call", LocalID); | ||
148 | _scene.TaintedObject("BSPrim.create", delegate() | 149 | _scene.TaintedObject("BSPrim.create", delegate() |
149 | { | 150 | { |
150 | RecreateGeomAndObject(); | 151 | RecreateGeomAndObject(); |
@@ -160,19 +161,22 @@ public sealed class BSPrim : PhysicsActor | |||
160 | public void Destroy() | 161 | public void Destroy() |
161 | { | 162 | { |
162 | // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); | 163 | // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); |
163 | // DetailLog("{0},BSPrim.Destroy", LocalID); | ||
164 | |||
165 | // Undo any vehicle properties | ||
166 | _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); | ||
167 | _scene.RemoveVehiclePrim(this); // just to make sure | ||
168 | 164 | ||
169 | // Undo any links between me and any other object | 165 | // Undo any links between me and any other object |
166 | BSPrim parentBefore = _linkset.Root; | ||
167 | int childrenBefore = _linkset.NumberOfChildren; | ||
168 | |||
170 | _linkset = _linkset.RemoveMeFromLinkset(this); | 169 | _linkset = _linkset.RemoveMeFromLinkset(this); |
171 | 170 | ||
171 | DetailLog("{0},BSPrim.Destroy,call,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}", | ||
172 | LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); | ||
173 | |||
174 | // Undo any vehicle properties | ||
175 | this.VehicleType = (int)Vehicle.TYPE_NONE; | ||
176 | |||
172 | _scene.TaintedObject("BSPrim.destroy", delegate() | 177 | _scene.TaintedObject("BSPrim.destroy", delegate() |
173 | { | 178 | { |
174 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); | 179 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); |
175 | |||
176 | // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. | 180 | // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. |
177 | BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); | 181 | BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); |
178 | }); | 182 | }); |
@@ -229,8 +233,13 @@ public sealed class BSPrim : PhysicsActor | |||
229 | if (parent != null) | 233 | if (parent != null) |
230 | { | 234 | { |
231 | DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID); | 235 | DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID); |
232 | DetailLog("{0},BSPrim.link,parent={1}", LocalID, parent.LocalID); | 236 | BSPrim parentBefore = _linkset.Root; |
233 | _linkset = _linkset.AddMeToLinkset(this, parent); | 237 | int childrenBefore = _linkset.NumberOfChildren; |
238 | |||
239 | _linkset = parent.Linkset.AddMeToLinkset(this); | ||
240 | |||
241 | DetailLog("{0},BSPrim.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}", | ||
242 | LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); | ||
234 | } | 243 | } |
235 | return; | 244 | return; |
236 | } | 245 | } |
@@ -340,21 +349,14 @@ public sealed class BSPrim : PhysicsActor | |||
340 | } | 349 | } |
341 | set { | 350 | set { |
342 | Vehicle type = (Vehicle)value; | 351 | Vehicle type = (Vehicle)value; |
343 | _scene.TaintedObject("BSPrim.setVehicleType", delegate() | 352 | BSPrim vehiclePrim = this; |
353 | _scene.TaintedObject("setVehicleType", delegate() | ||
344 | { | 354 | { |
345 | DetailLog("{0},BSPrim.SetVehicleType,taint,type={1}", LocalID, type); | 355 | // Done at taint time so we're sure the physics engine is not using the variables |
356 | // Vehicle code changes the parameters for this vehicle type. | ||
346 | _vehicle.ProcessTypeChange(type); | 357 | _vehicle.ProcessTypeChange(type); |
347 | if (type == Vehicle.TYPE_NONE) | 358 | // Tell the scene about the vehicle so it will get processing each frame. |
348 | { | 359 | _scene.VehicleInSceneTypeChanged(this, type); |
349 | _scene.RemoveVehiclePrim(this); | ||
350 | } | ||
351 | else | ||
352 | { | ||
353 | BulletSimAPI.ClearForces2(this.Body.Ptr); | ||
354 | // make it so the scene will call us each tick to do vehicle things | ||
355 | _scene.AddVehiclePrim(this); | ||
356 | } | ||
357 | return; | ||
358 | }); | 360 | }); |
359 | } | 361 | } |
360 | } | 362 | } |
@@ -493,8 +495,10 @@ public sealed class BSPrim : PhysicsActor | |||
493 | // Bullet wants static objects to have a mass of zero | 495 | // Bullet wants static objects to have a mass of zero |
494 | float mass = IsStatic ? 0f : _mass; | 496 | float mass = IsStatic ? 0f : _mass; |
495 | 497 | ||
496 | DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); | ||
497 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); | 498 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); |
499 | |||
500 | CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr); | ||
501 | DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf); | ||
498 | } | 502 | } |
499 | 503 | ||
500 | // prims don't fly | 504 | // prims don't fly |
@@ -1224,7 +1228,7 @@ public sealed class BSPrim : PhysicsActor | |||
1224 | bool ret = BulletSimAPI.CreateObject(_scene.WorldID, shape); | 1228 | bool ret = BulletSimAPI.CreateObject(_scene.WorldID, shape); |
1225 | 1229 | ||
1226 | // the CreateObject() may have recreated the rigid body. Make sure we have the latest. | 1230 | // the CreateObject() may have recreated the rigid body. Make sure we have the latest. |
1227 | m_body.Ptr = BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID); | 1231 | Body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); |
1228 | 1232 | ||
1229 | return ret; | 1233 | return ret; |
1230 | } | 1234 | } |
@@ -1344,7 +1348,7 @@ public sealed class BSPrim : PhysicsActor | |||
1344 | else | 1348 | else |
1345 | { | 1349 | { |
1346 | // For debugging, we also report the movement of children | 1350 | // For debugging, we also report the movement of children |
1347 | DetailLog("{0},BSPrim.BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", | 1351 | DetailLog("{0},BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", |
1348 | LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, | 1352 | LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, |
1349 | entprop.Acceleration, entprop.RotationalVelocity); | 1353 | entprop.Acceleration, entprop.RotationalVelocity); |
1350 | } | 1354 | } |