diff options
Diffstat (limited to 'OpenSim.RegionServer/world/Primitive.cs')
-rw-r--r-- | OpenSim.RegionServer/world/Primitive.cs | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/OpenSim.RegionServer/world/Primitive.cs b/OpenSim.RegionServer/world/Primitive.cs index a185f0b..ca764a7 100644 --- a/OpenSim.RegionServer/world/Primitive.cs +++ b/OpenSim.RegionServer/world/Primitive.cs | |||
@@ -12,6 +12,7 @@ namespace OpenSim.world | |||
12 | { | 12 | { |
13 | public class Primitive : Entity | 13 | public class Primitive : Entity |
14 | { | 14 | { |
15 | //private static object physicsLock = new object(); | ||
15 | protected float mesh_cutbegin; | 16 | protected float mesh_cutbegin; |
16 | protected float mesh_cutend; | 17 | protected float mesh_cutend; |
17 | protected PrimData primData; | 18 | protected PrimData primData; |
@@ -21,7 +22,8 @@ namespace OpenSim.world | |||
21 | private ObjectUpdatePacket OurPacket; | 22 | private ObjectUpdatePacket OurPacket; |
22 | private PhysicsActor _physActor; | 23 | private PhysicsActor _physActor; |
23 | private bool physicsEnabled = false; | 24 | private bool physicsEnabled = false; |
24 | private bool physicstest = false; //just added for testing | 25 | private bool physicstest = false; |
26 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | ||
25 | private Dictionary<uint, SimClient> m_clientThreads; | 27 | private Dictionary<uint, SimClient> m_clientThreads; |
26 | private ulong m_regionHandle; | 28 | private ulong m_regionHandle; |
27 | private World m_world; | 29 | private World m_world; |
@@ -72,7 +74,7 @@ namespace OpenSim.world | |||
72 | { | 74 | { |
73 | mesh_cutbegin = 0.0f; | 75 | mesh_cutbegin = 0.0f; |
74 | mesh_cutend = 1.0f; | 76 | mesh_cutend = 1.0f; |
75 | 77 | ||
76 | m_clientThreads = clientThreads; | 78 | m_clientThreads = clientThreads; |
77 | m_regionHandle = regionHandle; | 79 | m_regionHandle = regionHandle; |
78 | m_world = world; | 80 | m_world = world; |
@@ -97,13 +99,30 @@ namespace OpenSim.world | |||
97 | this.position = pos; | 99 | this.position = pos; |
98 | if (this._physActor != null) // && this.physicsEnabled) | 100 | if (this._physActor != null) // && this.physicsEnabled) |
99 | { | 101 | { |
100 | this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z); | 102 | try |
103 | { | ||
104 | lock (m_world.LockPhysicsEngine) | ||
105 | { | ||
106 | this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z); | ||
107 | } | ||
108 | } | ||
109 | catch (Exception e) | ||
110 | { | ||
111 | Console.WriteLine(e.Message); | ||
112 | } | ||
101 | } | 113 | } |
102 | this.updateFlag = true; | 114 | this.updateFlag = true; |
103 | } | 115 | } |
104 | 116 | ||
105 | public override void update() | 117 | public override void update() |
106 | { | 118 | { |
119 | LLVector3 pos2 = new LLVector3(0, 0, 0); | ||
120 | if (this._physActor != null && this.physicsEnabled) | ||
121 | { | ||
122 | |||
123 | PhysicsVector pPos = this._physActor.Position; | ||
124 | pos2 = new LLVector3(pPos.X, pPos.Y, pPos.Z); | ||
125 | } | ||
107 | if (this.newPrimFlag) | 126 | if (this.newPrimFlag) |
108 | { | 127 | { |
109 | foreach (SimClient client in m_clientThreads.Values) | 128 | foreach (SimClient client in m_clientThreads.Values) |
@@ -137,15 +156,19 @@ namespace OpenSim.world | |||
137 | { | 156 | { |
138 | if (this._physActor != null && this.physicsEnabled) | 157 | if (this._physActor != null && this.physicsEnabled) |
139 | { | 158 | { |
140 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | 159 | if (pos2 != this.positionLastFrame) |
141 | terse.RegionData.RegionHandle = m_regionHandle; // FIXME | ||
142 | terse.RegionData.TimeDilation = 64096; | ||
143 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
144 | terse.ObjectData[0] = this.CreateImprovedBlock(); | ||
145 | foreach (SimClient client in m_clientThreads.Values) | ||
146 | { | 160 | { |
147 | client.OutPacket(terse); | 161 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); |
162 | terse.RegionData.RegionHandle = m_regionHandle; // FIXME | ||
163 | terse.RegionData.TimeDilation = 64096; | ||
164 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
165 | terse.ObjectData[0] = this.CreateImprovedBlock(); | ||
166 | foreach (SimClient client in m_clientThreads.Values) | ||
167 | { | ||
168 | client.OutPacket(terse); | ||
169 | } | ||
148 | } | 170 | } |
171 | this.positionLastFrame = pos2; | ||
149 | } | 172 | } |
150 | } | 173 | } |
151 | 174 | ||
@@ -487,7 +510,7 @@ namespace OpenSim.world | |||
487 | this.primData.LocalID = this.localid; | 510 | this.primData.LocalID = this.localid; |
488 | this.primData.Position = this.position; | 511 | this.primData.Position = this.position; |
489 | this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); | 512 | this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); |
490 | m_world.localStorage.StorePrim(this.primData); | 513 | this.m_world.localStorage.StorePrim(this.primData); |
491 | } | 514 | } |
492 | } | 515 | } |
493 | 516 | ||