aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
diff options
context:
space:
mode:
authorMelanie2010-03-01 01:01:32 +0000
committerMelanie2010-03-01 01:01:32 +0000
commit38ea1dd5c82df6e037f7e634df572df5a38b2bd0 (patch)
tree5d94d42e833985ff13a1522085b28f9889d70595 /OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
parentShould have things the right way around, better that way (diff)
parentfix bug where region settings loaded via an oar (water height, terrain textur... (diff)
downloadopensim-SC_OLD-38ea1dd5c82df6e037f7e634df572df5a38b2bd0.zip
opensim-SC_OLD-38ea1dd5c82df6e037f7e634df572df5a38b2bd0.tar.gz
opensim-SC_OLD-38ea1dd5c82df6e037f7e634df572df5a38b2bd0.tar.bz2
opensim-SC_OLD-38ea1dd5c82df6e037f7e634df572df5a38b2bd0.tar.xz
Merge branch 'master' into presence-refactor
Diffstat (limited to 'OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs')
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs183
1 files changed, 183 insertions, 0 deletions
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
new file mode 100644
index 0000000..4de4b01
--- /dev/null
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXScene.cs
@@ -0,0 +1,183 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager;
33using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection;
36using log4net;
37using OpenMetaverse;
38
39namespace OpenSim.Region.Physics.PhysXPlugin
40{
41 public class PhysXScene : PhysicsScene
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
45 private List<PhysXPrim> _prims = new List<PhysXPrim>();
46 private float[] _heightMap = null;
47 private NxPhysicsSDK mySdk;
48 private NxScene scene;
49
50 // protected internal string sceneIdentifier;
51 public PhysXScene(string _sceneIdentifier)
52 {
53 //sceneIdentifier = _sceneIdentifier;
54
55 mySdk = NxPhysicsSDK.CreateSDK();
56 m_log.Info("Sdk created - now creating scene");
57 scene = mySdk.CreateScene();
58 }
59
60 public override void Initialise(IMesher meshmerizer, IConfigSource config)
61 {
62 // Does nothing right now
63 }
64 public override void Dispose()
65 {
66
67 }
68
69 public override void SetWaterLevel(float baseheight)
70 {
71
72 }
73
74 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
75 {
76 Vec3 pos = new Vec3();
77 pos.X = position.X;
78 pos.Y = position.Y;
79 pos.Z = position.Z;
80 PhysXCharacter act = new PhysXCharacter(scene.AddCharacter(pos));
81 act.Flying = isFlying;
82 act.Position = position;
83 _characters.Add(act);
84 return act;
85 }
86
87 public override void RemovePrim(PhysicsActor prim)
88 {
89 }
90
91 public override void RemoveAvatar(PhysicsActor actor)
92 {
93 }
94
95 private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
96 {
97 Vec3 pos = new Vec3();
98 pos.X = position.X;
99 pos.Y = position.Y;
100 pos.Z = position.Z;
101 Vec3 siz = new Vec3();
102 siz.X = size.X;
103 siz.Y = size.Y;
104 siz.Z = size.Z;
105 PhysXPrim act = new PhysXPrim(scene.AddNewBox(pos, siz));
106 _prims.Add(act);
107 return act;
108 }
109
110 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
111 Vector3 size, Quaternion rotation) //To be removed
112 {
113 return AddPrimShape(primName, pbs, position, size, rotation, false);
114 }
115
116 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
117 Vector3 size, Quaternion rotation, bool isPhysical)
118 {
119 return AddPrim(position, size, rotation);
120 }
121
122 public override void AddPhysicsActorTaint(PhysicsActor prim)
123 {
124 }
125
126 public override float Simulate(float timeStep)
127 {
128 float fps = 0f;
129 try
130 {
131 foreach (PhysXCharacter actor in _characters)
132 {
133 actor.Move(timeStep);
134 }
135 scene.Simulate(timeStep);
136 scene.FetchResults();
137 scene.UpdateControllers();
138
139 foreach (PhysXCharacter actor in _characters)
140 {
141 actor.UpdatePosition();
142 }
143 }
144 catch (Exception e)
145 {
146 m_log.Error(e.Message);
147 }
148 return fps;
149 }
150
151 public override void GetResults()
152 {
153 }
154
155 public override bool IsThreaded
156 {
157 // for now we won't be multithreaded
158 get { return (false); }
159 }
160
161 public override void SetTerrain(float[] heightMap)
162 {
163 if (_heightMap != null)
164 {
165 m_log.Debug("PhysX - deleting old terrain");
166 scene.DeleteTerrain();
167 }
168 _heightMap = heightMap;
169 scene.AddTerrain(heightMap);
170 }
171
172 public override void DeleteTerrain()
173 {
174 scene.DeleteTerrain();
175 }
176
177 public override Dictionary<uint, float> GetTopColliders()
178 {
179 Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
180 return returncolliders;
181 }
182 }
183}