BSPhysObject.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyrightD
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Text;
  30. using OMV = OpenMetaverse;
  31. using OpenSim.Framework;
  32. using OpenSim.Region.Physics.Manager;
  33. namespace OpenSim.Region.Physics.BulletSPlugin
  34. {
  35. /*
  36. * Class to wrap all objects.
  37. * The rest of BulletSim doesn't need to keep checking for avatars or prims
  38. * unless the difference is significant.
  39. *
  40. * Variables in the physicsl objects are in three forms:
  41. * VariableName: used by the simulator and performs taint operations, etc
  42. * RawVariableName: direct reference to the BulletSim storage for the variable value
  43. * ForceVariableName: direct reference (store and fetch) to the value in the physics engine.
  44. * The last one should only be referenced in taint-time.
  45. */
  46. /*
  47. * As of 20121221, the following are the call sequences (going down) for different script physical functions:
  48. * llApplyImpulse llApplyRotImpulse llSetTorque llSetForce
  49. * SOP.ApplyImpulse SOP.ApplyAngularImpulse SOP.SetAngularImpulse SOP.SetForce
  50. * SOG.ApplyImpulse SOG.ApplyAngularImpulse SOG.SetAngularImpulse
  51. * PA.AddForce PA.AddAngularForce PA.Torque = v PA.Force = v
  52. * BS.ApplyCentralForce BS.ApplyTorque
  53. */
  54. // Flags used to denote which properties updates when making UpdateProperties calls to linksets, etc.
  55. public enum UpdatedProperties : uint
  56. {
  57. Position = 1 << 0,
  58. Orientation = 1 << 1,
  59. Velocity = 1 << 2,
  60. Acceleration = 1 << 3,
  61. RotationalVelocity = 1 << 4,
  62. EntPropUpdates = Position | Orientation | Velocity | Acceleration | RotationalVelocity,
  63. }
  64. public abstract class BSPhysObject : PhysicsActor
  65. {
  66. protected BSPhysObject()
  67. {
  68. }
  69. protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName)
  70. {
  71. PhysScene = parentScene;
  72. LocalID = localID;
  73. PhysObjectName = name;
  74. Name = name; // PhysicsActor also has the name of the object. Someday consolidate.
  75. TypeName = typeName;
  76. // The collection of things that push me around
  77. PhysicalActors = new BSActorCollection(PhysScene);
  78. // Initialize variables kept in base.
  79. GravModifier = 1.0f;
  80. Gravity = new OMV.Vector3(0f, 0f, BSParam.Gravity);
  81. HoverActive = false;
  82. // We don't have any physical representation yet.
  83. PhysBody = new BulletBody(localID);
  84. PhysShape = new BSShapeNull();
  85. UserSetCenterOfMassDisplacement = null;
  86. PrimAssetState = PrimAssetCondition.Unknown;
  87. // Default material type. Also sets Friction, Restitution and Density.
  88. SetMaterial((int)MaterialAttributes.Material.Wood);
  89. CollisionCollection = new CollisionEventUpdate();
  90. CollisionsLastReported = CollisionCollection;
  91. CollisionsLastTick = new CollisionEventUpdate();
  92. CollisionsLastTickStep = -1;
  93. SubscribedEventsMs = 0;
  94. // Crazy values that will never be true
  95. CollidingStep = BSScene.NotASimulationStep;
  96. CollidingGroundStep = BSScene.NotASimulationStep;
  97. CollisionAccumulation = BSScene.NotASimulationStep;
  98. ColliderIsMoving = false;
  99. CollisionScore = 0;
  100. // All axis free.
  101. LockedLinearAxis = LockedAxisFree;
  102. LockedAngularAxis = LockedAxisFree;
  103. }
  104. // Tell the object to clean up.
  105. public virtual void Destroy()
  106. {
  107. PhysicalActors.Enable(false);
  108. PhysScene.TaintedObject("BSPhysObject.Destroy", delegate()
  109. {
  110. PhysicalActors.Dispose();
  111. });
  112. }
  113. public BSScene PhysScene { get; protected set; }
  114. // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor
  115. public string PhysObjectName { get; protected set; }
  116. public string TypeName { get; protected set; }
  117. // Return the object mass without calculating it or having side effects
  118. public abstract float RawMass { get; }
  119. // Set the raw mass but also update physical mass properties (inertia, ...)
  120. // 'inWorld' true if the object has already been added to the dynamic world.
  121. public abstract void UpdatePhysicalMassProperties(float mass, bool inWorld);
  122. // The gravity being applied to the object. A function of default grav, GravityModifier and Buoyancy.
  123. public virtual OMV.Vector3 Gravity { get; set; }
  124. // The last value calculated for the prim's inertia
  125. public OMV.Vector3 Inertia { get; set; }
  126. // Reference to the physical body (btCollisionObject) of this object
  127. public BulletBody PhysBody;
  128. // Reference to the physical shape (btCollisionShape) of this object
  129. public BSShape PhysShape;
  130. // The physical representation of the prim might require an asset fetch.
  131. // The asset state is first 'Unknown' then 'Waiting' then either 'Failed' or 'Fetched'.
  132. public enum PrimAssetCondition
  133. {
  134. Unknown, Waiting, FailedAssetFetch, FailedMeshing, Fetched
  135. }
  136. public PrimAssetCondition PrimAssetState { get; set; }
  137. // The objects base shape information. Null if not a prim type shape.
  138. public PrimitiveBaseShape BaseShape { get; protected set; }
  139. // When the physical properties are updated, an EntityProperty holds the update values.
  140. // Keep the current and last EntityProperties to enable computation of differences
  141. // between the current update and the previous values.
  142. public EntityProperties CurrentEntityProperties { get; set; }
  143. public EntityProperties LastEntityProperties { get; set; }
  144. public virtual OMV.Vector3 Scale { get; set; }
  145. // It can be confusing for an actor to know if it should move or update an object
  146. // depeneding on the setting of 'selected', 'physical, ...
  147. // This flag is the true test -- if true, the object is being acted on in the physical world
  148. public abstract bool IsPhysicallyActive { get; }
  149. // Detailed state of the object.
  150. public abstract bool IsSolid { get; }
  151. public abstract bool IsStatic { get; }
  152. public abstract bool IsSelected { get; }
  153. // Materialness
  154. public MaterialAttributes.Material Material { get; private set; }
  155. public override void SetMaterial(int material)
  156. {
  157. Material = (MaterialAttributes.Material)material;
  158. // Setting the material sets the material attributes also.
  159. // TODO: decide if this is necessary -- the simulator does this.
  160. MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
  161. Friction = matAttrib.friction;
  162. Restitution = matAttrib.restitution;
  163. Density = matAttrib.density / BSParam.DensityScaleFactor;
  164. // DetailLog("{0},{1}.SetMaterial,Mat={2},frict={3},rest={4},den={5}", LocalID, TypeName, Material, Friction, Restitution, Density);
  165. }
  166. // Stop all physical motion.
  167. public abstract void ZeroMotion(bool inTaintTime);
  168. public abstract void ZeroAngularMotion(bool inTaintTime);
  169. // Update the physical location and motion of the object. Called with data from Bullet.
  170. public abstract void UpdateProperties(EntityProperties entprop);
  171. public virtual OMV.Vector3 RawPosition { get; set; }
  172. public abstract OMV.Vector3 ForcePosition { get; set; }
  173. public virtual OMV.Quaternion RawOrientation { get; set; }
  174. public abstract OMV.Quaternion ForceOrientation { get; set; }
  175. public OMV.Vector3 RawVelocity { get; set; }
  176. public abstract OMV.Vector3 ForceVelocity { get; set; }
  177. public OMV.Vector3 RawForce { get; set; }
  178. public OMV.Vector3 RawTorque { get; set; }
  179. public override void AddAngularForce(OMV.Vector3 force, bool pushforce)
  180. {
  181. AddAngularForce(force, pushforce, false);
  182. }
  183. public abstract void AddAngularForce(OMV.Vector3 force, bool pushforce, bool inTaintTime);
  184. public abstract void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime);
  185. public abstract OMV.Vector3 ForceRotationalVelocity { get; set; }
  186. public abstract float ForceBuoyancy { get; set; }
  187. public virtual bool ForceBodyShapeRebuild(bool inTaintTime) { return false; }
  188. public override bool PIDActive { set { MoveToTargetActive = value; } }
  189. public override OMV.Vector3 PIDTarget { set { MoveToTargetTarget = value; } }
  190. public override float PIDTau { set { MoveToTargetTau = value; } }
  191. public bool MoveToTargetActive { get; set; }
  192. public OMV.Vector3 MoveToTargetTarget { get; set; }
  193. public float MoveToTargetTau { get; set; }
  194. // Used for llSetHoverHeight and maybe vehicle height. Hover Height will override MoveTo target's Z
  195. public override bool PIDHoverActive { set { HoverActive = value; } }
  196. public override float PIDHoverHeight { set { HoverHeight = value; } }
  197. public override PIDHoverType PIDHoverType { set { HoverType = value; } }
  198. public override float PIDHoverTau { set { HoverTau = value; } }
  199. public bool HoverActive { get; set; }
  200. public float HoverHeight { get; set; }
  201. public PIDHoverType HoverType { get; set; }
  202. public float HoverTau { get; set; }
  203. // For RotLookAt
  204. public override OMV.Quaternion APIDTarget { set { return; } }
  205. public override bool APIDActive { set { return; } }
  206. public override float APIDStrength { set { return; } }
  207. public override float APIDDamping { set { return; } }
  208. // The current velocity forward
  209. public virtual float ForwardSpeed
  210. {
  211. get
  212. {
  213. OMV.Vector3 characterOrientedVelocity = RawVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation));
  214. return characterOrientedVelocity.X;
  215. }
  216. }
  217. // The forward speed we are trying to achieve (TargetVelocity)
  218. public virtual float TargetVelocitySpeed
  219. {
  220. get
  221. {
  222. OMV.Vector3 characterOrientedVelocity = TargetVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation));
  223. return characterOrientedVelocity.X;
  224. }
  225. }
  226. // The user can optionally set the center of mass. The user's setting will override any
  227. // computed center-of-mass (like in linksets).
  228. // Note this is a displacement from the root's coordinates. Zero means use the root prim as center-of-mass.
  229. public OMV.Vector3? UserSetCenterOfMassDisplacement { get; set; }
  230. public OMV.Vector3 LockedLinearAxis { get; set; } // zero means locked. one means free.
  231. public OMV.Vector3 LockedAngularAxis { get; set; } // zero means locked. one means free.
  232. public const float FreeAxis = 1f;
  233. public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(FreeAxis, FreeAxis, FreeAxis); // All axis are free
  234. // Enable physical actions. Bullet will keep sleeping non-moving physical objects so
  235. // they need waking up when parameters are changed.
  236. // Called in taint-time!!
  237. public void ActivateIfPhysical(bool forceIt)
  238. {
  239. if (IsPhysical && PhysBody.HasPhysicalBody)
  240. PhysScene.PE.Activate(PhysBody, forceIt);
  241. }
  242. // 'actors' act on the physical object to change or constrain its motion. These can range from
  243. // hovering to complex vehicle motion.
  244. // May be called at non-taint time as this just adds the actor to the action list and the real
  245. // work is done during the simulation step.
  246. // Note that, if the actor is already in the list and we are disabling same, the actor is just left
  247. // in the list disabled.
  248. public delegate BSActor CreateActor();
  249. public void EnableActor(bool enableActor, string actorName, CreateActor creator)
  250. {
  251. lock (PhysicalActors)
  252. {
  253. BSActor theActor;
  254. if (PhysicalActors.TryGetActor(actorName, out theActor))
  255. {
  256. // The actor already exists so just turn it on or off
  257. DetailLog("{0},BSPhysObject.EnableActor,enablingExistingActor,name={1},enable={2}", LocalID, actorName, enableActor);
  258. theActor.Enabled = enableActor;
  259. }
  260. else
  261. {
  262. // The actor does not exist. If it should, create it.
  263. if (enableActor)
  264. {
  265. DetailLog("{0},BSPhysObject.EnableActor,creatingActor,name={1}", LocalID, actorName);
  266. theActor = creator();
  267. PhysicalActors.Add(actorName, theActor);
  268. theActor.Enabled = true;
  269. }
  270. else
  271. {
  272. DetailLog("{0},BSPhysObject.EnableActor,notCreatingActorSinceNotEnabled,name={1}", LocalID, actorName);
  273. }
  274. }
  275. }
  276. }
  277. #region Collisions
  278. // Requested number of milliseconds between collision events. Zero means disabled.
  279. protected int SubscribedEventsMs { get; set; }
  280. // Given subscription, the time that a collision may be passed up
  281. protected int NextCollisionOkTime { get; set; }
  282. // The simulation step that last had a collision
  283. protected long CollidingStep { get; set; }
  284. // The simulation step that last had a collision with the ground
  285. protected long CollidingGroundStep { get; set; }
  286. // The simulation step that last collided with an object
  287. protected long CollidingObjectStep { get; set; }
  288. // The collision flags we think are set in Bullet
  289. protected CollisionFlags CurrentCollisionFlags { get; set; }
  290. // On a collision, check the collider and remember if the last collider was moving
  291. // Used to modify the standing of avatars (avatars on stationary things stand still)
  292. public bool ColliderIsMoving;
  293. // Used by BSCharacter to manage standing (and not slipping)
  294. public bool IsStationary;
  295. // Count of collisions for this object
  296. protected long CollisionAccumulation { get; set; }
  297. public override bool IsColliding {
  298. get { return (CollidingStep == PhysScene.SimulationStep); }
  299. set {
  300. if (value)
  301. CollidingStep = PhysScene.SimulationStep;
  302. else
  303. CollidingStep = BSScene.NotASimulationStep;
  304. }
  305. }
  306. public override bool CollidingGround {
  307. get { return (CollidingGroundStep == PhysScene.SimulationStep); }
  308. set
  309. {
  310. if (value)
  311. CollidingGroundStep = PhysScene.SimulationStep;
  312. else
  313. CollidingGroundStep = BSScene.NotASimulationStep;
  314. }
  315. }
  316. public override bool CollidingObj {
  317. get { return (CollidingObjectStep == PhysScene.SimulationStep); }
  318. set {
  319. if (value)
  320. CollidingObjectStep = PhysScene.SimulationStep;
  321. else
  322. CollidingObjectStep = BSScene.NotASimulationStep;
  323. }
  324. }
  325. // The collisions that have been collected for the next collision reporting (throttled by subscription)
  326. protected CollisionEventUpdate CollisionCollection;
  327. // This is the collision collection last reported to the Simulator.
  328. public CollisionEventUpdate CollisionsLastReported;
  329. // Remember the collisions recorded in the last tick for fancy collision checking
  330. // (like a BSCharacter walking up stairs).
  331. public CollisionEventUpdate CollisionsLastTick;
  332. private long CollisionsLastTickStep = -1;
  333. // The simulation step is telling this object about a collision.
  334. // Return 'true' if a collision was processed and should be sent up.
  335. // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision.
  336. // Called at taint time from within the Step() function
  337. public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
  338. OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
  339. {
  340. bool ret = false;
  341. // The following lines make IsColliding(), CollidingGround() and CollidingObj work
  342. CollidingStep = PhysScene.SimulationStep;
  343. if (collidingWith <= PhysScene.TerrainManager.HighestTerrainID)
  344. {
  345. CollidingGroundStep = PhysScene.SimulationStep;
  346. }
  347. else
  348. {
  349. CollidingObjectStep = PhysScene.SimulationStep;
  350. }
  351. CollisionAccumulation++;
  352. // For movement tests, remember if we are colliding with an object that is moving.
  353. ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero) : false;
  354. // Make a collection of the collisions that happened the last simulation tick.
  355. // This is different than the collection created for sending up to the simulator as it is cleared every tick.
  356. if (CollisionsLastTickStep != PhysScene.SimulationStep)
  357. {
  358. CollisionsLastTick = new CollisionEventUpdate();
  359. CollisionsLastTickStep = PhysScene.SimulationStep;
  360. }
  361. CollisionsLastTick.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
  362. // If someone has subscribed for collision events log the collision so it will be reported up
  363. if (SubscribedEvents()) {
  364. CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
  365. DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}",
  366. LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving);
  367. ret = true;
  368. }
  369. return ret;
  370. }
  371. // Send the collected collisions into the simulator.
  372. // Called at taint time from within the Step() function thus no locking problems
  373. // with CollisionCollection and ObjectsWithNoMoreCollisions.
  374. // Return 'true' if there were some actual collisions passed up
  375. public virtual bool SendCollisions()
  376. {
  377. bool ret = true;
  378. // If the 'no collision' call, force it to happen right now so quick collision_end
  379. bool force = (CollisionCollection.Count == 0 && CollisionsLastReported.Count != 0);
  380. // throttle the collisions to the number of milliseconds specified in the subscription
  381. if (force || (PhysScene.SimulationNowTime >= NextCollisionOkTime))
  382. {
  383. NextCollisionOkTime = PhysScene.SimulationNowTime + SubscribedEventsMs;
  384. // We are called if we previously had collisions. If there are no collisions
  385. // this time, send up one last empty event so OpenSim can sense collision end.
  386. if (CollisionCollection.Count == 0)
  387. {
  388. // If I have no collisions this time, remove me from the list of objects with collisions.
  389. ret = false;
  390. }
  391. DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count);
  392. base.SendCollisionUpdate(CollisionCollection);
  393. // Remember the collisions from this tick for some collision specific processing.
  394. CollisionsLastReported = CollisionCollection;
  395. // The CollisionCollection instance is passed around in the simulator.
  396. // Make sure we don't have a handle to that one and that a new one is used for next time.
  397. // This fixes an interesting 'gotcha'. If we call CollisionCollection.Clear() here,
  398. // a race condition is created for the other users of this instance.
  399. CollisionCollection = new CollisionEventUpdate();
  400. }
  401. return ret;
  402. }
  403. // Subscribe for collision events.
  404. // Parameter is the millisecond rate the caller wishes collision events to occur.
  405. public override void SubscribeEvents(int ms) {
  406. // DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms);
  407. SubscribedEventsMs = ms;
  408. if (ms > 0)
  409. {
  410. // make sure first collision happens
  411. NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs);
  412. PhysScene.TaintedObject(TypeName+".SubscribeEvents", delegate()
  413. {
  414. if (PhysBody.HasPhysicalBody)
  415. CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
  416. });
  417. }
  418. else
  419. {
  420. // Subscribing for zero or less is the same as unsubscribing
  421. UnSubscribeEvents();
  422. }
  423. }
  424. public override void UnSubscribeEvents() {
  425. // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName);
  426. SubscribedEventsMs = 0;
  427. PhysScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate()
  428. {
  429. // Make sure there is a body there because sometimes destruction happens in an un-ideal order.
  430. if (PhysBody.HasPhysicalBody)
  431. CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
  432. });
  433. }
  434. // Return 'true' if the simulator wants collision events
  435. public override bool SubscribedEvents() {
  436. return (SubscribedEventsMs > 0);
  437. }
  438. // Because 'CollisionScore' is called many times while sorting, it should not be recomputed
  439. // each time called. So this is built to be light weight for each collision and to do
  440. // all the processing when the user asks for the info.
  441. public void ComputeCollisionScore()
  442. {
  443. // Scale the collision count by the time since the last collision.
  444. // The "+1" prevents dividing by zero.
  445. long timeAgo = PhysScene.SimulationStep - CollidingStep + 1;
  446. CollisionScore = CollisionAccumulation / timeAgo;
  447. }
  448. public override float CollisionScore { get; set; }
  449. #endregion // Collisions
  450. #region Per Simulation Step actions
  451. public BSActorCollection PhysicalActors;
  452. // When an update to the physical properties happens, this event is fired to let
  453. // different actors to modify the update before it is passed around
  454. public delegate void PreUpdatePropertyAction(ref EntityProperties entprop);
  455. public event PreUpdatePropertyAction OnPreUpdateProperty;
  456. protected void TriggerPreUpdatePropertyAction(ref EntityProperties entprop)
  457. {
  458. PreUpdatePropertyAction actions = OnPreUpdateProperty;
  459. if (actions != null)
  460. actions(ref entprop);
  461. }
  462. #endregion // Per Simulation Step actions
  463. // High performance detailed logging routine used by the physical objects.
  464. protected void DetailLog(string msg, params Object[] args)
  465. {
  466. if (PhysScene.PhysicsLogging.Enabled)
  467. PhysScene.DetailLog(msg, args);
  468. }
  469. }
  470. }