aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-07-17 10:25:13 +0200
committerMelanie2012-07-17 10:25:13 +0200
commit0797736fba7f87f7d9bd9d514bb318e1c7844124 (patch)
treede4ba57287560a22d7c2d03a37ad561a965f5637 /OpenSim
parentReplace PollServiceRequestManager with older version, add extra logging to (diff)
parentfix PollServiceRequestManager (diff)
downloadopensim-SC_OLD-0797736fba7f87f7d9bd9d514bb318e1c7844124.zip
opensim-SC_OLD-0797736fba7f87f7d9bd9d514bb318e1c7844124.tar.gz
opensim-SC_OLD-0797736fba7f87f7d9bd9d514bb318e1c7844124.tar.bz2
opensim-SC_OLD-0797736fba7f87f7d9bd9d514bb318e1c7844124.tar.xz
Merge branch 'ubitwork' into avination
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs57
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs47
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SimStatsReporter.cs67
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs143
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs16
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs14
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs99
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs6
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs394
11 files changed, 393 insertions, 457 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index af40185..a3bd330 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -288,9 +288,8 @@ namespace OpenSim.Framework.Servers.HttpServer
288 { 288 {
289 foreach (PollServiceHttpRequest req in m_retryRequests) 289 foreach (PollServiceHttpRequest req in m_retryRequests)
290 { 290 {
291 m_server.DoHTTPGruntWork( 291 DoHTTPGruntWork(m_server,req,
292 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), 292 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
293 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
294 } 293 }
295 } 294 }
296 catch 295 catch
@@ -311,9 +310,8 @@ namespace OpenSim.Framework.Servers.HttpServer
311 try 310 try
312 { 311 {
313 wreq = m_requests.Dequeue(0); 312 wreq = m_requests.Dequeue(0);
314 m_server.DoHTTPGruntWork( 313 DoHTTPGruntWork(m_server,wreq,
315 wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id), 314 wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id));
316 new OSHttpResponse(new HttpResponse(wreq.HttpContext, wreq.Request), wreq.HttpContext));
317 } 315 }
318 catch 316 catch
319 { 317 {
@@ -357,8 +355,7 @@ namespace OpenSim.Framework.Servers.HttpServer
357 try 355 try
358 { 356 {
359 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); 357 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
360 m_server.DoHTTPGruntWork(responsedata, 358 DoHTTPGruntWork(m_server, req, responsedata);
361 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
362 } 359 }
363 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream 360 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
364 { 361 {
@@ -374,8 +371,8 @@ namespace OpenSim.Framework.Servers.HttpServer
374 371
375 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) 372 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
376 { 373 {
377 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), 374 DoHTTPGruntWork(m_server, req,
378 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); 375 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id));
379 } 376 }
380 else 377 else
381 { 378 {
@@ -390,6 +387,46 @@ namespace OpenSim.Framework.Servers.HttpServer
390 } 387 }
391 } 388 }
392 } 389 }
390
391 // DoHTTPGruntWork changed, not sending response
392 // do the same work around as core
393
394 internal static void DoHTTPGruntWork(BaseHttpServer server, PollServiceHttpRequest req, Hashtable responsedata)
395 {
396 OSHttpResponse response
397 = new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext);
398
399 byte[] buffer = server.DoHTTPGruntWork(responsedata, response);
400
401 response.SendChunked = false;
402 response.ContentLength64 = buffer.Length;
403 response.ContentEncoding = Encoding.UTF8;
404
405 try
406 {
407 response.OutputStream.Write(buffer, 0, buffer.Length);
408 }
409 catch (Exception ex)
410 {
411 m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex));
412 }
413 finally
414 {
415 //response.OutputStream.Close();
416 try
417 {
418 response.OutputStream.Flush();
419 response.Send();
420
421 //if (!response.KeepAlive && response.ReuseContext)
422 // response.FreeContext();
423 }
424 catch (Exception e)
425 {
426 m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e));
427 }
428 }
429 }
393 } 430 }
394} 431}
395 432
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 05af942..f501828 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -225,7 +225,6 @@ namespace OpenSim.Region.Framework.Scenes
225 private int backupMS; 225 private int backupMS;
226 private int terrainMS; 226 private int terrainMS;
227 private int landMS; 227 private int landMS;
228 private int spareMS;
229 228
230 /// <summary> 229 /// <summary>
231 /// Tick at which the last frame was processed. 230 /// Tick at which the last frame was processed.
@@ -1434,16 +1433,20 @@ namespace OpenSim.Region.Framework.Scenes
1434 endFrame = Frame + frames; 1433 endFrame = Frame + frames;
1435 1434
1436 float physicsFPS = 0f; 1435 float physicsFPS = 0f;
1437 int previousFrameTick, tmpMS; 1436 int tmpMS;
1438 int maintc = Util.EnvironmentTickCount(); 1437 int previousFrameTick;
1438 int maintc;
1439 int sleepMS;
1440 int framestart;
1439 1441
1440 while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) 1442 while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
1441 { 1443 {
1444 framestart = Util.EnvironmentTickCount();
1442 ++Frame; 1445 ++Frame;
1443 1446
1444// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); 1447// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
1445 1448
1446 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; 1449 agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0;
1447 1450
1448 try 1451 try
1449 { 1452 {
@@ -1495,6 +1498,7 @@ namespace OpenSim.Region.Framework.Scenes
1495 m_sceneGraph.UpdatePresences(); 1498 m_sceneGraph.UpdatePresences();
1496 1499
1497 agentMS += Util.EnvironmentTickCountSubtract(tmpMS); 1500 agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
1501
1498 1502
1499 // Delete temp-on-rez stuff 1503 // Delete temp-on-rez stuff
1500 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) 1504 if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
@@ -1573,36 +1577,37 @@ namespace OpenSim.Region.Framework.Scenes
1573 1577
1574 Watchdog.UpdateThread(); 1578 Watchdog.UpdateThread();
1575 1579
1580 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
1581
1582 StatsReporter.AddPhysicsFPS(physicsFPS);
1583 StatsReporter.AddTimeDilation(TimeDilation);
1584 StatsReporter.AddFPS(1);
1585
1586 StatsReporter.addAgentMS(agentMS);
1587 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1588 StatsReporter.addOtherMS(otherMS);
1589 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1590
1576 previousFrameTick = m_lastFrameTick; 1591 previousFrameTick = m_lastFrameTick;
1577 m_lastFrameTick = Util.EnvironmentTickCount(); 1592 m_lastFrameTick = Util.EnvironmentTickCount();
1578 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); 1593 tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart);
1579 tmpMS = (int)(MinFrameTime * 1000) - tmpMS; 1594 tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
1580 1595
1581 m_firstHeartbeat = false; 1596 m_firstHeartbeat = false;
1582 1597
1598 sleepMS = Util.EnvironmentTickCount();
1599
1583 if (tmpMS > 0) 1600 if (tmpMS > 0)
1584 {
1585 Thread.Sleep(tmpMS); 1601 Thread.Sleep(tmpMS);
1586 spareMS += tmpMS;
1587 }
1588 1602
1589 frameMS = Util.EnvironmentTickCountSubtract(maintc); 1603 sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
1590 maintc = Util.EnvironmentTickCount(); 1604 frameMS = Util.EnvironmentTickCountSubtract(framestart);
1591 1605 StatsReporter.addSleepMS(sleepMS);
1592 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1606 StatsReporter.addFrameMS(frameMS);
1593 1607
1594 // if (Frame%m_update_avatars == 0) 1608 // if (Frame%m_update_avatars == 0)
1595 // UpdateInWorldTime(); 1609 // UpdateInWorldTime();
1596 StatsReporter.AddPhysicsFPS(physicsFPS);
1597 StatsReporter.AddTimeDilation(TimeDilation);
1598 StatsReporter.AddFPS(1);
1599 1610
1600 StatsReporter.addFrameMS(frameMS);
1601 StatsReporter.addAgentMS(agentMS);
1602 StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
1603 StatsReporter.addOtherMS(otherMS);
1604 StatsReporter.AddSpareMS(spareMS);
1605 StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
1606 1611
1607 // Optionally warn if a frame takes double the amount of time that it should. 1612 // Optionally warn if a frame takes double the amount of time that it should.
1608 if (DebugUpdates 1613 if (DebugUpdates
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index f1f94a7..6ab0027 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3066,7 +3066,7 @@ namespace OpenSim.Region.Framework.Scenes
3066 part.LinkNum = linkNum; 3066 part.LinkNum = linkNum;
3067 3067
3068 // Compute the new position of this SOP relative to the group position 3068 // Compute the new position of this SOP relative to the group position
3069 part.OffsetPosition = part.GroupPosition - AbsolutePosition; 3069 part.OffsetPosition = newPos - AbsolutePosition;
3070 3070
3071 // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. 3071 // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times.
3072 // It would have the affect of setting the physics engine position multiple 3072 // It would have the affect of setting the physics engine position multiple
@@ -3087,7 +3087,8 @@ namespace OpenSim.Region.Framework.Scenes
3087 3087
3088 // Since this SOP's state has changed, push those changes into the physics engine 3088 // Since this SOP's state has changed, push those changes into the physics engine
3089 // and the simulator. 3089 // and the simulator.
3090 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); 3090 // done on caller
3091// part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
3091 } 3092 }
3092 3093
3093 /// <summary> 3094 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b038876..bd11cde 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4964,7 +4964,7 @@ namespace OpenSim.Region.Framework.Scenes
4964 4964
4965 pa.OnCollisionUpdate -= PhysicsCollision; 4965 pa.OnCollisionUpdate -= PhysicsCollision;
4966 4966
4967 bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); 4967 bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0));
4968 4968
4969 scriptEvents CombinedEvents = AggregateScriptEvents; 4969 scriptEvents CombinedEvents = AggregateScriptEvents;
4970 4970
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
index 18e6ece..d6ff5a2 100644
--- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
+++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
@@ -164,7 +164,7 @@ namespace OpenSim.Region.Framework.Scenes
164 164
165 // saved last reported value so there is something available for llGetRegionFPS 165 // saved last reported value so there is something available for llGetRegionFPS
166 private float lastReportedSimFPS; 166 private float lastReportedSimFPS;
167 private float[] lastReportedSimStats = new float[22]; 167 private float[] lastReportedSimStats = new float[23];
168 private float m_pfps; 168 private float m_pfps;
169 169
170 /// <summary> 170 /// <summary>
@@ -178,12 +178,13 @@ namespace OpenSim.Region.Framework.Scenes
178 private int m_objectUpdates; 178 private int m_objectUpdates;
179 179
180 private int m_frameMS; 180 private int m_frameMS;
181 private int m_spareMS; 181
182 private int m_netMS; 182 private int m_netMS;
183 private int m_agentMS; 183 private int m_agentMS;
184 private int m_physicsMS; 184 private int m_physicsMS;
185 private int m_imageMS; 185 private int m_imageMS;
186 private int m_otherMS; 186 private int m_otherMS;
187 private int m_sleeptimeMS;
187 188
188//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. 189//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
189//Ckrinke private int m_scriptMS = 0; 190//Ckrinke private int m_scriptMS = 0;
@@ -260,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes
260 261
261 private void statsHeartBeat(object sender, EventArgs e) 262 private void statsHeartBeat(object sender, EventArgs e)
262 { 263 {
263 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; 264 SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23];
264 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); 265 SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
265 266
266 // Know what's not thread safe in Mono... modifying timers. 267 // Know what's not thread safe in Mono... modifying timers.
@@ -298,6 +299,8 @@ namespace OpenSim.Region.Framework.Scenes
298 physfps = 0; 299 physfps = 0;
299 300
300#endregion 301#endregion
302 float factor = 1 / m_statsUpdateFactor;
303
301 if (reportedFPS <= 0) 304 if (reportedFPS <= 0)
302 reportedFPS = 1; 305 reportedFPS = 1;
303 306
@@ -308,9 +311,22 @@ namespace OpenSim.Region.Framework.Scenes
308 float targetframetime = 1100.0f / (float)m_nominalReportedFps; 311 float targetframetime = 1100.0f / (float)m_nominalReportedFps;
309 312
310 float sparetime; 313 float sparetime;
314 float sleeptime;
315
311 if (TotalFrameTime > targetframetime) 316 if (TotalFrameTime > targetframetime)
312 { 317 {
313 sparetime = 0; 318 sparetime = 0;
319 sleeptime = 0;
320 }
321 else
322 {
323 sparetime = m_frameMS - m_physicsMS - m_agentMS;
324 sparetime *= perframe;
325 if (sparetime < 0)
326 sparetime = 0;
327 else if (sparetime > TotalFrameTime)
328 sparetime = TotalFrameTime;
329 sleeptime = m_sleeptimeMS * perframe;
314 } 330 }
315 331
316 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); 332 m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
@@ -327,19 +343,11 @@ namespace OpenSim.Region.Framework.Scenes
327 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; 343 // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
328 // m_imageMS m_netMS are not included in m_frameMS 344 // m_imageMS m_netMS are not included in m_frameMS
329 345
330 m_otherMS = m_frameMS - m_physicsMS - m_agentMS; 346 m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS;
331 if (m_otherMS < 0) 347 if (m_otherMS < 0)
332 m_otherMS = 0; 348 m_otherMS = 0;
333 349
334 uint thisFrame = m_scene.Frame; 350 for (int i = 0; i < 23; i++)
335 float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
336 m_lastUpdateFrame = thisFrame;
337
338 // Avoid div-by-zero if somehow we've not updated any frames.
339 if (framesUpdated == 0)
340 framesUpdated = 1;
341
342 for (int i = 0; i < 22; i++)
343 { 351 {
344 sb[i] = new SimStatsPacket.StatBlock(); 352 sb[i] = new SimStatsPacket.StatBlock();
345 } 353 }
@@ -369,19 +377,19 @@ namespace OpenSim.Region.Framework.Scenes
369 sb[7].StatValue = m_activePrim; 377 sb[7].StatValue = m_activePrim;
370 378
371 sb[8].StatID = (uint)Stats.FrameMS; 379 sb[8].StatID = (uint)Stats.FrameMS;
372 sb[8].StatValue = m_frameMS / framesUpdated; 380 sb[8].StatValue = TotalFrameTime;
373 381
374 sb[9].StatID = (uint)Stats.NetMS; 382 sb[9].StatID = (uint)Stats.NetMS;
375 sb[9].StatValue = m_netMS / framesUpdated; 383 sb[9].StatValue = m_netMS * perframe;
376 384
377 sb[10].StatID = (uint)Stats.PhysicsMS; 385 sb[10].StatID = (uint)Stats.PhysicsMS;
378 sb[10].StatValue = m_physicsMS / framesUpdated; 386 sb[10].StatValue = m_physicsMS * perframe;
379 387
380 sb[11].StatID = (uint)Stats.ImageMS ; 388 sb[11].StatID = (uint)Stats.ImageMS ;
381 sb[11].StatValue = m_imageMS / framesUpdated; 389 sb[11].StatValue = m_imageMS * perframe;
382 390
383 sb[12].StatID = (uint)Stats.OtherMS; 391 sb[12].StatID = (uint)Stats.OtherMS;
384 sb[12].StatValue = m_otherMS / framesUpdated; 392 sb[12].StatValue = m_otherMS * perframe;
385 393
386 sb[13].StatID = (uint)Stats.InPacketsPerSecond; 394 sb[13].StatID = (uint)Stats.InPacketsPerSecond;
387 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); 395 sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
@@ -393,7 +401,7 @@ namespace OpenSim.Region.Framework.Scenes
393 sb[15].StatValue = m_unAckedBytes; 401 sb[15].StatValue = m_unAckedBytes;
394 402
395 sb[16].StatID = (uint)Stats.AgentMS; 403 sb[16].StatID = (uint)Stats.AgentMS;
396 sb[16].StatValue = m_agentMS / framesUpdated; 404 sb[16].StatValue = m_agentMS * perframe;
397 405
398 sb[17].StatID = (uint)Stats.PendingDownloads; 406 sb[17].StatID = (uint)Stats.PendingDownloads;
399 sb[17].StatValue = m_pendingDownloads; 407 sb[17].StatValue = m_pendingDownloads;
@@ -408,7 +416,10 @@ namespace OpenSim.Region.Framework.Scenes
408 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; 416 sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
409 417
410 sb[21].StatID = (uint)Stats.SimSpareMs; 418 sb[21].StatID = (uint)Stats.SimSpareMs;
411 sb[21].StatValue = m_spareMS / framesUpdated; 419 sb[21].StatValue = sparetime;
420
421 sb[22].StatID = (uint)Stats.SimSleepMs;
422 sb[22].StatValue = sleeptime;
412 423
413 for (int i = 0; i < 22; i++) 424 for (int i = 0; i < 22; i++)
414 { 425 {
@@ -441,13 +452,14 @@ namespace OpenSim.Region.Framework.Scenes
441 // Need to change things so that stats source can indicate whether they are per second or 452 // Need to change things so that stats source can indicate whether they are per second or
442 // per frame. 453 // per frame.
443 if (tuple.Key.EndsWith("MS")) 454 if (tuple.Key.EndsWith("MS"))
444 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; 455 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe;
445 else 456 else
446 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; 457 m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
447 } 458 }
448 } 459 }
449 } 460 }
450 461
462// LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor;
451 ResetValues(); 463 ResetValues();
452 } 464 }
453 } 465 }
@@ -470,7 +482,8 @@ namespace OpenSim.Region.Framework.Scenes
470 m_physicsMS = 0; 482 m_physicsMS = 0;
471 m_imageMS = 0; 483 m_imageMS = 0;
472 m_otherMS = 0; 484 m_otherMS = 0;
473 m_spareMS = 0; 485// m_spareMS = 0;
486 m_sleeptimeMS = 0;
474 487
475//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. 488//Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
476//Ckrinke m_scriptMS = 0; 489//Ckrinke m_scriptMS = 0;
@@ -549,11 +562,6 @@ namespace OpenSim.Region.Framework.Scenes
549 m_frameMS += ms; 562 m_frameMS += ms;
550 } 563 }
551 564
552 public void AddSpareMS(int ms)
553 {
554 m_spareMS += ms;
555 }
556
557 public void addNetMS(int ms) 565 public void addNetMS(int ms)
558 { 566 {
559 m_netMS += ms; 567 m_netMS += ms;
@@ -579,6 +587,11 @@ namespace OpenSim.Region.Framework.Scenes
579 m_otherMS += ms; 587 m_otherMS += ms;
580 } 588 }
581 589
590 public void addSleepMS(int ms)
591 {
592 m_sleeptimeMS += ms;
593 }
594
582 public void AddPendingDownloads(int count) 595 public void AddPendingDownloads(int count)
583 { 596 {
584 m_pendingDownloads += count; 597 m_pendingDownloads += count;
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index aaeae86..a2c72c3 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -43,7 +43,8 @@ namespace OpenSim.Region.Physics.Manager
43 Unknown = 0, 43 Unknown = 0,
44 Agent = 1, 44 Agent = 1,
45 Prim = 2, 45 Prim = 2,
46 Ground = 3 46 Ground = 3,
47 Water = 4
47 } 48 }
48 49
49 public enum PIDHoverType 50 public enum PIDHoverType
@@ -114,7 +115,7 @@ namespace OpenSim.Region.Physics.Manager
114 m_objCollisionList.Add(localID, contact); 115 m_objCollisionList.Add(localID, contact);
115 } 116 }
116 else 117 else
117 { 118 {
118 if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) 119 if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth)
119 m_objCollisionList[localID] = contact; 120 m_objCollisionList[localID] = contact;
120 } 121 }
@@ -202,7 +203,7 @@ namespace OpenSim.Region.Physics.Manager
202 /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or 203 /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or
203 /// water. This is not a problem due to the formatting of names given by prims and avatars. 204 /// water. This is not a problem due to the formatting of names given by prims and avatars.
204 /// </remarks> 205 /// </remarks>
205 public string Name { get; protected set; } 206 public string Name { get; set; }
206 207
207 /// <summary> 208 /// <summary>
208 /// This is being used by ODE joint code. 209 /// This is being used by ODE joint code.
@@ -230,11 +231,6 @@ namespace OpenSim.Region.Physics.Manager
230 } 231 }
231 } 232 }
232 233
233 public virtual byte[] Serialize(bool PhysIsRunning)
234 {
235 return new byte[0];
236 }
237
238 public virtual void RaiseOutOfBounds(Vector3 pos) 234 public virtual void RaiseOutOfBounds(Vector3 pos)
239 { 235 {
240 // Make a temporary copy of the event to avoid possibility of 236 // Make a temporary copy of the event to avoid possibility of
@@ -258,10 +254,7 @@ namespace OpenSim.Region.Physics.Manager
258 handler(e); 254 handler(e);
259 } 255 }
260 256
261 public virtual void SetMaterial (int material) 257 public virtual void SetMaterial (int material) { }
262 {
263 }
264
265 public virtual float Density { get; set; } 258 public virtual float Density { get; set; }
266 public virtual float GravModifier { get; set; } 259 public virtual float GravModifier { get; set; }
267 public virtual float Friction { get; set; } 260 public virtual float Friction { get; set; }
@@ -373,13 +366,21 @@ namespace OpenSim.Region.Physics.Manager
373 public abstract void SubscribeEvents(int ms); 366 public abstract void SubscribeEvents(int ms);
374 public abstract void UnSubscribeEvents(); 367 public abstract void UnSubscribeEvents();
375 public abstract bool SubscribedEvents(); 368 public abstract bool SubscribedEvents();
369
370 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { }
371
372 // Warning in a parent part it returns itself, not null
373 public virtual PhysicsActor ParentActor { get { return this; } }
374
376 } 375 }
377 376
378 public class NullPhysicsActor : PhysicsActor 377 public class NullPhysicsActor : PhysicsActor
379 { 378 {
379 private ActorTypes m_actorType = ActorTypes.Unknown;
380
380 public override bool Stopped 381 public override bool Stopped
381 { 382 {
382 get{ return false; } 383 get{ return true; }
383 } 384 }
384 385
385 public override Vector3 Position 386 public override Vector3 Position
@@ -396,6 +397,7 @@ namespace OpenSim.Region.Physics.Manager
396 397
397 public override uint LocalID 398 public override uint LocalID
398 { 399 {
400 get { return 0; }
399 set { return; } 401 set { return; }
400 } 402 }
401 403
@@ -455,49 +457,17 @@ namespace OpenSim.Region.Physics.Manager
455 set { return; } 457 set { return; }
456 } 458 }
457 459
458 public override void VehicleFloatParam(int param, float value) 460 public override void VehicleFloatParam(int param, float value) {}
459 { 461 public override void VehicleVectorParam(int param, Vector3 value) { }
460 } 462 public override void VehicleRotationParam(int param, Quaternion rotation) { }
461 463 public override void VehicleFlags(int param, bool remove) { }
462 public override void VehicleVectorParam(int param, Vector3 value) 464 public override void SetVolumeDetect(int param) {}
463 { 465 public override void SetMaterial(int material) {}
464 466 public override Vector3 CenterOfMass { get { return Vector3.Zero; }}
465 }
466
467 public override void VehicleRotationParam(int param, Quaternion rotation)
468 {
469
470 }
471
472 public override void VehicleFlags(int param, bool remove)
473 {
474
475 }
476
477 public override void SetVolumeDetect(int param)
478 {
479
480 }
481
482 public override void SetMaterial(int material)
483 {
484
485 }
486
487 public override Vector3 CenterOfMass
488 {
489 get { return Vector3.Zero; }
490 }
491 467
492 public override Vector3 GeometricCenter 468 public override Vector3 GeometricCenter { get { return Vector3.Zero; }}
493 {
494 get { return Vector3.Zero; }
495 }
496 469
497 public override PrimitiveBaseShape Shape 470 public override PrimitiveBaseShape Shape { set { return; }}
498 {
499 set { return; }
500 }
501 471
502 public override Vector3 Velocity 472 public override Vector3 Velocity
503 { 473 {
@@ -517,9 +487,7 @@ namespace OpenSim.Region.Physics.Manager
517 set { } 487 set { }
518 } 488 }
519 489
520 public override void CrossingFailure() 490 public override void CrossingFailure() {}
521 {
522 }
523 491
524 public override Quaternion Orientation 492 public override Quaternion Orientation
525 { 493 {
@@ -559,8 +527,20 @@ namespace OpenSim.Region.Physics.Manager
559 527
560 public override int PhysicsActorType 528 public override int PhysicsActorType
561 { 529 {
562 get { return (int) ActorTypes.Unknown; } 530 get { return (int)m_actorType; }
563 set { return; } 531 set {
532 ActorTypes type = (ActorTypes)value;
533 switch (type)
534 {
535 case ActorTypes.Ground:
536 case ActorTypes.Water:
537 m_actorType = type;
538 break;
539 default:
540 m_actorType = ActorTypes.Unknown;
541 break;
542 }
543 }
564 } 544 }
565 545
566 public override bool Kinematic 546 public override bool Kinematic
@@ -569,26 +549,11 @@ namespace OpenSim.Region.Physics.Manager
569 set { return; } 549 set { return; }
570 } 550 }
571 551
572 public override void link(PhysicsActor obj) 552 public override void link(PhysicsActor obj) { }
573 { 553 public override void delink() { }
574 } 554 public override void LockAngularMotion(Vector3 axis) { }
575 555 public override void AddForce(Vector3 force, bool pushforce) { }
576 public override void delink() 556 public override void AddAngularForce(Vector3 force, bool pushforce) { }
577 {
578 }
579
580 public override void LockAngularMotion(Vector3 axis)
581 {
582 }
583
584 public override void AddForce(Vector3 force, bool pushforce)
585 {
586 }
587
588 public override void AddAngularForce(Vector3 force, bool pushforce)
589 {
590
591 }
592 557
593 public override Vector3 RotationalVelocity 558 public override Vector3 RotationalVelocity
594 { 559 {
@@ -610,22 +575,10 @@ namespace OpenSim.Region.Physics.Manager
610 public override float APIDStrength { set { return; } } 575 public override float APIDStrength { set { return; } }
611 public override float APIDDamping { set { return; } } 576 public override float APIDDamping { set { return; } }
612 577
613 public override void SetMomentum(Vector3 momentum) 578 public override void SetMomentum(Vector3 momentum) { }
614 {
615 }
616
617 public override void SubscribeEvents(int ms)
618 {
619
620 }
621 public override void UnSubscribeEvents()
622 {
623
624 }
625 public override bool SubscribedEvents()
626 {
627 return false;
628 }
629 579
580 public override void SubscribeEvents(int ms) { }
581 public override void UnSubscribeEvents() { }
582 public override bool SubscribedEvents() { return false; }
630 } 583 }
631} 584}
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index b506b1c..c363310 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.OdePlugin
106 private bool m_freemove = false; 106 private bool m_freemove = false;
107 // private CollisionLocker ode; 107 // private CollisionLocker ode;
108 108
109 private string m_name = String.Empty; 109// private string m_name = String.Empty;
110 // other filter control 110 // other filter control
111 int m_colliderfilter = 0; 111 int m_colliderfilter = 0;
112 int m_colliderGroundfilter = 0; 112 int m_colliderGroundfilter = 0;
@@ -183,7 +183,7 @@ namespace OpenSim.Region.Physics.OdePlugin
183 183
184 m_isPhysical = false; // current status: no ODE information exists 184 m_isPhysical = false; // current status: no ODE information exists
185 185
186 m_name = avName; 186 Name = avName;
187 187
188 AddChange(changes.Add, null); 188 AddChange(changes.Add, null);
189 } 189 }
@@ -218,6 +218,11 @@ namespace OpenSim.Region.Physics.OdePlugin
218 set { m_localID = value; } 218 set { m_localID = value; }
219 } 219 }
220 220
221 public override PhysicsActor ParentActor
222 {
223 get { return (PhysicsActor)this; }
224 }
225
221 public override bool Grabbed 226 public override bool Grabbed
222 { 227 {
223 set { return; } 228 set { return; }
@@ -740,7 +745,7 @@ namespace OpenSim.Region.Physics.OdePlugin
740 //kill the Geometry 745 //kill the Geometry
741 if (Shell != IntPtr.Zero) 746 if (Shell != IntPtr.Zero)
742 { 747 {
743 _parent_scene.geom_name_map.Remove(Shell); 748// _parent_scene.geom_name_map.Remove(Shell);
744 _parent_scene.actor_name_map.Remove(Shell); 749 _parent_scene.actor_name_map.Remove(Shell);
745 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 750 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
746 d.GeomDestroy(Shell); 751 d.GeomDestroy(Shell);
@@ -1115,7 +1120,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1115 m_eventsubscription = 0; 1120 m_eventsubscription = 0;
1116 } 1121 }
1117 1122
1118 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 1123 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
1119 { 1124 {
1120 if (CollisionEventsThisFrame == null) 1125 if (CollisionEventsThisFrame == null)
1121 CollisionEventsThisFrame = new CollisionEventUpdate(); 1126 CollisionEventsThisFrame = new CollisionEventUpdate();
@@ -1184,7 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1184 } 1189 }
1185 1190
1186 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); 1191 AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z);
1187 _parent_scene.geom_name_map[Shell] = m_name; 1192
1188 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1193 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
1189 _parent_scene.AddCharacter(this); 1194 _parent_scene.AddCharacter(this);
1190 } 1195 }
@@ -1236,7 +1241,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1236 1241
1237 Velocity = Vector3.Zero; 1242 Velocity = Vector3.Zero;
1238 1243
1239 _parent_scene.geom_name_map[Shell] = m_name;
1240 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1244 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
1241 } 1245 }
1242 else 1246 else
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 6d322e2..6bf5be1 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -176,7 +176,7 @@ namespace OpenSim.Region.Physics.OdePlugin
176 private bool m_lastUpdateSent; 176 private bool m_lastUpdateSent;
177 177
178 public IntPtr Body = IntPtr.Zero; 178 public IntPtr Body = IntPtr.Zero;
179 public String Name { get; private set; } 179// public String Name { get; private set; }
180 private Vector3 _target_velocity; 180 private Vector3 _target_velocity;
181 181
182 public Vector3 primOOBsize; // prim real dimensions from mesh 182 public Vector3 primOOBsize; // prim real dimensions from mesh
@@ -295,14 +295,14 @@ namespace OpenSim.Region.Physics.OdePlugin
295 set { m_localID = value; } 295 set { m_localID = value; }
296 } 296 }
297 297
298 public OdePrim Parent 298 public override PhysicsActor ParentActor
299 { 299 {
300 get 300 get
301 { 301 {
302 if (childPrim) 302 if (childPrim)
303 return (OdePrim)_parent; 303 return _parent;
304 else 304 else
305 return this; 305 return (PhysicsActor)this;
306 } 306 }
307 } 307 }
308 308
@@ -950,7 +950,7 @@ namespace OpenSim.Region.Physics.OdePlugin
950 _parent_scene.RemoveCollisionEventReporting(this); 950 _parent_scene.RemoveCollisionEventReporting(this);
951 } 951 }
952 952
953 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 953 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
954 { 954 {
955 if (CollisionEventsThisFrame == null) 955 if (CollisionEventsThisFrame == null)
956 CollisionEventsThisFrame = new CollisionEventUpdate(); 956 CollisionEventsThisFrame = new CollisionEventUpdate();
@@ -1431,6 +1431,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1431 //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); 1431 //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name);
1432 if (prim_geom != IntPtr.Zero) 1432 if (prim_geom != IntPtr.Zero)
1433 { 1433 {
1434
1434 if (m_NoColide) 1435 if (m_NoColide)
1435 { 1436 {
1436 d.GeomSetCategoryBits(prim_geom, 0); 1437 d.GeomSetCategoryBits(prim_geom, 0);
@@ -1452,7 +1453,6 @@ namespace OpenSim.Region.Physics.OdePlugin
1452 1453
1453 CalcPrimBodyData(); 1454 CalcPrimBodyData();
1454 1455
1455 _parent_scene.geom_name_map[prim_geom] = Name;
1456 _parent_scene.actor_name_map[prim_geom] = this; 1456 _parent_scene.actor_name_map[prim_geom] = this;
1457 1457
1458 } 1458 }
@@ -1526,7 +1526,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1526 { 1526 {
1527 if (prim_geom != IntPtr.Zero) 1527 if (prim_geom != IntPtr.Zero)
1528 { 1528 {
1529 _parent_scene.geom_name_map.Remove(prim_geom); 1529// _parent_scene.geom_name_map.Remove(prim_geom);
1530 _parent_scene.actor_name_map.Remove(prim_geom); 1530 _parent_scene.actor_name_map.Remove(prim_geom);
1531 try 1531 try
1532 { 1532 {
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
index 3d108f8..21fe9c0 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
@@ -470,56 +470,77 @@ namespace OpenSim.Region.Physics.OdePlugin
470 470
471 if (p2 == null) 471 if (p2 == null)
472 { 472 {
473 string name; 473 /*
474 474 string name;
475 if (!m_scene.geom_name_map.TryGetValue(g2, out name)) 475
476 return; 476 if (!m_scene.geom_name_map.TryGetValue(g2, out name))
477 477 return;
478 if (name == "Terrain") 478
479 { 479 if (name == "Terrain")
480 // land colision 480 {
481 if ((CurrentRayFilter & RayFilterFlags.land) == 0) 481 // land colision
482 return; 482 if ((CurrentRayFilter & RayFilterFlags.land) == 0)
483 } 483 return;
484 else if (name == "Water") 484 }
485 { 485 else if (name == "Water")
486 if ((CurrentRayFilter & RayFilterFlags.water) == 0) 486 {
487 return; 487 if ((CurrentRayFilter & RayFilterFlags.water) == 0)
488 } 488 return;
489 else 489 }
490 return; 490 else
491 return;
492 */
493 return;
491 } 494 }
492 else 495 else
493 { 496 {
494 if (p2 is OdePrim) 497 switch (p2.PhysicsActorType)
495 { 498 {
496 RayFilterFlags thisFlags; 499 case (int)ActorTypes.Prim:
497 500
498 if (p2.IsPhysical) 501 RayFilterFlags thisFlags;
499 thisFlags = RayFilterFlags.physical;
500 else
501 thisFlags = RayFilterFlags.nonphysical;
502 502
503 if (p2.Phantom) 503 if (p2.IsPhysical)
504 thisFlags |= RayFilterFlags.phantom; 504 thisFlags = RayFilterFlags.physical;
505 else
506 thisFlags = RayFilterFlags.nonphysical;
505 507
506 if (p2.IsVolumeDtc) 508 if (p2.Phantom)
507 thisFlags |= RayFilterFlags.volumedtc; 509 thisFlags |= RayFilterFlags.phantom;
508 510
509 if ((thisFlags & CurrentRayFilter) == 0) 511 if (p2.IsVolumeDtc)
510 return; 512 thisFlags |= RayFilterFlags.volumedtc;
511 513
512 ID = ((OdePrim)p2).LocalID; 514 if ((thisFlags & CurrentRayFilter) == 0)
513 } 515 return;
514 else if (p2 is OdeCharacter) 516
515 { 517 ID = ((OdePrim)p2).LocalID;
516 if ((CurrentRayFilter & RayFilterFlags.agent) == 0) 518 break;
519
520 case (int)ActorTypes.Agent:
521
522 if ((CurrentRayFilter & RayFilterFlags.agent) == 0)
523 return;
524 else
525 ID = ((OdeCharacter)p2).LocalID;
526 break;
527
528 case (int)ActorTypes.Ground:
529
530 if ((CurrentRayFilter & RayFilterFlags.land) == 0)
531 return;
532 break;
533
534 case (int)ActorTypes.Water:
535
536 if ((CurrentRayFilter & RayFilterFlags.water) == 0)
537 return;
538 break;
539
540 default:
517 return; 541 return;
518 else 542 break;
519 ID = ((OdeCharacter)p2).LocalID;
520 } 543 }
521 else //??
522 return;
523 } 544 }
524 545
525 d.ContactGeom curcontact = new d.ContactGeom(); 546 d.ContactGeom curcontact = new d.ContactGeom();
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
index ee48db5..403a4ce 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
@@ -903,7 +903,7 @@ namespace OdeAPI
903 public static extern GeomClassID GeomGetClass(IntPtr geom); 903 public static extern GeomClassID GeomGetClass(IntPtr geom);
904 904
905 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetData"), SuppressUnmanagedCodeSecurity] 905 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetData"), SuppressUnmanagedCodeSecurity]
906 public static extern IntPtr GeomGetData(IntPtr geom); 906 public static extern IntPtr GeomGetData(IntPtr geom);
907 907
908 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetOffsetPosition"), SuppressUnmanagedCodeSecurity] 908 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetOffsetPosition"), SuppressUnmanagedCodeSecurity]
909 public extern unsafe static Vector3* GeomGetOffsetPositionUnsafe(IntPtr geom); 909 public extern unsafe static Vector3* GeomGetOffsetPositionUnsafe(IntPtr geom);
@@ -1096,8 +1096,8 @@ namespace OdeAPI
1096 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetConvex"), SuppressUnmanagedCodeSecurity] 1096 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetConvex"), SuppressUnmanagedCodeSecurity]
1097 public static extern IntPtr GeomSetConvex(IntPtr geom, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons); 1097 public static extern IntPtr GeomSetConvex(IntPtr geom, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons);
1098 1098
1099 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetData"), SuppressUnmanagedCodeSecurity] 1099 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetData"), SuppressUnmanagedCodeSecurity]
1100 public static extern void GeomSetData(IntPtr geom, IntPtr data); 1100 public static extern void GeomSetData(IntPtr geom, IntPtr data);
1101 1101
1102 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetOffsetPosition"), SuppressUnmanagedCodeSecurity] 1102 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetOffsetPosition"), SuppressUnmanagedCodeSecurity]
1103 public static extern void GeomSetOffsetPosition(IntPtr geom, dReal x, dReal y, dReal z); 1103 public static extern void GeomSetOffsetPosition(IntPtr geom, dReal x, dReal y, dReal z);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 2928257..a554897 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -203,9 +203,9 @@ namespace OpenSim.Region.Physics.OdePlugin
203 private float waterlevel = 0f; 203 private float waterlevel = 0f;
204 private int framecount = 0; 204 private int framecount = 0;
205 205
206 private IntPtr WaterGeom = IntPtr.Zero; 206// private IntPtr WaterGeom = IntPtr.Zero;
207 private IntPtr WaterHeightmapData = IntPtr.Zero; 207// private IntPtr WaterHeightmapData = IntPtr.Zero;
208 private GCHandle WaterMapHandler = new GCHandle(); 208// private GCHandle WaterMapHandler = new GCHandle();
209 209
210 public float avPIDD = 2200f; // make it visible 210 public float avPIDD = 2200f; // make it visible
211 public float avPIDP = 900f; // make it visible 211 public float avPIDP = 900f; // make it visible
@@ -251,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin
251 private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>(); 251 private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>();
252 252
253 private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); 253 private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
254 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 254// public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); 255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
256 256
257 private float contactsurfacelayer = 0.002f; 257 private float contactsurfacelayer = 0.002f;
@@ -274,7 +274,7 @@ namespace OpenSim.Region.Physics.OdePlugin
274 274
275 private int m_physicsiterations = 10; 275 private int m_physicsiterations = 10;
276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag 276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
277 private PhysicsActor PANull = new NullPhysicsActor(); 277// private PhysicsActor PANull = new NullPhysicsActor();
278 private float step_time = 0.0f; 278 private float step_time = 0.0f;
279 279
280 public IntPtr world; 280 public IntPtr world;
@@ -713,6 +713,7 @@ namespace OpenSim.Region.Physics.OdePlugin
713 713
714 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 714 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
715 return; 715 return;
716
716 if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || 717 if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc ||
717 d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) 718 d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc)
718 { 719 {
@@ -738,7 +739,7 @@ namespace OpenSim.Region.Physics.OdePlugin
738 return; 739 return;
739 } 740 }
740 741
741 // id contacts done 742 // contacts done
742 if (count == 0) 743 if (count == 0)
743 return; 744 return;
744 745
@@ -748,12 +749,14 @@ namespace OpenSim.Region.Physics.OdePlugin
748 749
749 if (!actor_name_map.TryGetValue(g1, out p1)) 750 if (!actor_name_map.TryGetValue(g1, out p1))
750 { 751 {
751 p1 = PANull; 752 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 1");
753 return;
752 } 754 }
753 755
754 if (!actor_name_map.TryGetValue(g2, out p2)) 756 if (!actor_name_map.TryGetValue(g2, out p2))
755 { 757 {
756 p2 = PANull; 758 m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2");
759 return;
757 } 760 }
758 761
759 // update actors collision score 762 // update actors collision score
@@ -765,7 +768,6 @@ namespace OpenSim.Region.Physics.OdePlugin
765 p2.CollisionScore = 0; 768 p2.CollisionScore = 0;
766 p2.CollisionScore += count; 769 p2.CollisionScore += count;
767 770
768
769 // get first contact 771 // get first contact
770 d.ContactGeom curContact = new d.ContactGeom(); 772 d.ContactGeom curContact = new d.ContactGeom();
771 if (!GetCurContactGeom(0, ref curContact)) 773 if (!GetCurContactGeom(0, ref curContact))
@@ -798,7 +800,6 @@ namespace OpenSim.Region.Physics.OdePlugin
798 ContactData contactdata1 = new ContactData(0, 0, false); 800 ContactData contactdata1 = new ContactData(0, 0, false);
799 ContactData contactdata2 = new ContactData(0, 0, false); 801 ContactData contactdata2 = new ContactData(0, 0, false);
800 802
801 String name = null;
802 bool dop1foot = false; 803 bool dop1foot = false;
803 bool dop2foot = false; 804 bool dop2foot = false;
804 bool ignore = false; 805 bool ignore = false;
@@ -830,34 +831,16 @@ namespace OpenSim.Region.Physics.OdePlugin
830 switch (p2.PhysicsActorType) 831 switch (p2.PhysicsActorType)
831 { 832 {
832 case (int)ActorTypes.Agent: 833 case (int)ActorTypes.Agent:
833/*
834 p1.getContactData(ref contactdata1);
835 p2.getContactData(ref contactdata2);
836
837 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
838
839 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
840 mu *= frictionMovementMult;
841*/
842 p1.CollidingObj = true; 834 p1.CollidingObj = true;
843 p2.CollidingObj = true; 835 p2.CollidingObj = true;
844 break; 836 break;
845 case (int)ActorTypes.Prim:
846/*
847 p1.getContactData(ref contactdata1);
848 p2.getContactData(ref contactdata2);
849 837
850 838 case (int)ActorTypes.Prim:
851 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
852
853 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
854 mu *= frictionMovementMult;
855 */
856 if (p2.Velocity.LengthSquared() > 0.0f) 839 if (p2.Velocity.LengthSquared() > 0.0f)
857 p2.CollidingObj = true; 840 p2.CollidingObj = true;
858
859 dop1foot = true; 841 dop1foot = true;
860 break; 842 break;
843
861 default: 844 default:
862 ignore = true; // avatar to terrain and water ignored 845 ignore = true; // avatar to terrain and water ignored
863 break; 846 break;
@@ -869,9 +852,6 @@ namespace OpenSim.Region.Physics.OdePlugin
869 switch (p2.PhysicsActorType) 852 switch (p2.PhysicsActorType)
870 { 853 {
871 case (int)ActorTypes.Agent: 854 case (int)ActorTypes.Agent:
872 // p1.getContactData(ref contactdata1);
873 // p2.getContactData(ref contactdata2);
874
875 AvanormOverride = true; 855 AvanormOverride = true;
876 856
877 Vector3 tmp = p2.Position - p1.Position; 857 Vector3 tmp = p2.Position - p1.Position;
@@ -894,16 +874,12 @@ namespace OpenSim.Region.Physics.OdePlugin
894 bounce = 0; 874 bounce = 0;
895 mu = 0; 875 mu = 0;
896 cfm = 0.0001f; 876 cfm = 0.0001f;
897 /*
898 mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
899 877
900 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
901 mu *= frictionMovementMult;
902 */
903 dop2foot = true; 878 dop2foot = true;
904 if (p1.Velocity.LengthSquared() > 0.0f) 879 if (p1.Velocity.LengthSquared() > 0.0f)
905 p1.CollidingObj = true; 880 p1.CollidingObj = true;
906 break; 881 break;
882
907 case (int)ActorTypes.Prim: 883 case (int)ActorTypes.Prim:
908 if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f) 884 if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f)
909 { 885 {
@@ -933,95 +909,77 @@ namespace OpenSim.Region.Physics.OdePlugin
933 mu *= frictionMovementMult; 909 mu *= frictionMovementMult;
934 910
935 break; 911 break;
936 default:
937 if (geom_name_map.TryGetValue(g2, out name))
938 {
939 if (name == "Terrain")
940 {
941 p1.getContactData(ref contactdata1);
942 bounce = contactdata1.bounce * TerrainBounce;
943 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
944 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
945 mu *= frictionMovementMult;
946 p1.CollidingGround = true;
947
948 cfm = p1.Mass;
949 dscale = 10 / cfm;
950 dscale = (float)Math.Sqrt(dscale);
951 if (dscale > 1.0f)
952 dscale = 1.0f;
953 erpscale = cfm * 0.01f;
954 cfm = 0.0001f / cfm;
955 if (cfm > 0.01f)
956 cfm = 0.01f;
957 else if (cfm < 0.00001f)
958 cfm = 0.00001f;
959
960 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
961 {
962 if (curContact.side1 > 0)
963 IgnoreNegSides = true;
964 }
965
966 }
967 else if (name == "Water")
968 {
969 ignore = true;
970 }
971 }
972 else
973 ignore = true;
974 break;
975 }
976 break;
977
978 default:
979 if (geom_name_map.TryGetValue(g1, out name))
980 {
981 if (name == "Terrain")
982 {
983 if (p2.PhysicsActorType == (int)ActorTypes.Prim)
984 {
985 p2.CollidingGround = true;
986 p2.getContactData(ref contactdata2);
987 bounce = contactdata2.bounce * TerrainBounce;
988 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
989 912
990 cfm = p2.Mass; 913 case (int)ActorTypes.Ground:
991 dscale = 10 / cfm; 914 p1.getContactData(ref contactdata1);
992 dscale = (float)Math.Sqrt(dscale); 915 bounce = contactdata1.bounce * TerrainBounce;
993 916 mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
994 if (dscale > 1.0f) 917 if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
995 dscale = 1.0f; 918 mu *= frictionMovementMult;
919 p1.CollidingGround = true;
996 920
997 erpscale = cfm * 0.01f; 921 cfm = p1.Mass;
998 cfm = 0.0001f / cfm; 922 dscale = 10 / cfm;
999 if (cfm > 0.01f) 923 dscale = (float)Math.Sqrt(dscale);
1000 cfm = 0.01f; 924 if (dscale > 1.0f)
1001 else if (cfm < 0.00001f) 925 dscale = 1.0f;
1002 cfm = 0.00001f; 926 erpscale = cfm * 0.01f;
927 cfm = 0.0001f / cfm;
928 if (cfm > 0.01f)
929 cfm = 0.01f;
930 else if (cfm < 0.00001f)
931 cfm = 0.00001f;
1003 932
1004 if (curContact.side1 > 0) // should be 2 ? 933 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
934 {
935 if (curContact.side1 > 0)
1005 IgnoreNegSides = true; 936 IgnoreNegSides = true;
1006
1007 if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
1008 mu *= frictionMovementMult;
1009 } 937 }
1010 else 938 break;
1011 ignore = true;
1012 939
1013 } 940 case (int)ActorTypes.Water:
1014 else if (name == "Water" && 941 default:
1015 (p2.PhysicsActorType == (int)ActorTypes.Prim || p2.PhysicsActorType == (int)ActorTypes.Agent))
1016 {
1017 ignore = true; 942 ignore = true;
1018 } 943 break;
944 }
945 break;
946
947 case (int)ActorTypes.Ground:
948 if (p2.PhysicsActorType == (int)ActorTypes.Prim)
949 {
950 p2.CollidingGround = true;
951 p2.getContactData(ref contactdata2);
952 bounce = contactdata2.bounce * TerrainBounce;
953 mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
954
955 cfm = p2.Mass;
956 dscale = 10 / cfm;
957 dscale = (float)Math.Sqrt(dscale);
958
959 if (dscale > 1.0f)
960 dscale = 1.0f;
961
962 erpscale = cfm * 0.01f;
963 cfm = 0.0001f / cfm;
964 if (cfm > 0.01f)
965 cfm = 0.01f;
966 else if (cfm < 0.00001f)
967 cfm = 0.00001f;
968
969 if (curContact.side1 > 0) // should be 2 ?
970 IgnoreNegSides = true;
971
972 if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
973 mu *= frictionMovementMult;
1019 } 974 }
1020 else 975 else
1021 ignore = true; 976 ignore = true;
1022 break; 977 break;
1023 }
1024 978
979 case (int)ActorTypes.Water:
980 default:
981 break;
982 }
1025 if (ignore) 983 if (ignore)
1026 return; 984 return;
1027 985
@@ -1162,36 +1120,23 @@ namespace OpenSim.Region.Physics.OdePlugin
1162 1120
1163 } 1121 }
1164 */ 1122 */
1165 } 1123 }
1166 1124
1167 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) 1125 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
1168 { 1126 {
1169
1170 OdeCharacter cc1;
1171 OdePrim cp1;
1172 OdeCharacter cc2;
1173 OdePrim cp2;
1174 OdePrim cp1Parent;
1175 OdePrim cp2Parent;
1176
1177 uint obj2LocalID = 0; 1127 uint obj2LocalID = 0;
1128
1178 bool p1events = p1.SubscribedEvents(); 1129 bool p1events = p1.SubscribedEvents();
1179 bool p2events = p2.SubscribedEvents(); 1130 bool p2events = p2.SubscribedEvents();
1180 1131
1181 if (p1.IsVolumeDtc) 1132 if (p1.IsVolumeDtc)
1182 p2events = false; 1133 p2events = false;
1183 if (p2.IsVolumeDtc) 1134 if (p2.IsVolumeDtc)
1184 p1events = false; 1135 p1events = false;
1185 1136
1186 if (!(p2events || p1events)) 1137 if (!p2events && !p1events)
1187 return; 1138 return;
1188 1139
1189 if (p1events)
1190 AddCollisionEventReporting(p1);
1191
1192 if (p2events)
1193 AddCollisionEventReporting(p2);
1194
1195 Vector3 vel = Vector3.Zero; 1140 Vector3 vel = Vector3.Zero;
1196 if (p2 != null && p2.IsPhysical) 1141 if (p2 != null && p2.IsPhysical)
1197 vel = p2.Velocity; 1142 vel = p2.Velocity;
@@ -1200,71 +1145,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1200 vel -= p1.Velocity; 1145 vel -= p1.Velocity;
1201 1146
1202 contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); 1147 contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal);
1203 1148
1204 switch ((ActorTypes)p1.PhysicsActorType) 1149 switch ((ActorTypes)p1.PhysicsActorType)
1205 { 1150 {
1206 case ActorTypes.Agent: 1151 case ActorTypes.Agent:
1207 cc1 = (OdeCharacter)p1;
1208 switch ((ActorTypes)p2.PhysicsActorType)
1209 {
1210 case ActorTypes.Agent:
1211 cc2 = (OdeCharacter)p2;
1212 obj2LocalID = cc2.LocalID;
1213 if (p2events)
1214 cc2.AddCollisionEvent(cc1.LocalID, contact);
1215 break;
1216
1217 case ActorTypes.Prim:
1218 if (p2 is OdePrim)
1219 {
1220 cp2 = (OdePrim)p2;
1221 if (p2events)
1222 cp2.AddCollisionEvent(cc1.LocalID, contact);
1223 cp2 = cp2.Parent;
1224 obj2LocalID = cp2.LocalID;
1225 }
1226 break;
1227
1228 case ActorTypes.Ground:
1229 case ActorTypes.Unknown:
1230 default:
1231 obj2LocalID = 0;
1232 break;
1233 }
1234 if (p1events)
1235 {
1236 contact.SurfaceNormal = -contact.SurfaceNormal;
1237 cc1.AddCollisionEvent(obj2LocalID, contact);
1238 }
1239 break;
1240
1241 case ActorTypes.Prim: 1152 case ActorTypes.Prim:
1242 1153 {
1243 if (p1 is OdePrim)
1244 {
1245 cp1 = (OdePrim)p1;
1246 cp1Parent = cp1.Parent;
1247 switch ((ActorTypes)p2.PhysicsActorType) 1154 switch ((ActorTypes)p2.PhysicsActorType)
1248 { 1155 {
1249 case ActorTypes.Agent: 1156 case ActorTypes.Agent:
1250 if (p2 is OdeCharacter)
1251 {
1252 cc2 = (OdeCharacter)p2;
1253 obj2LocalID = cc2.LocalID;
1254 if (p2events)
1255 cc2.AddCollisionEvent(cp1Parent.LocalID, contact);
1256 }
1257 break;
1258 case ActorTypes.Prim: 1157 case ActorTypes.Prim:
1259 1158 if (p2events)
1260 if (p2 is OdePrim) 1159 {
1261 { 1160 AddCollisionEventReporting(p2);
1262 cp2 = (OdePrim)p2; 1161 p2.AddCollisionEvent(p1.ParentActor.LocalID, contact);
1263 if (p2events) 1162 }
1264 cp2.AddCollisionEvent(cp1Parent.LocalID, contact); 1163 obj2LocalID = p2.ParentActor.LocalID;
1265 cp2 = cp2.Parent;
1266 obj2LocalID = cp2.LocalID;
1267 }
1268 break; 1164 break;
1269 1165
1270 case ActorTypes.Ground: 1166 case ActorTypes.Ground:
@@ -1272,41 +1168,28 @@ namespace OpenSim.Region.Physics.OdePlugin
1272 default: 1168 default:
1273 obj2LocalID = 0; 1169 obj2LocalID = 0;
1274 break; 1170 break;
1275 } 1171 }
1276 if (p1events) 1172 if (p1events)
1277 { 1173 {
1278 contact.SurfaceNormal = -contact.SurfaceNormal; 1174 contact.SurfaceNormal = -contact.SurfaceNormal;
1279 cp1.AddCollisionEvent(obj2LocalID, contact); 1175 AddCollisionEventReporting(p1);
1280 } 1176 p1.AddCollisionEvent(obj2LocalID, contact);
1281 } 1177 }
1282 break; 1178 break;
1179 }
1283 case ActorTypes.Ground: 1180 case ActorTypes.Ground:
1284 case ActorTypes.Unknown: 1181 case ActorTypes.Unknown:
1285 default: 1182 default:
1286 switch ((ActorTypes)p2.PhysicsActorType) 1183 {
1184 if (p2events && !p2.IsVolumeDtc)
1287 { 1185 {
1288 case ActorTypes.Agent: 1186 AddCollisionEventReporting(p2);
1289 if (p2 is OdeCharacter) 1187 p2.AddCollisionEvent(0, contact);
1290 {
1291 cc2 = (OdeCharacter)p2;
1292 obj2LocalID = cc2.LocalID;
1293 if (p2events)
1294 cc2.AddCollisionEvent(0, contact);
1295 }
1296 break;
1297 case ActorTypes.Prim:
1298 if (p2 is OdePrim)
1299 {
1300 cp2 = (OdePrim)p2;
1301 obj2LocalID = cp2.LocalID;
1302 if (p2events)
1303 cp2.AddCollisionEvent(0, contact);
1304 }
1305 break;
1306 } 1188 }
1307 break; 1189 break;
1308 } 1190 }
1309 } 1191 }
1192 }
1310 1193
1311 /// <summary> 1194 /// <summary>
1312 /// This is our collision testing routine in ODE 1195 /// This is our collision testing routine in ODE
@@ -2369,6 +2252,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2369 RegionTerrain.Remove(pOffset); 2252 RegionTerrain.Remove(pOffset);
2370 if (GroundGeom != IntPtr.Zero) 2253 if (GroundGeom != IntPtr.Zero)
2371 { 2254 {
2255 actor_name_map.Remove(GroundGeom);
2372 d.GeomDestroy(GroundGeom); 2256 d.GeomDestroy(GroundGeom);
2373 2257
2374 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) 2258 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom))
@@ -2394,27 +2278,32 @@ namespace OpenSim.Region.Physics.OdePlugin
2394 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); 2278 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land));
2395 d.GeomSetCollideBits(GroundGeom, 0); 2279 d.GeomSetCollideBits(GroundGeom, 0);
2396 2280
2397 } 2281 PhysicsActor pa = new NullPhysicsActor();
2398 geom_name_map[GroundGeom] = "Terrain"; 2282 pa.Name = "Terrain";
2283 pa.PhysicsActorType = (int)ActorTypes.Ground;
2284 actor_name_map[GroundGeom] = pa;
2399 2285
2400 d.Matrix3 R = new d.Matrix3(); 2286// geom_name_map[GroundGeom] = "Terrain";
2401 2287
2402 Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); 2288 d.Matrix3 R = new d.Matrix3();
2403 Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f);
2404
2405 2289
2406 q1 = q1 * q2; 2290 Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f);
2407 2291 Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f);
2408 Vector3 v3; 2292
2409 float angle; 2293
2410 q1.GetAxisAngle(out v3, out angle); 2294 q1 = q1 * q2;
2411 2295
2412 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 2296 Vector3 v3;
2413 d.GeomSetRotation(GroundGeom, ref R); 2297 float angle;
2414 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2298 q1.GetAxisAngle(out v3, out angle);
2415 RegionTerrain.Add(pOffset, GroundGeom); 2299
2416 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2300 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
2417 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2301 d.GeomSetRotation(GroundGeom, ref R);
2302 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2303 RegionTerrain.Add(pOffset, GroundGeom);
2304 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2305 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2306 }
2418 } 2307 }
2419 } 2308 }
2420 2309
@@ -2478,6 +2367,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2478 RegionTerrain.Remove(pOffset); 2367 RegionTerrain.Remove(pOffset);
2479 if (GroundGeom != IntPtr.Zero) 2368 if (GroundGeom != IntPtr.Zero)
2480 { 2369 {
2370 actor_name_map.Remove(GroundGeom);
2481 d.GeomDestroy(GroundGeom); 2371 d.GeomDestroy(GroundGeom);
2482 2372
2483 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) 2373 if (TerrainHeightFieldHeights.ContainsKey(GroundGeom))
@@ -2509,13 +2399,18 @@ namespace OpenSim.Region.Physics.OdePlugin
2509 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); 2399 d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land));
2510 d.GeomSetCollideBits(GroundGeom, 0); 2400 d.GeomSetCollideBits(GroundGeom, 0);
2511 2401
2512 } 2402 PhysicsActor pa = new NullPhysicsActor();
2513 geom_name_map[GroundGeom] = "Terrain"; 2403 pa.Name = "Terrain";
2404 pa.PhysicsActorType = (int)ActorTypes.Ground;
2405 actor_name_map[GroundGeom] = pa;
2406
2407// geom_name_map[GroundGeom] = "Terrain";
2514 2408
2515 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2409 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2516 RegionTerrain.Add(pOffset, GroundGeom); 2410 RegionTerrain.Add(pOffset, GroundGeom);
2517 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2411 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2518 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2412 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2413 }
2519 } 2414 }
2520 } 2415 }
2521 2416
@@ -2596,9 +2491,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2596 public override void SetWaterLevel(float baseheight) 2491 public override void SetWaterLevel(float baseheight)
2597 { 2492 {
2598 waterlevel = baseheight; 2493 waterlevel = baseheight;
2599 randomizeWater(waterlevel); 2494// randomizeWater(waterlevel);
2600 } 2495 }
2601 2496/*
2602 public void randomizeWater(float baseheight) 2497 public void randomizeWater(float baseheight)
2603 { 2498 {
2604 const uint heightmapWidth = Constants.RegionSize + 2; 2499 const uint heightmapWidth = Constants.RegionSize + 2;
@@ -2632,6 +2527,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2632 { 2527 {
2633 if (WaterGeom != IntPtr.Zero) 2528 if (WaterGeom != IntPtr.Zero)
2634 { 2529 {
2530 actor_name_map.Remove(WaterGeom);
2635 d.GeomDestroy(WaterGeom); 2531 d.GeomDestroy(WaterGeom);
2636 d.GeomHeightfieldDataDestroy(WaterHeightmapData); 2532 d.GeomHeightfieldDataDestroy(WaterHeightmapData);
2637 WaterGeom = IntPtr.Zero; 2533 WaterGeom = IntPtr.Zero;
@@ -2654,7 +2550,13 @@ namespace OpenSim.Region.Physics.OdePlugin
2654 d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water)); 2550 d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water));
2655 d.GeomSetCollideBits(WaterGeom, 0); 2551 d.GeomSetCollideBits(WaterGeom, 0);
2656 2552
2657 geom_name_map[WaterGeom] = "Water"; 2553
2554 PhysicsActor pa = new NullPhysicsActor();
2555 pa.Name = "Water";
2556 pa.PhysicsActorType = (int)ActorTypes.Water;
2557
2558 actor_name_map[WaterGeom] = pa;
2559// geom_name_map[WaterGeom] = "Water";
2658 2560
2659 d.Matrix3 R = new d.Matrix3(); 2561 d.Matrix3 R = new d.Matrix3();
2660 2562
@@ -2672,7 +2574,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2672 } 2574 }
2673 } 2575 }
2674 } 2576 }
2675 2577*/
2676 public override void Dispose() 2578 public override void Dispose()
2677 { 2579 {
2678 lock (OdeLock) 2580 lock (OdeLock)
@@ -2722,7 +2624,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2722 2624
2723 TerrainHeightFieldHeightsHandlers.Clear(); 2625 TerrainHeightFieldHeightsHandlers.Clear();
2724 TerrainHeightFieldHeights.Clear(); 2626 TerrainHeightFieldHeights.Clear();
2725 2627/*
2726 if (WaterGeom != IntPtr.Zero) 2628 if (WaterGeom != IntPtr.Zero)
2727 { 2629 {
2728 d.GeomDestroy(WaterGeom); 2630 d.GeomDestroy(WaterGeom);
@@ -2734,7 +2636,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2734 if (WaterMapHandler.IsAllocated) 2636 if (WaterMapHandler.IsAllocated)
2735 WaterMapHandler.Free(); 2637 WaterMapHandler.Free();
2736 } 2638 }
2737 2639*/
2738 if (ContactgeomsArray != IntPtr.Zero) 2640 if (ContactgeomsArray != IntPtr.Zero)
2739 Marshal.FreeHGlobal(ContactgeomsArray); 2641 Marshal.FreeHGlobal(ContactgeomsArray);
2740 if (GlobalContactsArray != IntPtr.Zero) 2642 if (GlobalContactsArray != IntPtr.Zero)