aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2007-12-24 05:48:16 +0000
committerTeravus Ovares2007-12-24 05:48:16 +0000
commitde43f7e8584d84c34678bc35f8b915eeb0a91795 (patch)
treef7b282e79d262a825ae6d3035ead9c41c663e2c8 /OpenSim
parentLog message tweaking (diff)
downloadopensim-SC_OLD-de43f7e8584d84c34678bc35f8b915eeb0a91795.zip
opensim-SC_OLD-de43f7e8584d84c34678bc35f8b915eeb0a91795.tar.gz
opensim-SC_OLD-de43f7e8584d84c34678bc35f8b915eeb0a91795.tar.bz2
opensim-SC_OLD-de43f7e8584d84c34678bc35f8b915eeb0a91795.tar.xz
* ODE: now using the 10.00000638 density value on prim.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs42
1 files changed, 30 insertions, 12 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 26cb24b..32a9fc7 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -65,9 +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; 68 private float m_density = 10.000006836f;// Aluminum g/cm3;
69 69
70 70
71 71
72 public bool _zeroFlag = false; 72 public bool _zeroFlag = false;
73 private bool m_lastUpdateSent = false; 73 private bool m_lastUpdateSent = false;
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Physics.OdePlugin
76 private String m_primName; 76 private String m_primName;
77 private PhysicsVector _target_velocity; 77 private PhysicsVector _target_velocity;
78 public d.Mass pMass; 78 public d.Mass pMass;
79 private const float MassMultiplier = 150f; 79
80 private int debugcounter = 0; 80 private int debugcounter = 0;
81 81
82 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,
@@ -190,7 +190,8 @@ namespace OpenSim.Region.Physics.OdePlugin
190 float volume = 0; 190 float volume = 0;
191 191
192 // No material is passed to the physics engines yet.. soo.. 192 // No material is passed to the physics engines yet.. soo..
193 float density = 2.7f; // Aluminum g/cm3; 193 // we're using the m_density constant in the class definition
194
194 195
195 float returnMass = 0; 196 float returnMass = 0;
196 197
@@ -202,16 +203,20 @@ namespace OpenSim.Region.Physics.OdePlugin
202 volume = _size.X * _size.Y * _size.Z; 203 volume = _size.X * _size.Y * _size.Z;
203 204
204 // If the user has 'hollowed out' 205 // If the user has 'hollowed out'
206 // ProfileHollow is one of those 0 to 50000 values :P
207 // we like percentages better.. so turning into a percentage
208
205 if (((float)_pbs.ProfileHollow / 50000f) > 0.0) 209 if (((float)_pbs.ProfileHollow / 50000f) > 0.0)
206 { 210 {
207 float hollowAmount = (float)_pbs.ProfileHollow / 50000f; 211 float hollowAmount = (float)_pbs.ProfileHollow / 50000f;
208 //break; 212
213 // calculate the hollow volume by it's shape compared to the prim shape
209 float hollowVolume = 0; 214 float hollowVolume = 0;
210 switch (_pbs.HollowShape) 215 switch (_pbs.HollowShape)
211 { 216 {
212 case HollowShape.Square: 217 case HollowShape.Square:
213 case HollowShape.Same: 218 case HollowShape.Same:
214 // Cube Hollow 219 // Cube Hollow volume calculation
215 float hollowsizex = _size.X * hollowAmount; 220 float hollowsizex = _size.X * hollowAmount;
216 float hollowsizey = _size.Y * hollowAmount; 221 float hollowsizey = _size.Y * hollowAmount;
217 float hollowsizez = _size.Z * hollowAmount; 222 float hollowsizez = _size.Z * hollowAmount;
@@ -220,6 +225,7 @@ namespace OpenSim.Region.Physics.OdePlugin
220 225
221 case HollowShape.Circle: 226 case HollowShape.Circle:
222 // Hollow shape is a perfect cyllinder in respect to the cube's scale 227 // Hollow shape is a perfect cyllinder in respect to the cube's scale
228 // Cyllinder hollow volume calculation
223 float hRadius = _size.X / 2; 229 float hRadius = _size.X / 2;
224 float hLength = _size.Z; 230 float hLength = _size.Z;
225 231
@@ -228,7 +234,10 @@ namespace OpenSim.Region.Physics.OdePlugin
228 break; 234 break;
229 235
230 case HollowShape.Triangle: 236 case HollowShape.Triangle:
231 float aLength = _size.Y; // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y 237 // Equilateral Triangular Prism volume hollow calculation
238 // Triangle is an Equilateral Triangular Prism with aLength = to _size.Y
239
240 float aLength = _size.Y;
232 // 1/2 abh 241 // 1/2 abh
233 hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount); 242 hollowVolume = (float)((0.5 * aLength * _size.X * _size.Z) * hollowAmount);
234 break; 243 break;
@@ -244,14 +253,22 @@ namespace OpenSim.Region.Physics.OdePlugin
244 break; 253 break;
245 254
246 default: 255 default:
256 // we don't have all of the volume formulas yet so
257 // use the common volume formula for all
247 volume = _size.X * _size.Y * _size.Z; 258 volume = _size.X * _size.Y * _size.Z;
248 break; 259 break;
249 } 260 }
250 261
251 // Calculate Path cut effect on volume 262 // Calculate Path cut effect on volume
252 // Not exact, in the triangle hollow example 263 // Not exact, in the triangle hollow example
253 // They should ever be less then zero.. 264 // They should never be zero or less then zero..
254 // we'll ignore it if it's less then zero 265 // we'll ignore it if it's less then zero
266
267 // ProfileEnd and ProfileBegin are values
268 // from 0 to 50000
269
270 // Turning them back into percentages so that I can cut that percentage off the volume
271
255 float PathCutEndAmount = _pbs.ProfileEnd; 272 float PathCutEndAmount = _pbs.ProfileEnd;
256 float PathCutStartAmount = _pbs.ProfileBegin; 273 float PathCutStartAmount = _pbs.ProfileBegin;
257 if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f) 274 if (((PathCutStartAmount + PathCutEndAmount)/50000f) > 0.0f)
@@ -259,13 +276,16 @@ namespace OpenSim.Region.Physics.OdePlugin
259 276
260 float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount) / 50000f); 277 float pathCutAmount = ((PathCutStartAmount + PathCutEndAmount) / 50000f);
261 278
279 // Check the return amount for sanity
262 if (pathCutAmount >= 0.99f) 280 if (pathCutAmount >= 0.99f)
263 pathCutAmount=0.99f; 281 pathCutAmount=0.99f;
264 282
265 volume = volume - (volume * pathCutAmount); 283 volume = volume - (volume * pathCutAmount);
266 } 284 }
267 285
268 returnMass = density * volume; 286 // Mass = density * volume
287
288 returnMass = m_density * volume;
269 289
270 return returnMass; 290 return returnMass;
271 } 291 }
@@ -274,8 +294,6 @@ namespace OpenSim.Region.Physics.OdePlugin
274 { 294 {
275 if (Body != (IntPtr)0) 295 if (Body != (IntPtr)0)
276 { 296 {
277 //if (_pbs.ProfileShape = ProfileShape.Square) {
278
279 d.MassSetBoxTotal(out pMass, CalculateMass(), _size.X, _size.Y, _size.Z); 297 d.MassSetBoxTotal(out pMass, CalculateMass(), _size.X, _size.Y, _size.Z);
280 d.BodySetMass(Body, ref pMass); 298 d.BodySetMass(Body, ref pMass);
281 } 299 }