aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour2.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour2.cs (renamed from OpenSim/Region/Physics/OdePlugin/OdePlugin.cs)74
1 files changed, 35 insertions, 39 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour2.cs
index 478dd95..1ec2046 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour2.cs
@@ -25,66 +25,62 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using OpenMetaverse;
28using System; 29using System;
29using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Linq;
30using System.Reflection; 32using System.Reflection;
31using System.Runtime.InteropServices;
32using System.Threading; 33using System.Threading;
33using System.IO;
34using System.Diagnostics;
35using log4net; 34using log4net;
36using Nini.Config; 35using pCampBot.Interfaces;
37using Ode.NET;
38using OpenSim.Framework;
39using OpenSim.Region.Physics.Manager;
40using OpenMetaverse;
41 36
42namespace OpenSim.Region.Physics.OdePlugin 37namespace pCampBot
43{ 38{
44 /// <summary> 39 /// <summary>
45 /// ODE plugin 40 /// This behavior is for the systematic study of some performance improvements made
41 /// for OSCC'13.
42 /// Walk around, sending AgentUpdate packets all the time.
46 /// </summary> 43 /// </summary>
47 public class OdePlugin : IPhysicsPlugin 44 public class PhysicsBehaviour2 : AbstractBehaviour
48 { 45 {
49 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 46// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private OdeScene m_scene;
52 47
53 public bool Init() 48 public PhysicsBehaviour2()
54 { 49 {
55 return true; 50 AbbreviatedName = "ph2";
51 Name = "Physics2";
56 } 52 }
57 53
58 public PhysicsScene GetScene(String sceneIdentifier) 54 private const int TIME_WALKING = 5 * 10; // 5 seconds
55 private int counter = 0;
56
57 public override void Action()
59 { 58 {
60 if (m_scene == null) 59
60 if (counter >= TIME_WALKING)
61 { 61 {
62 // We do this so that OpenSimulator on Windows loads the correct native ODE library depending on whether 62 counter = 0;
63 // it's running as a 32-bit process or a 64-bit one. By invoking LoadLibary here, later DLLImports
64 // will find it already loaded later on.
65 //
66 // This isn't necessary for other platforms (e.g. Mac OSX and Linux) since the DLL used can be
67 // controlled in Ode.NET.dll.config
68 if (Util.IsWindows())
69 Util.LoadArchSpecificWindowsDll("ode.dll");
70 63
71 // Initializing ODE only when a scene is created allows alternative ODE plugins to co-habit (according to 64 Vector3 target = new Vector3(Bot.Random.Next(1, 254), Bot.Random.Next(1, 254), Bot.Client.Self.SimPosition.Z);
72 // http://opensimulator.org/mantis/view.php?id=2750). 65 MyTurnToward(target);
73 d.InitODE();
74
75 m_scene = new OdeScene(sceneIdentifier);
76 }
77 66
78 return m_scene; 67 Bot.Client.Self.Movement.AtPos = true;
79 }
80 68
81 public string GetName() 69 }
82 { 70 else
83 return ("OpenDynamicsEngine"); 71 counter++;
72 // In any case, send an update
73 Bot.Client.Self.Movement.SendUpdate();
84 } 74 }
85 75
86 public void Dispose() 76 private void MyTurnToward(Vector3 target)
87 { 77 {
78 Quaternion between = Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(target - Bot.Client.Self.SimPosition));
79 Quaternion rot = between ;
80
81 Bot.Client.Self.Movement.BodyRotation = rot;
82 Bot.Client.Self.Movement.HeadRotation = rot;
83 Bot.Client.Self.Movement.Camera.LookAt(Bot.Client.Self.SimPosition, target);
88 } 84 }
89 } 85 }
90} \ No newline at end of file 86} \ No newline at end of file