29 using System.Collections.Generic;
33 using OpenSim.Framework;
34 using OpenSim.Region.PhysicsModules.SharedBase;
35 using OpenSim.Region.Framework.Scenes;
36 using OpenSim.Region.Framework.Interfaces;
38 namespace OpenSim.
Region.PhysicsModule.BasicPhysics
47 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"BasicPhysicsScene")]
50 private List<BasicActor> _actors =
new List<BasicActor>();
51 private List<BasicPhysicsPrim> _prims =
new List<BasicPhysicsPrim>();
52 private float[] _heightMap;
53 private Vector3 m_regionExtent;
55 private bool m_Enabled =
false;
58 #region INonSharedRegionModule
61 get {
return "basicphysics"; }
64 public Type ReplaceableInterface
72 IConfig config = source.Configs[
"Startup"];
75 string physics = config.GetString(
"physics", string.Empty);
92 PhysicsSceneName = EngineType +
"/" + scene.RegionInfo.RegionName;
96 base.Initialise(scene.PhysicsRequestAsset,
118 Vector3 size, Quaternion
rotation,
bool isPhysical, uint localid)
121 prim.IsPhysical = isPhysical;
128 public override PhysicsActor AddAvatar(
string avName, Vector3 position, Vector3 velocity, Vector3 size,
bool isFlying)
131 act.Position = position;
132 act.Velocity = velocity;
133 act.Flying = isFlying;
141 if (_prims.Contains(prim))
148 if (_actors.Contains(act))
161 for (
int i = 0; i < _actors.Count; ++i)
164 Vector3 actorPosition = actor.Position;
165 Vector3 actorVelocity = actor.Velocity;
170 actorPosition.X += actor.Velocity.X * timeStep;
171 actorPosition.Y += actor.Velocity.Y * timeStep;
175 actorPosition.Y = 0.1F;
177 else if (actor.
Position.Y >= m_regionExtent.Y)
179 actorPosition.Y = (m_regionExtent.Y - 0.1f);
184 actorPosition.X = 0.1F;
186 else if (actor.
Position.X >= m_regionExtent.X)
188 actorPosition.X = (m_regionExtent.X - 0.1f);
191 float terrainHeight = 0;
192 if (_heightMap != null)
193 terrainHeight = _heightMap[(int)actor.
Position.Y * (
int)m_regionExtent.Y + (int)actor.
Position.X];
195 float height = terrainHeight + actor.
Size.Z;
202 actorPosition.Z = height;
204 actor.IsColliding =
true;
208 actorPosition.Z += actor.Velocity.Z * timeStep;
209 actor.IsColliding =
false;
214 actorPosition.Z = height;
216 actor.IsColliding =
true;
219 actor.Position = actorPosition;
220 actor.Velocity = actorVelocity;
230 public override bool IsThreaded
232 get {
return (
false);
238 _heightMap = heightMap;
251 Dictionary<uint, float> returncolliders =
new Dictionary<uint, float>();
252 return returncolliders;
override void SetTerrain(float[] heightMap)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
override Vector3 Position
override void DeleteTerrain()
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
uint RegionSizeX
X dimension of the region.
uint RegionSizeY
X dimension of the region.
override Vector3 Velocity
RegionSettings RegionSettings
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical, uint localid)
override void RemovePrim(PhysicsActor actor)
Remove a prim.
override void AddPhysicsActorTaint(PhysicsActor prim)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
override void GetResults()
override void SetWaterLevel(float baseheight)
override float Simulate(float timeStep)
Perform a simulation of the current physics scene over the given timestep.
This is an incomplete extremely basic physics implementation
override Dictionary< uint, float > GetTopColliders()
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
override void RemoveAvatar(PhysicsActor actor)
Remove an avatar.
override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 velocity, Vector3 size, bool isFlying)
Add an avatar
uint RegionSizeZ
Z dimension of the region.
virtual RegionInfo RegionInfo