aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world/Primitive.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/world/Primitive.cs83
1 files changed, 73 insertions, 10 deletions
diff --git a/src/world/Primitive.cs b/src/world/Primitive.cs
index 0d7d951..6be33ef 100644
--- a/src/world/Primitive.cs
+++ b/src/world/Primitive.cs
@@ -5,6 +5,7 @@ using OpenSim.types;
5using libsecondlife; 5using libsecondlife;
6using libsecondlife.Packets; 6using libsecondlife.Packets;
7using GridInterfaces; 7using GridInterfaces;
8using PhysicsSystem;
8 9
9namespace OpenSim.world 10namespace OpenSim.world
10{ 11{
@@ -16,8 +17,21 @@ namespace OpenSim.world
16 protected bool newPrimFlag; 17 protected bool newPrimFlag;
17 protected bool updateFlag; 18 protected bool updateFlag;
18 protected bool dirtyFlag; 19 protected bool dirtyFlag;
19 protected ObjectUpdatePacket OurPacket; 20 private ObjectUpdatePacket OurPacket;
21 private PhysicsActor _physActor;
22 private bool physicsEnabled;
20 23
24 public bool PhysicsEnabled
25 {
26 get
27 {
28 return physicsEnabled;
29 }
30 set
31 {
32 physicsEnabled = value;
33 }
34 }
21 public bool UpdateFlag 35 public bool UpdateFlag
22 { 36 {
23 get 37 get
@@ -41,6 +55,14 @@ namespace OpenSim.world
41 return this.primData.Scale; 55 return this.primData.Scale;
42 } 56 }
43 } 57 }
58 public PhysicsActor PhysActor
59 {
60 set
61 {
62 this._physActor = value;
63 }
64 }
65
44 public Primitive() 66 public Primitive()
45 { 67 {
46 mesh_cutbegin = 0.0f; 68 mesh_cutbegin = 0.0f;
@@ -61,6 +83,16 @@ namespace OpenSim.world
61 return mesh; 83 return mesh;
62 } 84 }
63 85
86 public void UpdatePosition( LLVector3 pos)
87 {
88 this.position = pos;
89 if(this._physActor != null && this.physicsEnabled)
90 {
91 this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z);
92 }
93 this.updateFlag = true;
94 }
95
64 public override void update() 96 public override void update()
65 { 97 {
66 if(this.newPrimFlag) 98 if(this.newPrimFlag)
@@ -89,13 +121,39 @@ namespace OpenSim.world
89 } 121 }
90 this.dirtyFlag = false; 122 this.dirtyFlag = false;
91 } 123 }
92 124 else
125 {
126 if(this._physActor != null && this.physicsEnabled)
127 {
128 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
129 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
130 terse.RegionData.TimeDilation = 64096;
131 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
132 terse.ObjectData[0] = this.CreateImprovedBlock();
133 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
134 client.OutPacket(terse);
135 }
136 }
137 }
93 } 138 }
94 139
95 public void UpdateClient(OpenSimClient RemoteClient) 140 public void UpdateClient(OpenSimClient RemoteClient)
96 { 141 {
97 byte[] pb = this.position.GetBytes(); 142
143 LLVector3 lPos;
144 if( this._physActor != null && this.physicsEnabled)
145 {
146 PhysicsVector pPos = this._physActor.Position;
147 lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
148 }
149 else
150 {
151 lPos = this.position;
152 }
153 byte[] pb = lPos.GetBytes();
98 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); 154 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
155
156 // OurPacket should be update with the follwing in updateShape() rather than having to do it here
99 OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID; 157 OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID;
100 OurPacket.ObjectData[0].PCode = this.primData.PCode; 158 OurPacket.ObjectData[0].PCode = this.primData.PCode;
101 OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin; 159 OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin;
@@ -137,7 +195,6 @@ namespace OpenSim.world
137 this.primData.PathCurve = addPacket.PathCurve; 195 this.primData.PathCurve = addPacket.PathCurve;
138 this.primData.ProfileCurve = addPacket.ProfileCurve; 196 this.primData.ProfileCurve = addPacket.ProfileCurve;
139 this.primData.ProfileHollow = addPacket.ProfileHollow; 197 this.primData.ProfileHollow = addPacket.ProfileHollow;
140
141 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset; 198 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
142 this.primData.PathRevolutions = addPacket.PathRevolutions; 199 this.primData.PathRevolutions = addPacket.PathRevolutions;
143 this.primData.PathTaperX = addPacket.PathTaperX; 200 this.primData.PathTaperX = addPacket.PathTaperX;
@@ -145,7 +202,6 @@ namespace OpenSim.world
145 this.primData.PathTwist = addPacket.PathTwist; 202 this.primData.PathTwist = addPacket.PathTwist;
146 this.primData.PathTwistBegin =addPacket.PathTwistBegin; 203 this.primData.PathTwistBegin =addPacket.PathTwistBegin;
147 this.dirtyFlag = true; 204 this.dirtyFlag = true;
148
149 } 205 }
150 206
151 public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID) 207 public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID)
@@ -162,7 +218,6 @@ namespace OpenSim.world
162 objupdate.ObjectData[0].ExtraParams = new byte[1]; 218 objupdate.ObjectData[0].ExtraParams = new byte[1];
163 objupdate.ObjectData[0].MediaURL = new byte[0]; 219 objupdate.ObjectData[0].MediaURL = new byte[0];
164 objupdate.ObjectData[0].NameValue = new byte[0]; 220 objupdate.ObjectData[0].NameValue = new byte[0];
165 objupdate.ObjectData[0].PSBlock = new byte[0];
166 objupdate.ObjectData[0].Text = new byte[0]; 221 objupdate.ObjectData[0].Text = new byte[0];
167 objupdate.ObjectData[0].TextColor = new byte[4]; 222 objupdate.ObjectData[0].TextColor = new byte[4];
168 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0); 223 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
@@ -232,7 +287,6 @@ namespace OpenSim.world
232 objupdate.ObjectData[0].ExtraParams = new byte[1]; 287 objupdate.ObjectData[0].ExtraParams = new byte[1];
233 objupdate.ObjectData[0].MediaURL = new byte[0]; 288 objupdate.ObjectData[0].MediaURL = new byte[0];
234 objupdate.ObjectData[0].NameValue = new byte[0]; 289 objupdate.ObjectData[0].NameValue = new byte[0];
235 objupdate.ObjectData[0].PSBlock = new byte[0];
236 objupdate.ObjectData[0].Text = new byte[0]; 290 objupdate.ObjectData[0].Text = new byte[0];
237 objupdate.ObjectData[0].TextColor = new byte[4]; 291 objupdate.ObjectData[0].TextColor = new byte[4];
238 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0); 292 objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
@@ -291,7 +345,6 @@ namespace OpenSim.world
291 uint ID = this.localid; 345 uint ID = this.localid;
292 byte[] bytes = new byte[60]; 346 byte[] bytes = new byte[60];
293 347
294
295 int i = 0; 348 int i = 0;
296 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 349 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
297 dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry; 350 dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry;
@@ -302,8 +355,18 @@ namespace OpenSim.world
302 bytes[i++] = (byte)((ID >> 24) % 256); 355 bytes[i++] = (byte)((ID >> 24) % 256);
303 bytes[i++]= 0; 356 bytes[i++]= 0;
304 bytes[i++]= 0; 357 bytes[i++]= 0;
305 358
306 byte[] pb = this.position.GetBytes(); 359 LLVector3 lPos;
360 if( this._physActor != null && this.physicsEnabled)
361 {
362 PhysicsVector pPos = this._physActor.Position;
363 lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
364 }
365 else
366 {
367 lPos = this.position;
368 }
369 byte[] pb = lPos.GetBytes();
307 Array.Copy(pb, 0, bytes, i, pb.Length); 370 Array.Copy(pb, 0, bytes, i, pb.Length);
308 i += 12; 371 i += 12;
309 ushort ac = 32767; 372 ushort ac = 32767;