aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs81
1 files changed, 61 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 50ba343..02d06b4 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -204,6 +204,10 @@ public sealed class BSPrim : BSPhysObject
204 } 204 }
205 } 205 }
206 } 206 }
207 public override bool IsSelected
208 {
209 get { return _isSelected; }
210 }
207 public override void CrossingFailure() { return; } 211 public override void CrossingFailure() { return; }
208 212
209 // link me to the specified parent 213 // link me to the specified parent
@@ -1153,33 +1157,70 @@ public sealed class BSPrim : BSPhysObject
1153 // This added force will only last the next simulation tick. 1157 // This added force will only last the next simulation tick.
1154 public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { 1158 public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
1155 // for an object, doesn't matter if force is a pushforce or not 1159 // for an object, doesn't matter if force is a pushforce or not
1156 if (!IsStatic && force.IsFinite()) 1160 if (!IsStatic)
1157 { 1161 {
1158 float magnitude = force.Length(); 1162 if (force.IsFinite())
1159 if (magnitude > BSParam.MaxAddForceMagnitude)
1160 { 1163 {
1161 // Force has a limit 1164 float magnitude = force.Length();
1162 force = force / magnitude * BSParam.MaxAddForceMagnitude; 1165 if (magnitude > BSParam.MaxAddForceMagnitude)
1163 } 1166 {
1167 // Force has a limit
1168 force = force / magnitude * BSParam.MaxAddForceMagnitude;
1169 }
1164 1170
1165 OMV.Vector3 addForce = force; 1171 OMV.Vector3 addForce = force;
1166 // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); 1172 // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce);
1167 1173
1168 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() 1174 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate()
1169 {
1170 // Bullet adds this central force to the total force for this tick
1171 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
1172 if (PhysBody.HasPhysicalBody)
1173 { 1175 {
1174 PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce); 1176 // Bullet adds this central force to the total force for this tick
1175 ActivateIfPhysical(false); 1177 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
1176 } 1178 if (PhysBody.HasPhysicalBody)
1177 }); 1179 {
1180 PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce);
1181 ActivateIfPhysical(false);
1182 }
1183 });
1184 }
1185 else
1186 {
1187 m_log.WarnFormat("{0}: AddForce: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID);
1188 return;
1189 }
1178 } 1190 }
1179 else 1191 }
1192
1193 public void AddForceImpulse(OMV.Vector3 impulse, bool pushforce, bool inTaintTime) {
1194 // for an object, doesn't matter if force is a pushforce or not
1195 if (!IsStatic)
1180 { 1196 {
1181 m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); 1197 if (impulse.IsFinite())
1182 return; 1198 {
1199 float magnitude = impulse.Length();
1200 if (magnitude > BSParam.MaxAddForceMagnitude)
1201 {
1202 // Force has a limit
1203 impulse = impulse / magnitude * BSParam.MaxAddForceMagnitude;
1204 }
1205
1206 // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse);
1207 OMV.Vector3 addImpulse = impulse;
1208 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate()
1209 {
1210 // Bullet adds this impulse immediately to the velocity
1211 DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse);
1212 if (PhysBody.HasPhysicalBody)
1213 {
1214 PhysicsScene.PE.ApplyCentralImpulse(PhysBody, addImpulse);
1215 ActivateIfPhysical(false);
1216 }
1217 });
1218 }
1219 else
1220 {
1221 m_log.WarnFormat("{0}: AddForceImpulse: Got a NaN impulse applied to a prim. LocalID={1}", LogHeader, LocalID);
1222 return;
1223 }
1183 } 1224 }
1184 } 1225 }
1185 1226