diff options
author | Robert Adams | 2014-10-02 18:45:36 -0700 |
---|---|---|
committer | Robert Adams | 2014-11-30 19:52:58 -0800 |
commit | cf85ade81e38e692fe99c71386ab2c306ab77319 (patch) | |
tree | ba8dd76e62a4a989ae46f02dfe028ef0ee3d37fd | |
parent | A little more cleaning of config files. (diff) | |
download | opensim-SC_OLD-cf85ade81e38e692fe99c71386ab2c306ab77319.zip opensim-SC_OLD-cf85ade81e38e692fe99c71386ab2c306ab77319.tar.gz opensim-SC_OLD-cf85ade81e38e692fe99c71386ab2c306ab77319.tar.bz2 opensim-SC_OLD-cf85ade81e38e692fe99c71386ab2c306ab77319.tar.xz |
BulletSim: add shape and linkset rebuild scheduled flags. Add BSPrim.Incomplete flag based on rebuild flags to say when an object is being rebuilt.
Diffstat (limited to '')
7 files changed, 101 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 63b70e4..c670cca 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -73,8 +73,12 @@ public sealed class BSCharacter : BSPhysObject | |||
73 | // base.RawVelocity = value; } | 73 | // base.RawVelocity = value; } |
74 | // } | 74 | // } |
75 | 75 | ||
76 | // Avatars are always complete (in the physics engine sense) | ||
77 | public override bool IsIncomplete { get { return false; } } | ||
78 | |||
76 | public BSCharacter( | 79 | public BSCharacter( |
77 | uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying) | 80 | uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 vel, OMV.Vector3 size, bool isFlying) |
81 | |||
78 | : base(parent_scene, localID, avName, "BSCharacter") | 82 | : base(parent_scene, localID, avName, "BSCharacter") |
79 | { | 83 | { |
80 | _physicsActorType = (int)ActorTypes.Agent; | 84 | _physicsActorType = (int)ActorTypes.Agent; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 77f69a5..e7b10fe 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -128,6 +128,7 @@ public abstract class BSLinkset | |||
128 | m_children = new Dictionary<BSPrimLinkable, BSLinkInfo>(); | 128 | m_children = new Dictionary<BSPrimLinkable, BSLinkInfo>(); |
129 | LinksetMass = parent.RawMass; | 129 | LinksetMass = parent.RawMass; |
130 | Rebuilding = false; | 130 | Rebuilding = false; |
131 | RebuildScheduled = false; | ||
131 | 132 | ||
132 | parent.ClearDisplacement(); | 133 | parent.ClearDisplacement(); |
133 | } | 134 | } |
@@ -297,8 +298,16 @@ public abstract class BSLinkset | |||
297 | 298 | ||
298 | // Flag denoting the linkset is in the process of being rebuilt. | 299 | // Flag denoting the linkset is in the process of being rebuilt. |
299 | // Used to know not the schedule a rebuild in the middle of a rebuild. | 300 | // Used to know not the schedule a rebuild in the middle of a rebuild. |
301 | // Because of potential update calls that could want to schedule another rebuild. | ||
300 | protected bool Rebuilding { get; set; } | 302 | protected bool Rebuilding { get; set; } |
301 | 303 | ||
304 | // Flag saying a linkset rebuild has been scheduled. | ||
305 | // This is turned on when the rebuild is requested and turned off when | ||
306 | // the rebuild is complete. Used to limit modifications to the | ||
307 | // linkset parameters while the linkset is in an intermediate state. | ||
308 | // Protected by a "lock(this)" on the BSLinkset object | ||
309 | public bool RebuildScheduled { get; protected set; } | ||
310 | |||
302 | // The object is going dynamic (physical). Do any setup necessary | 311 | // The object is going dynamic (physical). Do any setup necessary |
303 | // for a dynamic linkset. | 312 | // for a dynamic linkset. |
304 | // Only the state of the passed object can be modified. The rest of the linkset | 313 | // Only the state of the passed object can be modified. The rest of the linkset |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 6586099..582ba5b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -106,13 +106,21 @@ public sealed class BSLinksetCompound : BSLinkset | |||
106 | // When rebuilding, it is possible to set properties that would normally require a rebuild. | 106 | // When rebuilding, it is possible to set properties that would normally require a rebuild. |
107 | // If already rebuilding, don't request another rebuild. | 107 | // If already rebuilding, don't request another rebuild. |
108 | // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. | 108 | // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. |
109 | if (!Rebuilding && HasAnyChildren) | 109 | lock (this) |
110 | { | 110 | { |
111 | m_physicsScene.PostTaintObject("BSLinksetCompound.ScheduleRebuild", LinksetRoot.LocalID, delegate() | 111 | if (!RebuildScheduled) |
112 | { | 112 | { |
113 | if (HasAnyChildren) | 113 | if (!Rebuilding && HasAnyChildren) |
114 | RecomputeLinksetCompound(); | 114 | { |
115 | }); | 115 | RebuildScheduled = true; |
116 | m_physicsScene.PostTaintObject("BSLinksetCompound.ScheduleRebuild", LinksetRoot.LocalID, delegate() | ||
117 | { | ||
118 | if (HasAnyChildren) | ||
119 | RecomputeLinksetCompound(); | ||
120 | RebuildScheduled = false; | ||
121 | }); | ||
122 | } | ||
123 | } | ||
116 | } | 124 | } |
117 | } | 125 | } |
118 | 126 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index b0a5ef1..4384cdc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | |||
@@ -212,20 +212,28 @@ public sealed class BSLinksetConstraints : BSLinkset | |||
212 | // When rebuilding, it is possible to set properties that would normally require a rebuild. | 212 | // When rebuilding, it is possible to set properties that would normally require a rebuild. |
213 | // If already rebuilding, don't request another rebuild. | 213 | // If already rebuilding, don't request another rebuild. |
214 | // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. | 214 | // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. |
215 | if (!Rebuilding && HasAnyChildren) | 215 | lock (this) |
216 | { | 216 | { |
217 | // Queue to happen after all the other taint processing | 217 | if (!RebuildScheduled) |
218 | m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() | ||
219 | { | 218 | { |
220 | if (HasAnyChildren) | 219 | if (!Rebuilding && HasAnyChildren) |
221 | { | 220 | { |
222 | // Constraints that have not been changed are not rebuild but make sure | 221 | RebuildScheduled = true; |
223 | // the constraint of the requestor is rebuilt. | 222 | // Queue to happen after all the other taint processing |
224 | PhysicallyUnlinkAChildFromRoot(LinksetRoot, requestor); | 223 | m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() |
225 | // Rebuild the linkset and all its constraints. | 224 | { |
226 | RecomputeLinksetConstraints(); | 225 | if (HasAnyChildren) |
226 | { | ||
227 | // Constraints that have not been changed are not rebuild but make sure | ||
228 | // the constraint of the requestor is rebuilt. | ||
229 | PhysicallyUnlinkAChildFromRoot(LinksetRoot, requestor); | ||
230 | // Rebuild the linkset and all its constraints. | ||
231 | RecomputeLinksetConstraints(); | ||
232 | } | ||
233 | RebuildScheduled = false; | ||
234 | }); | ||
227 | } | 235 | } |
228 | }); | 236 | } |
229 | } | 237 | } |
230 | } | 238 | } |
231 | 239 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index e4d8df8..2b744a0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -136,6 +136,15 @@ public abstract class BSPhysObject : PhysicsActor | |||
136 | // This mostly prevents property updates and collisions until the object is completely here. | 136 | // This mostly prevents property updates and collisions until the object is completely here. |
137 | public bool IsInitialized { get; protected set; } | 137 | public bool IsInitialized { get; protected set; } |
138 | 138 | ||
139 | // Set to 'true' if an object (mesh/linkset/sculpty) is not completely constructed. | ||
140 | // This test is used to prevent some updates to the object when it only partially exists. | ||
141 | // There are several reasons and object might be incomplete: | ||
142 | // Its underlying mesh/sculpty is an asset which must be fetched from the asset store | ||
143 | // It is a linkset who is being added to or removed from | ||
144 | // It is changing state (static to physical, for instance) which requires rebuilding | ||
145 | // This is a computed value based on the underlying physical object construction | ||
146 | abstract public bool IsIncomplete { get; } | ||
147 | |||
139 | // Return the object mass without calculating it or having side effects | 148 | // Return the object mass without calculating it or having side effects |
140 | public abstract float RawMass { get; } | 149 | public abstract float RawMass { get; } |
141 | // Set the raw mass but also update physical mass properties (inertia, ...) | 150 | // Set the raw mass but also update physical mass properties (inertia, ...) |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 27ee5ac..c88a5c2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -141,6 +141,18 @@ public class BSPrim : BSPhysObject | |||
141 | public override bool Stopped { | 141 | public override bool Stopped { |
142 | get { return false; } | 142 | get { return false; } |
143 | } | 143 | } |
144 | |||
145 | public override bool IsIncomplete { | ||
146 | get { | ||
147 | return ShapeRebuildScheduled; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | // 'true' if this object's shape is in need of a rebuild and a rebuild has been queued. | ||
152 | // The prim is still available but its underlying shape will change soon. | ||
153 | // This is protected by a 'lock(this)'. | ||
154 | public bool ShapeRebuildScheduled { get; protected set; } | ||
155 | |||
144 | public override OMV.Vector3 Size { | 156 | public override OMV.Vector3 Size { |
145 | get { return _size; } | 157 | get { return _size; } |
146 | set { | 158 | set { |
@@ -159,13 +171,37 @@ public class BSPrim : BSPhysObject | |||
159 | ForceBodyShapeRebuild(false); | 171 | ForceBodyShapeRebuild(false); |
160 | } | 172 | } |
161 | } | 173 | } |
174 | // Cause the body and shape of the prim to be rebuilt if necessary. | ||
175 | // If there are no changes required, this is quick and does not make changes to the prim. | ||
176 | // If rebuilding is necessary (like changing from static to physical), that will happen. | ||
177 | // The 'ShapeRebuildScheduled' tells any checker that the body/shape may change shortly. | ||
178 | // The return parameter is not used by anyone. | ||
162 | public override bool ForceBodyShapeRebuild(bool inTaintTime) | 179 | public override bool ForceBodyShapeRebuild(bool inTaintTime) |
163 | { | 180 | { |
164 | PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ForceBodyShapeRebuild", delegate() | 181 | if (inTaintTime) |
165 | { | 182 | { |
183 | // If called in taint time, do the operation immediately | ||
166 | _mass = CalculateMass(); // changing the shape changes the mass | 184 | _mass = CalculateMass(); // changing the shape changes the mass |
167 | CreateGeomAndObject(true); | 185 | CreateGeomAndObject(true); |
168 | }); | 186 | } |
187 | else | ||
188 | { | ||
189 | lock (this) | ||
190 | { | ||
191 | // If a rebuild is not already in the queue | ||
192 | if (!ShapeRebuildScheduled) | ||
193 | { | ||
194 | // Remember that a rebuild is queued -- this is used to flag an incomplete object | ||
195 | ShapeRebuildScheduled = true; | ||
196 | PhysScene.TaintedObject(LocalID, "BSPrim.ForceBodyShapeRebuild", delegate() | ||
197 | { | ||
198 | _mass = CalculateMass(); // changing the shape changes the mass | ||
199 | CreateGeomAndObject(true); | ||
200 | ShapeRebuildScheduled = false; | ||
201 | }); | ||
202 | } | ||
203 | } | ||
204 | } | ||
169 | return true; | 205 | return true; |
170 | } | 206 | } |
171 | public override bool Grabbed { | 207 | public override bool Grabbed { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 430d645..cdd912d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | |||
@@ -54,6 +54,14 @@ public class BSPrimLinkable : BSPrimDisplaced | |||
54 | 54 | ||
55 | public BSLinkset.LinksetImplementation LinksetType { get; set; } | 55 | public BSLinkset.LinksetImplementation LinksetType { get; set; } |
56 | 56 | ||
57 | public override bool IsIncomplete | ||
58 | { | ||
59 | get | ||
60 | { | ||
61 | return base.IsIncomplete || Linkset.RebuildScheduled ; | ||
62 | } | ||
63 | } | ||
64 | |||
57 | public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, | 65 | public BSPrimLinkable(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, |
58 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) | 66 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) |
59 | : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical) | 67 | : base(localID, primName, parent_scene, pos, size, rotation, pbs, pisPhysical) |