diff options
author | Teravus Ovares | 2007-12-19 22:42:06 +0000 |
---|---|---|
committer | Teravus Ovares | 2007-12-19 22:42:06 +0000 |
commit | 27e028752600921deac57e281f1df6d8c7310c5d (patch) | |
tree | f94a99a6e7ad4d4325d336561f0e6365ec44f6d3 /OpenSim/Region/Physics | |
parent | Thank you very much, CharlieO for: (diff) | |
download | opensim-SC-27e028752600921deac57e281f1df6d8c7310c5d.zip opensim-SC-27e028752600921deac57e281f1df6d8c7310c5d.tar.gz opensim-SC-27e028752600921deac57e281f1df6d8c7310c5d.tar.bz2 opensim-SC-27e028752600921deac57e281f1df6d8c7310c5d.tar.xz |
* Re-did the mass calculations in ODE for Prim
* Exposed the mass as a PhysicsActor read only property (so scripts can get at it - hint hint -)
* Hollow and Path Cuts affect the prim mass (all Hollow Types are supported in this calculation (sphere,square,triangle))
* Prim no longer sink into the ground.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 19 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | 46 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 25 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 28 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 124 | ||||
-rw-r--r-- | OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 36 | ||||
-rw-r--r-- | OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 42 |
7 files changed, 303 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index 545f461..5ac651f 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | |||
@@ -258,7 +258,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
258 | 258 | ||
259 | public override PhysicsVector Size | 259 | public override PhysicsVector Size |
260 | { | 260 | { |
261 | get { return new PhysicsVector(0, 0, 0); } | 261 | get { return PhysicsVector.Zero; } |
262 | set { } | 262 | set { } |
263 | } | 263 | } |
264 | 264 | ||
@@ -269,7 +269,22 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin | |||
269 | return; | 269 | return; |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | public override float Mass | |
273 | { | ||
274 | get { return 0f; } | ||
275 | } | ||
276 | public override PhysicsVector Force | ||
277 | { | ||
278 | get { return PhysicsVector.Zero; } | ||
279 | } | ||
280 | public override PhysicsVector CenterOfMass | ||
281 | { | ||
282 | get { return PhysicsVector.Zero; } | ||
283 | } | ||
284 | public override PhysicsVector GeometricCenter | ||
285 | { | ||
286 | get { return PhysicsVector.Zero; } | ||
287 | } | ||
273 | public override PhysicsVector Velocity | 288 | public override PhysicsVector Velocity |
274 | { | 289 | { |
275 | get { return _velocity; } | 290 | get { return _velocity; } |
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 1760e50..5602301 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | |||
@@ -511,10 +511,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
511 | GC.Collect(); | 511 | GC.Collect(); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | |||
514 | public override void AddPhysicsActorTaint(PhysicsActor prim) | 515 | public override void AddPhysicsActorTaint(PhysicsActor prim) |
515 | { | 516 | { |
516 | 517 | ||
517 | } | 518 | } |
519 | |||
518 | public override float Simulate(float timeStep) | 520 | public override float Simulate(float timeStep) |
519 | { | 521 | { |
520 | float fps = 0; | 522 | float fps = 0; |
@@ -735,11 +737,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
735 | } | 737 | } |
736 | } | 738 | } |
737 | } | 739 | } |
740 | |||
738 | public override PhysicsVector RotationalVelocity | 741 | public override PhysicsVector RotationalVelocity |
739 | { | 742 | { |
740 | get { return m_rotationalVelocity; } | 743 | get { return m_rotationalVelocity; } |
741 | set { m_rotationalVelocity = value; } | 744 | set { m_rotationalVelocity = value; } |
742 | } | 745 | } |
746 | |||
743 | public override PhysicsVector Velocity | 747 | public override PhysicsVector Velocity |
744 | { | 748 | { |
745 | get { return _velocity; } | 749 | get { return _velocity; } |
@@ -760,12 +764,28 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
760 | } | 764 | } |
761 | } | 765 | } |
762 | } | 766 | } |
767 | |||
763 | public override PhysicsVector Size | 768 | public override PhysicsVector Size |
764 | { | 769 | { |
765 | get { return _size; } | 770 | get { return _size; } |
766 | set { lock (BulletXScene.BulletXLock) { _size = value; } } | 771 | set { lock (BulletXScene.BulletXLock) { _size = value; } } |
767 | } | 772 | } |
768 | 773 | ||
774 | public override PhysicsVector Force | ||
775 | { | ||
776 | get { return PhysicsVector.Zero; } | ||
777 | } | ||
778 | |||
779 | public override PhysicsVector CenterOfMass | ||
780 | { | ||
781 | get { return PhysicsVector.Zero; } | ||
782 | } | ||
783 | |||
784 | public override PhysicsVector GeometricCenter | ||
785 | { | ||
786 | get { return PhysicsVector.Zero; } | ||
787 | } | ||
788 | |||
769 | public override PrimitiveBaseShape Shape | 789 | public override PrimitiveBaseShape Shape |
770 | { | 790 | { |
771 | set | 791 | set |
@@ -773,15 +793,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
773 | return; | 793 | return; |
774 | } | 794 | } |
775 | } | 795 | } |
796 | |||
776 | public override bool SetAlwaysRun | 797 | public override bool SetAlwaysRun |
777 | { | 798 | { |
778 | get { return false; } | 799 | get { return false; } |
779 | set { return; } | 800 | set { return; } |
780 | } | 801 | } |
802 | |||
781 | public override PhysicsVector Acceleration | 803 | public override PhysicsVector Acceleration |
782 | { | 804 | { |
783 | get { return _acceleration; } | 805 | get { return _acceleration; } |
784 | } | 806 | } |
807 | |||
785 | public override AxiomQuaternion Orientation | 808 | public override AxiomQuaternion Orientation |
786 | { | 809 | { |
787 | get { return _orientation; } | 810 | get { return _orientation; } |
@@ -794,10 +817,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
794 | } | 817 | } |
795 | } | 818 | } |
796 | } | 819 | } |
797 | public virtual float Mass | 820 | |
821 | public override float Mass | ||
798 | { | 822 | { |
799 | get { return 0; } | 823 | get { return ActorMass; } |
824 | } | ||
825 | |||
826 | public virtual float ActorMass | ||
827 | { | ||
828 | get { return 0; } | ||
800 | } | 829 | } |
830 | |||
801 | public override int PhysicsActorType | 831 | public override int PhysicsActorType |
802 | { | 832 | { |
803 | get { return (int) m_PhysicsActorType; } | 833 | get { return (int) m_PhysicsActorType; } |
@@ -808,6 +838,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
808 | { | 838 | { |
809 | get { return rigidBody; } | 839 | get { return rigidBody; } |
810 | } | 840 | } |
841 | |||
811 | public Vector3 RigidBodyPosition | 842 | public Vector3 RigidBodyPosition |
812 | { | 843 | { |
813 | get { return this.rigidBody.CenterOfMassPosition; } | 844 | get { return this.rigidBody.CenterOfMassPosition; } |
@@ -829,21 +860,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
829 | get { return false; } | 860 | get { return false; } |
830 | set { return; } | 861 | set { return; } |
831 | } | 862 | } |
863 | |||
832 | public override bool IsColliding | 864 | public override bool IsColliding |
833 | { | 865 | { |
834 | get { return iscolliding; } | 866 | get { return iscolliding; } |
835 | set { iscolliding = value; } | 867 | set { iscolliding = value; } |
836 | } | 868 | } |
869 | |||
837 | public override bool CollidingGround | 870 | public override bool CollidingGround |
838 | { | 871 | { |
839 | get { return false; } | 872 | get { return false; } |
840 | set { return; } | 873 | set { return; } |
841 | } | 874 | } |
875 | |||
842 | public override bool CollidingObj | 876 | public override bool CollidingObj |
843 | { | 877 | { |
844 | get { return false; } | 878 | get { return false; } |
845 | set { return; } | 879 | set { return; } |
846 | } | 880 | } |
881 | |||
847 | public virtual void SetAcceleration(PhysicsVector accel) | 882 | public virtual void SetAcceleration(PhysicsVector accel) |
848 | { | 883 | { |
849 | lock (BulletXScene.BulletXLock) | 884 | lock (BulletXScene.BulletXLock) |
@@ -851,6 +886,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
851 | _acceleration = accel; | 886 | _acceleration = accel; |
852 | } | 887 | } |
853 | } | 888 | } |
889 | |||
854 | public override bool Kinematic | 890 | public override bool Kinematic |
855 | { | 891 | { |
856 | get | 892 | get |
@@ -862,16 +898,20 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
862 | 898 | ||
863 | } | 899 | } |
864 | } | 900 | } |
901 | |||
865 | public override void AddForce(PhysicsVector force) | 902 | public override void AddForce(PhysicsVector force) |
866 | { | 903 | { |
867 | 904 | ||
868 | } | 905 | } |
906 | |||
869 | public override void SetMomentum(PhysicsVector momentum) | 907 | public override void SetMomentum(PhysicsVector momentum) |
870 | { | 908 | { |
871 | } | 909 | } |
910 | |||
872 | internal virtual void ValidateHeight(float heighmapPositionValue) | 911 | internal virtual void ValidateHeight(float heighmapPositionValue) |
873 | { | 912 | { |
874 | } | 913 | } |
914 | |||
875 | internal virtual void UpdateKinetics() | 915 | internal virtual void UpdateKinetics() |
876 | { | 916 | { |
877 | } | 917 | } |
@@ -1176,7 +1216,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin | |||
1176 | get { return base.Orientation; } | 1216 | get { return base.Orientation; } |
1177 | set { base.Orientation = value; } | 1217 | set { base.Orientation = value; } |
1178 | } | 1218 | } |
1179 | public override float Mass | 1219 | public override float ActorMass |
1180 | { | 1220 | { |
1181 | get | 1221 | get |
1182 | { | 1222 | { |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 7e8d160..5894ab0 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -157,6 +157,14 @@ namespace OpenSim.Region.Physics.Manager | |||
157 | 157 | ||
158 | public abstract PhysicsVector Position { get; set; } | 158 | public abstract PhysicsVector Position { get; set; } |
159 | 159 | ||
160 | public abstract float Mass { get; } | ||
161 | |||
162 | public abstract PhysicsVector Force { get;} | ||
163 | |||
164 | public abstract PhysicsVector GeometricCenter { get; } | ||
165 | |||
166 | public abstract PhysicsVector CenterOfMass { get; } | ||
167 | |||
160 | public abstract PhysicsVector Velocity { get; set; } | 168 | public abstract PhysicsVector Velocity { get; set; } |
161 | 169 | ||
162 | public abstract PhysicsVector Acceleration { get; } | 170 | public abstract PhysicsVector Acceleration { get; } |
@@ -210,7 +218,22 @@ namespace OpenSim.Region.Physics.Manager | |||
210 | get { return PhysicsVector.Zero; } | 218 | get { return PhysicsVector.Zero; } |
211 | set { return; } | 219 | set { return; } |
212 | } | 220 | } |
213 | 221 | public override float Mass | |
222 | { | ||
223 | get { return 0f; } | ||
224 | } | ||
225 | public override PhysicsVector Force | ||
226 | { | ||
227 | get { return PhysicsVector.Zero; } | ||
228 | } | ||
229 | public override PhysicsVector CenterOfMass | ||
230 | { | ||
231 | get { return PhysicsVector.Zero; } | ||
232 | } | ||
233 | public override PhysicsVector GeometricCenter | ||
234 | { | ||
235 | get { return PhysicsVector.Zero; } | ||
236 | } | ||
214 | public override PrimitiveBaseShape Shape | 237 | public override PrimitiveBaseShape Shape |
215 | { | 238 | { |
216 | set | 239 | set |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 6f22ecf..04bf9a0 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
46 | private PhysicsVector _target_velocity; | 46 | private PhysicsVector _target_velocity; |
47 | private PhysicsVector _acceleration; | 47 | private PhysicsVector _acceleration; |
48 | private PhysicsVector m_rotationalVelocity; | 48 | private PhysicsVector m_rotationalVelocity; |
49 | private float m_density = 50f; | ||
49 | private bool m_pidControllerActive = true; | 50 | private bool m_pidControllerActive = true; |
50 | private static float PID_D = 3020.0f; | 51 | private static float PID_D = 3020.0f; |
51 | private static float PID_P = 7000.0f; | 52 | private static float PID_P = 7000.0f; |
@@ -93,7 +94,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
93 | { | 94 | { |
94 | 95 | ||
95 | Shell = d.CreateCapsule(parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); | 96 | Shell = d.CreateCapsule(parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); |
96 | d.MassSetCapsule(out ShellMass, 50.0f, 3, 0.4f, 1.0f); | 97 | d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); |
97 | Body = d.BodyCreate(parent_scene.world); | 98 | Body = d.BodyCreate(parent_scene.world); |
98 | d.BodySetMass(Body, ref ShellMass); | 99 | d.BodySetMass(Body, ref ShellMass); |
99 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); | 100 | d.BodySetPosition(Body, pos.X, pos.Y, pos.Z); |
@@ -273,7 +274,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
273 | d.GeomDestroy(Shell); | 274 | d.GeomDestroy(Shell); |
274 | //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH)); | 275 | //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH)); |
275 | Shell = d.CreateCapsule(_parent_scene.space, capsuleradius, CAPSULE_LENGTH); | 276 | Shell = d.CreateCapsule(_parent_scene.space, capsuleradius, CAPSULE_LENGTH); |
276 | d.MassSetCapsule(out ShellMass, 50.0f, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); | 277 | d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); |
277 | Body = d.BodyCreate(_parent_scene.world); | 278 | Body = d.BodyCreate(_parent_scene.world); |
278 | d.BodySetMass(Body, ref ShellMass); | 279 | d.BodySetMass(Body, ref ShellMass); |
279 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); | 280 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); |
@@ -283,6 +284,29 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
283 | _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; | 284 | _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; |
284 | } | 285 | } |
285 | } | 286 | } |
287 | public override float Mass | ||
288 | { | ||
289 | get { | ||
290 | |||
291 | float AVvolume = (float)(Math.PI * Math.Pow(CAPSULE_RADIUS, 2) * CAPSULE_LENGTH); | ||
292 | return m_density * AVvolume; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | public override PhysicsVector Force | ||
297 | { | ||
298 | get { return new PhysicsVector(_target_velocity.X,_target_velocity.Y,_target_velocity.Z); } | ||
299 | } | ||
300 | |||
301 | public override PhysicsVector CenterOfMass | ||
302 | { | ||
303 | get { return PhysicsVector.Zero; } | ||
304 | } | ||
305 | |||
306 | public override PhysicsVector GeometricCenter | ||
307 | { | ||
308 | get { return PhysicsVector.Zero; } | ||
309 | } | ||
286 | 310 | ||
287 | public override PrimitiveBaseShape Shape | 311 | public override PrimitiveBaseShape Shape |
288 | { | 312 | { |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 2ec8131..26cb24b 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -65,6 +65,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
65 | private bool m_throttleUpdates = false; | 65 | private bool m_throttleUpdates = false; |
66 | private int throttleCounter = 0; | 66 | private int throttleCounter = 0; |
67 | public bool outofBounds = false; | 67 | public bool outofBounds = false; |
68 | private float m_density = 0f; | ||
69 | |||
70 | |||
68 | 71 | ||
69 | public bool _zeroFlag = false; | 72 | public bool _zeroFlag = false; |
70 | private bool m_lastUpdateSent = false; | 73 | private bool m_lastUpdateSent = false; |
@@ -73,7 +76,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
73 | private String m_primName; | 76 | private String m_primName; |
74 | private PhysicsVector _target_velocity; | 77 | private PhysicsVector _target_velocity; |
75 | public d.Mass pMass; | 78 | public d.Mass pMass; |
76 | private const float MassMultiplier = 150f; // Ref: Water: 1000kg.. this iset to 500 | 79 | private const float MassMultiplier = 150f; |
77 | private int debugcounter = 0; | 80 | private int debugcounter = 0; |
78 | 81 | ||
79 | public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size, | 82 | public OdePrim(String primName, OdeScene parent_scene, IntPtr targetSpace, PhysicsVector pos, PhysicsVector size, |
@@ -182,15 +185,104 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
182 | 185 | ||
183 | _parent_scene.addActivePrim(this); | 186 | _parent_scene.addActivePrim(this); |
184 | } | 187 | } |
185 | public void setMass() | 188 | private float CalculateMass() |
186 | { | 189 | { |
187 | //Sets Mass based on member MassMultiplier. | 190 | float volume = 0; |
191 | |||
192 | // No material is passed to the physics engines yet.. soo.. | ||
193 | float density = 2.7f; // Aluminum g/cm3; | ||
194 | |||
195 | float returnMass = 0; | ||
196 | |||
197 | switch (_pbs.ProfileShape) | ||
198 | { | ||
199 | case ProfileShape.Square: | ||
200 | // Profile Volume | ||
201 | |||
202 | volume = _size.X * _size.Y * _size.Z; | ||
203 | |||
204 | // If the user has 'hollowed out' | ||
205 | if (((float)_pbs.ProfileHollow / 50000f) > 0.0) | ||
206 | { | ||
207 | float hollowAmount = (float)_pbs.ProfileHollow / 50000f; | ||
208 | //break; | ||
209 | float hollowVolume = 0; | ||
210 | switch (_pbs.HollowShape) | ||
211 | { | ||
212 | case HollowShape.Square: | ||
213 | case HollowShape.Same: | ||
214 | // Cube Hollow | ||
215 | float hollowsizex = _size.X * hollowAmount; | ||
216 | float hollowsizey = _size.Y * hollowAmount; | ||
217 | float hollowsizez = _size.Z * hollowAmount; | ||
218 | hollowVolume = hollowsizex * hollowsizey * hollowsizez; | ||
219 | break; | ||
220 | |||
221 | case HollowShape.Circle: | ||
222 | // Hollow shape is a perfect cyllinder in respect to the cube's scale | ||
223 | float hRadius = _size.X / 2; | ||
224 | float hLength = _size.Z; | ||
225 | |||
226 | // pi * r2 * h | ||
227 | hollowVolume = ((float)(Math.PI * Math.Pow(hRadius, 2) * hLength) * hollowAmount); | ||
228 | break; | ||
229 | |||
230 | case HollowShape.Triangle: | ||
231 | float aLength = _size.Y; // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y | ||
232 | // 1/2 abh | ||
233 | hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount); | ||
234 | break; | ||
235 | |||
236 | default: | ||
237 | hollowVolume = 0; | ||
238 | break; | ||
239 | } | ||
240 | volume = volume - hollowVolume; | ||
241 | |||
242 | } | ||
243 | |||
244 | break; | ||
245 | |||
246 | default: | ||
247 | volume = _size.X * _size.Y * _size.Z; | ||
248 | break; | ||
249 | } | ||
250 | |||
251 | // Calculate Path cut effect on volume | ||
252 | // Not exact, in the triangle hollow example | ||
253 | // They should ever be less then zero.. | ||
254 | // we'll ignore it if it's less then zero | ||
255 | float PathCutEndAmount = _pbs.ProfileEnd; | ||
256 | float PathCutStartAmount = _pbs.ProfileBegin; | ||
257 | if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f) | ||
258 | { | ||
259 | |||
260 | float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount) / 50000f); | ||
261 | |||
262 | if (pathCutAmount >= 0.99f) | ||
263 | pathCutAmount=0.99f; | ||
264 | |||
265 | volume = volume - (volume * pathCutAmount); | ||
266 | } | ||
267 | |||
268 | returnMass = density * volume; | ||
269 | |||
270 | return returnMass; | ||
271 | } | ||
272 | |||
273 | public void setMass() | ||
274 | { | ||
188 | if (Body != (IntPtr)0) | 275 | if (Body != (IntPtr)0) |
189 | { | 276 | { |
190 | d.MassSetBox(out pMass, (_size.X * _size.Y * _size.Z * MassMultiplier), _size.X, _size.Y, _size.Z); | 277 | //if (_pbs.ProfileShape = ProfileShape.Square) { |
278 | |||
279 | d.MassSetBoxTotal(out pMass, CalculateMass(), _size.X, _size.Y, _size.Z); | ||
191 | d.BodySetMass(Body, ref pMass); | 280 | d.BodySetMass(Body, ref pMass); |
192 | } | 281 | } |
193 | } | 282 | } |
283 | |||
284 | |||
285 | |||
194 | public void disableBody() | 286 | public void disableBody() |
195 | { | 287 | { |
196 | //this kills the body so things like 'mesh' can re-create it. | 288 | //this kills the body so things like 'mesh' can re-create it. |
@@ -212,7 +304,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
212 | int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage | 304 | int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage |
213 | int VertexCount = vertexList.GetLength(0) / 3; | 305 | int VertexCount = vertexList.GetLength(0) / 3; |
214 | int IndexCount = indexList.GetLength(0); | 306 | int IndexCount = indexList.GetLength(0); |
215 | 307 | ||
216 | _triMeshData = d.GeomTriMeshDataCreate(); | 308 | _triMeshData = d.GeomTriMeshDataCreate(); |
217 | 309 | ||
218 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3 * sizeof(float), VertexCount, indexList, IndexCount, | 310 | d.GeomTriMeshDataBuildSimple(_triMeshData, vertexList, 3 * sizeof(float), VertexCount, indexList, IndexCount, |
@@ -220,7 +312,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
220 | d.GeomTriMeshDataPreprocess(_triMeshData); | 312 | d.GeomTriMeshDataPreprocess(_triMeshData); |
221 | 313 | ||
222 | prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null); | 314 | prim_geom = d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null); |
223 | 315 | ||
224 | if (IsPhysical && Body == (IntPtr)0) | 316 | if (IsPhysical && Body == (IntPtr)0) |
225 | { | 317 | { |
226 | // Recreate the body | 318 | // Recreate the body |
@@ -502,6 +594,26 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
502 | } | 594 | } |
503 | } | 595 | } |
504 | 596 | ||
597 | public override float Mass | ||
598 | { | ||
599 | get { return CalculateMass(); } | ||
600 | } | ||
601 | |||
602 | public override PhysicsVector Force | ||
603 | { | ||
604 | get { return PhysicsVector.Zero; } | ||
605 | } | ||
606 | |||
607 | public override PhysicsVector CenterOfMass | ||
608 | { | ||
609 | get { return PhysicsVector.Zero; } | ||
610 | } | ||
611 | |||
612 | public override PhysicsVector GeometricCenter | ||
613 | { | ||
614 | get { return PhysicsVector.Zero; } | ||
615 | } | ||
616 | |||
505 | public override PrimitiveBaseShape Shape | 617 | public override PrimitiveBaseShape Shape |
506 | { | 618 | { |
507 | set | 619 | set |
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index a565598..26310f9 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | |||
@@ -383,6 +383,22 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
383 | get { return new PhysicsVector(0.5f, 0.5f, 1.0f); } | 383 | get { return new PhysicsVector(0.5f, 0.5f, 1.0f); } |
384 | set { } | 384 | set { } |
385 | } | 385 | } |
386 | public override float Mass | ||
387 | { | ||
388 | get { return 0f; } | ||
389 | } | ||
390 | public override PhysicsVector Force | ||
391 | { | ||
392 | get { return PhysicsVector.Zero; } | ||
393 | } | ||
394 | public override PhysicsVector CenterOfMass | ||
395 | { | ||
396 | get { return PhysicsVector.Zero; } | ||
397 | } | ||
398 | public override PhysicsVector GeometricCenter | ||
399 | { | ||
400 | get { return PhysicsVector.Zero; } | ||
401 | } | ||
386 | 402 | ||
387 | public override PrimitiveBaseShape Shape | 403 | public override PrimitiveBaseShape Shape |
388 | { | 404 | { |
@@ -492,6 +508,26 @@ namespace OpenSim.Region.Physics.POSPlugin | |||
492 | set { _size = value; } | 508 | set { _size = value; } |
493 | } | 509 | } |
494 | 510 | ||
511 | public override float Mass | ||
512 | { | ||
513 | get { return 0f; } | ||
514 | } | ||
515 | |||
516 | public override PhysicsVector Force | ||
517 | { | ||
518 | get { return PhysicsVector.Zero; } | ||
519 | } | ||
520 | |||
521 | public override PhysicsVector CenterOfMass | ||
522 | { | ||
523 | get { return PhysicsVector.Zero; } | ||
524 | } | ||
525 | |||
526 | public override PhysicsVector GeometricCenter | ||
527 | { | ||
528 | get { return PhysicsVector.Zero; } | ||
529 | } | ||
530 | |||
495 | public override PrimitiveBaseShape Shape | 531 | public override PrimitiveBaseShape Shape |
496 | { | 532 | { |
497 | set | 533 | set |
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index bc28626..8525e75 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | |||
@@ -270,10 +270,25 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
270 | 270 | ||
271 | public override PhysicsVector Size | 271 | public override PhysicsVector Size |
272 | { | 272 | { |
273 | get { return new PhysicsVector(0, 0, 0); } | 273 | get { return PhysicsVector.Zero; } |
274 | set { } | 274 | set { } |
275 | } | 275 | } |
276 | 276 | public override float Mass | |
277 | { | ||
278 | get { return 0f; } | ||
279 | } | ||
280 | public override PhysicsVector Force | ||
281 | { | ||
282 | get { return PhysicsVector.Zero; } | ||
283 | } | ||
284 | public override PhysicsVector CenterOfMass | ||
285 | { | ||
286 | get { return PhysicsVector.Zero; } | ||
287 | } | ||
288 | public override PhysicsVector GeometricCenter | ||
289 | { | ||
290 | get { return PhysicsVector.Zero; } | ||
291 | } | ||
277 | public override PhysicsVector Velocity | 292 | public override PhysicsVector Velocity |
278 | { | 293 | { |
279 | get { return _velocity; } | 294 | get { return _velocity; } |
@@ -507,8 +522,29 @@ namespace OpenSim.Region.Physics.PhysXPlugin | |||
507 | 522 | ||
508 | public override PhysicsVector Size | 523 | public override PhysicsVector Size |
509 | { | 524 | { |
510 | get { return new PhysicsVector(0, 0, 0); } | 525 | get { return PhysicsVector.Zero; } |
511 | set { } | 526 | set { } |
512 | } | 527 | } |
528 | |||
529 | public override float Mass | ||
530 | { | ||
531 | get { return 0f; } | ||
532 | } | ||
533 | |||
534 | public override PhysicsVector Force | ||
535 | { | ||
536 | get { return PhysicsVector.Zero; } | ||
537 | } | ||
538 | |||
539 | public override PhysicsVector CenterOfMass | ||
540 | { | ||
541 | get { return PhysicsVector.Zero; } | ||
542 | } | ||
543 | |||
544 | public override PhysicsVector GeometricCenter | ||
545 | { | ||
546 | get { return PhysicsVector.Zero; } | ||
547 | } | ||
548 | |||
513 | } | 549 | } |
514 | } | 550 | } |